`
dream_people
  • 浏览: 60089 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

1111111111

    博客分类:
  • VJ
阅读更多

#coding:utf-8
from django.db import models
from datetime import datetime
from django.contrib.auth.models import User

#发布形式
class PublishType(models.Model):
    name = models.CharField(max_length = 20)

    def __unicode__(self):
        return self.name

#产权单位
class Unit(models.Model):
    name = models.CharField(max_length = 200)

    def __unicode__(self):
        return self.name

#路段
class Road(models.Model):
    name = models.CharField(max_length = 200)

    def __unicode__(self):
        return self.name

#方向
class Direction(models.Model):
    name = models.CharField(max_length = 20)

    def __unicode__(self):
        return self.name

#当前广告牌状态
class BillboardState(models.Model):
    name = models.CharField(max_length = 20)

    def __unicode__(self):
        return self.name

#广告牌
class Billboard(models.Model):
    address = models.CharField(max_length = 200,verbose_name=u"地址")

    direction_type = models.ForeignKey(Direction,verbose_name=u"上下行")
    publish_type = models.ForeignKey(PublishType,verbose_name=u"发布方式")
    pile_number = models.CharField(max_length = 50,verbose_name=u"桩号")
    position = models.CharField(max_length = 50,verbose_name=u"位置")
    approval_code = models.CharField(max_length = 50,verbose_name=u"路政审批号")

    image = models.ImageField(verbose_name = u"照片",upload_to="upload/image",blank=True)

    state = models.ForeignKey(BillboardState,verbose_name=u"状态")

    insert_date = models.DateTimeField()
    insert_operator = models.ForeignKey(User)

    update_date = models.DateTimeField()
    update_operator = models.ForeignKey(User,related_name = 'op_user')

    def __unicode__(self):
        return self.pile_number

#合同状态
class ContractState(models.Model):
    name = models.CharField(max_length = 20)

    def __unicode__(self):
        return self.name

#付费方式
class PayType(models.Model):
    name = models.CharField(max_length = 20)

    def __unicode__(self):
        return self.name

#合同
class Contract(models.Model):
    code = models.CharField(max_length = 20,verbose_name=u'合同号')
    state = models.ForeignKey(ContractState,verbose_name=u'状态')

    pay_type = models.ForeignKey(PayType,verbose_name=u'付款方式')

    total_fee = models.FloatField(verbose_name=u'总费用',default = 0)
    payed_fee = models.FloatField(verbose_name=u'已付费用',default = 0)

    billboard = models.ForeignKey(Billboard,verbose_name=u'广告牌')
    active_date = models.DateTimeField(verbose_name=u'起始时间')
    inactive_date = models.DateTimeField(verbose_name=u'截止时间')

    insert_date = models.DateTimeField()
    insert_operator = models.ForeignKey(User)

    notes = models.CharField(max_length = 200,verbose_name=u'备注',blank=True)

#付费状态
class PayState(models.Model):
    name = models.CharField(max_length = 20)

    def __unicode__(self):
        return self.name

#账单
class Bill(models.Model):
    contract = models.ForeignKey(Contract)
    total_fee = models.FloatField(verbose_name = u'总费用')
    payed_fee = models.FloatField(verbose_name = u'已付费用',default = 0)

    pay_date = models.DateTimeField(verbose_name=u'付费时间')
    payed_date = models.DateTimeField()

    pay_state = models.ForeignKey(PayState,verbose_name = u'状态')

    insert_date = models.DateTimeField()
    insert_operator = models.ForeignKey(User)

    notes = models.CharField(max_length = 200,verbose_name=u'备注',blank=True)

#付费日志
class BillLog(models.Model):
    bill = models.ForeignKey(Bill)
    fee = models.FloatField(verbose_name=u'费用')

    insert_date = models.DateTimeField()
    insert_operator = models.ForeignKey(User)
    notes = models.CharField(max_length = 200,verbose_name='备注',blank=True)

 

from django import forms
from billboard import models as bm

class BillboardForm(forms.ModelForm):
    class Meta:
        model = bm.Billboard
        fields = ('address','direction_type','publish_type','pile_number',
                'position','approval_code','image','state')
   

class ContractForm(forms.ModelForm):
    billboard = forms.ModelChoiceField(queryset=bm.Billboard.objects.all(),widget=forms.HiddenInput)
    class Meta:
        model = bm.Contract
        fields = ('code','state','pay_type','billboard','active_date','inactive_date','notes')

class BillForm(forms.ModelForm):
    contract = forms.ModelChoiceField(queryset=bm.Contract.objects.all(),widget=forms.HiddenInput)
    class Meta:
        model = bm.Bill
        fields = ('contract','total_fee','pay_date','notes')

class BillLogForm(forms.ModelForm):
    bill = forms.ModelChoiceField(queryset=bm.Bill.objects.all(),widget=forms.HiddenInput)
    class Meta:
        model = bm.BillLog
        fields = ('bill','fee','notes')

分享到:
| 111
评论

相关推荐

Global site tag (gtag.js) - Google Analytics