Exemple #1
0
class Ques(models.Model):
    title=models.CharField(max_length=70 ,blank=True)
    img = models.ImageField(upload_to='images')
    verify_date = ModificationDateTimeField()
    corrected_date = ModificationDateTimeField()
    text=models.TextField(max_length=1000 ,blank=True)
    ocrtext=models.TextField(max_length=1000 ,blank=True)
    post_date = models.DateTimeField(auto_now_add=True)
    #ocrstatus=models.BooleanField(default=False,verbose_name="ocr_genereted")
    status = models.BooleanField(default=True, verbose_name="Approve")
    verify = models.BooleanField(default=False, verbose_name="verify")
    corrected = models.BooleanField(default=False, verbose_name="corrected")

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('exams:update', args=[self.pk])
    
    def save(self, *args, **kwargs):
        if self.img :
            
    
            im = Image.open(self.img)
            im = im.convert('L')                             # grayscale
            im = im.filter(ImageFilter.MedianFilter())       # a little blur
            im = im.point(lambda x: 0 if x < 140 else 255)
            self.ocrtext = pytesseract.image_to_string(im)
            
        if self.status:
            if not self.corrected:
                self.text=self.ocrtext
        super(Ques, self).save(*args, **kwargs)
Exemple #2
0
class ContactMessage(models.Model):
    """
    Message sent from Contact Page
    """
    class ContactStatus(DjangoChoices):
        new = ChoiceItem('new', label=_("New"))
        in_progress = ChoiceItem('in progress', label=_("In progress"))
        closed = ChoiceItem('closed', label=_("Closed"))

    status = models.CharField(_('status'),
                              max_length=20,
                              choices=ContactStatus.choices,
                              default=ContactStatus.new)

    author = models.ForeignKey(settings.AUTH_USER_MODEL,
                               verbose_name=_('author'),
                               blank=True,
                               null=True)
    name = models.CharField(_("Name"), max_length=200)
    email = models.EmailField(_("Email"), max_length=200)
    message = models.TextField(_("Message"))

    creation_date = CreationDateTimeField(_('creation date'))
    modification_date = ModificationDateTimeField(_('last modification'))

    def __unicode__(self):
        return self.message[0:30]
Exemple #3
0
class SecurityAdvisory(models.Model):
    id = models.CharField(max_length=8, primary_key=True, db_index=True)
    title = models.CharField(max_length=200)
    impact = models.CharField(max_length=100)
    reporter = models.CharField(max_length=100, null=True)
    announced = models.DateField(null=True)
    year = models.SmallIntegerField()
    order = models.SmallIntegerField()
    fixed_in = models.ManyToManyField(Product, related_name='advisories')
    extra_data = JSONField()
    html = models.TextField()
    last_modified = ModificationDateTimeField()

    class Meta:
        ordering = ('-year', '-order')
        get_latest_by = 'last_modified'

    def __unicode__(self):
        return u'MFSA {0}'.format(self.id)

    def get_absolute_url(self):
        return reverse('security.advisory', kwargs={'pk': self.id})

    @property
    def impact_class(self):
        return self.impact.lower().split(None, 1)[0]

    @property
    def products(self):
        prods_set = set(v.product for v in self.fixed_in.all())
        return sorted(prods_set)
Exemple #4
0
class MeditationSession(models.Model):
    user = models.ForeignKey(User)
    meditation_id = models.IntegerField(
        blank=False, null=False)  # foreign key to local meditation_id
    percent_completed = models.FloatField()
    created_at = CreationDateTimeField(_('created_at'))
    updated_at = ModificationDateTimeField(_('updated_at'))
Exemple #5
0
class Hackathon(models.Model):
    class Meta:
        app_label = 'hackathon'
        db_table = 'hackathon_hackathon'
        verbose_name = 'Hackathon'
        ordering = ['-created']
        get_latest_by = 'created'

    name = models.CharField('Name', max_length=24, unique=True)
    slogan = models.CharField('Slogan', max_length=256)
    template = models.CharField('Template', max_length=32, default='default')
    slug = models.CharField('Team Slug', max_length=24, unique=True)
    cover = models.ImageField('Cover', upload_to='hackathons')
    start = models.DateTimeField('Start')
    end = models.DateTimeField('End')
    instruction = models.TextField(
        'Instructions',
        help_text='Please input the content with markdown syntax')
    created = CreationDateTimeField()
    updated = ModificationDateTimeField()

    def save(self,
             force_insert=False,
             force_update=False,
             using=None,
             update_fields=None):

        if not self.slug:
            self.slug = slugify(self.name)
        super(Hackathon, self).save(force_insert, force_update, using,
                                    update_fields)
class OrganizationContact(ValidatedModelMixin, models.Model):
    """
    Basic details for an organization contact
    """
    name = models.TextField(_('name'), null=True, blank=True, max_length=100)
    email = models.EmailField(_('email'),
                              null=True,
                              blank=True,
                              max_length=254)
    phone = models.TextField(_('phone'), null=True, blank=True, max_length=40)
    owner = models.ForeignKey(settings.AUTH_USER_MODEL,
                              verbose_name=_('owner'),
                              null=True)

    created = CreationDateTimeField(
        _('created'), help_text=_('When this contact was created.'))
    updated = ModificationDateTimeField(_('updated'))

    required_fields = ['name', 'email']

    class Meta(object):
        verbose_name = _('Partner Organization Contact')
        verbose_name_plural = _('Partner Organization Contacts')

    def __str__(self):
        return str(self.name)
Exemple #7
0
class ProjectBudgetLine(models.Model):
    """
    BudgetLine: Entries to the Project Budget sheet.
    This is the budget for the amount asked from this
    website.
    """
    project = models.ForeignKey('projects.Project')
    description = models.CharField(_('description'), max_length=255, default='')
    amount = MoneyField()

    created = CreationDateTimeField()
    updated = ModificationDateTimeField()

    @property
    def owner(self):
        return self.project.owner

    @property
    def parent(self):
        return self.project

    class Meta:
        verbose_name = _('budget line')
        verbose_name_plural = _('budget lines')

    def __unicode__(self):
        return u'{0} - {1}'.format(self.description, self.amount)
Exemple #8
0
class Tutorial(models.Model):
    LIVE = 1
    HIDDEN = 2
    STATUS_CHOICES = (
        (LIVE, _('Published')),
        (HIDDEN, _('Unpublished')),
        )
    title = models.CharField(max_length=255)
    slug = AutoSlugField(unique=True, populate_from='title')
    body = models.TextField()
    url = models.URLField(blank=True)
    thumbnail = models.ImageField(upload_to="tutorials", blank=True)
    status = models.IntegerField(choices=STATUS_CHOICES, default=HIDDEN)
    created = CreationDateTimeField()
    modified = ModificationDateTimeField()

    def __unicode__(self):
        return self.title

    @models.permalink
    def get_absolute_url(self):
        return ('tutorial:object_detail', [self.slug])

    @property
    def is_published(self):
        return self.status == self.LIVE
Exemple #9
0
class BaseModel(models.Model):
    uuid = UUIDField()
    created = CreationDateTimeField()
    modified = ModificationDateTimeField()

    class Meta:
        abstract = True
Exemple #10
0
class UserResume(models.Model):
    user = models.ForeignKey(User,
                             related_name='resumes',
                             verbose_name=_l('User'))
    city = models.CharField(max_length=200,
                            null=True,
                            blank=True,
                            verbose_name=_l('City'))
    state = models.CharField(max_length=200,
                             null=True,
                             blank=True,
                             verbose_name=_l('State'))
    country = models.CharField(max_length=200,
                               null=True,
                               blank=True,
                               verbose_name=_l('Country'))
    address = models.CharField(max_length=255, verbose_name=_l('Address'))
    website = models.URLField(max_length=255,
                              null=True,
                              blank=True,
                              verbose_name=_l('Web Site'))
    mobile_phone = models.CharField(max_length=15,
                                    verbose_name=_l('Mobile Phone'))
    local_phone = models.CharField(max_length=15,
                                   null=True,
                                   blank=True,
                                   verbose_name=_l('Local Phone'))

    created_at = CreationDateTimeField(verbose_name=_l('Created at'))
    modified_at = ModificationDateTimeField(verbose_name=_l('Modified at'))

    def __unicode__(self):
        return '%s %s' % (_('Resume for'), self.user)
Exemple #11
0
class UserResumeEducation(models.Model):
    user_resume = models.ForeignKey(UserResume,
                                    related_name='educations',
                                    verbose_name=_l('User Resume'))
    school = models.ForeignKey(School,
                               related_name='graduates',
                               verbose_name=_l('School'))
    title = models.CharField(max_length=255, verbose_name=_l('Title'))
    date_start = models.DateField(verbose_name=_l('Date Start'))
    date_end = models.DateField(null=True,
                                blank=True,
                                verbose_name=_l('Date End'))

    created_at = CreationDateTimeField(verbose_name=_l('Created at'))
    modified_at = ModificationDateTimeField(verbose_name=_l('Modified at'))

    def __unicode__(self):
        return '%s: %s, %s: %s' % (_('School'), self.school, _('Title'),
                                   self.title)

    @property
    def period(self):
        if self.date_end:
            return '%s - %s' % (self.date_start, self.date_end)

        return '%s - %s' % (self.date_start, _('Present'))

    @property
    def period_name(self):
        if self.date_end:
            return '%s - %s' % (self.date_start.strftime('%b %Y'),
                                self.date_end.strftime('%b %Y'))

        return '%s - %s' % (self.date_start.strftime('%b %Y'), _('Present'))
Exemple #12
0
class UserResumeJob(models.Model):
    user_resume = models.ForeignKey(UserResume, related_name='jobs')
    company = models.ForeignKey(Company,
                                related_name='jobs',
                                verbose_name=_l('Company'))
    title = models.CharField(max_length=255, verbose_name=_l('Title'))
    description = models.TextField(verbose_name=_l('Description'))
    date_start = models.DateField(verbose_name=_l('Date Start'))
    date_end = models.DateField(null=True,
                                blank=True,
                                verbose_name=_l('Date End'))

    created_at = CreationDateTimeField(verbose_name=_l('Created at'))
    modified_at = ModificationDateTimeField(verbose_name=_l('Modified at'))

    def __unicode__(self):
        return '%s: %s, %s: %s' % (_('Company'), self.company.name, _('Title'),
                                   self.title)

    @property
    def period(self):
        if self.date_end:
            return '%s - %s' % (self.date_start, self.date_end)

        return '%s - %s' % (self.date_start, _('Present'))

    @property
    def period_name(self):
        if self.date_end:
            return '%s - %s' % (self.date_start.strftime('%b %Y'),
                                self.date_end.strftime('%b %Y'))

        return '%s - %s' % (self.date_start.strftime('%b %Y'), _('Present'))
class Migration(migrations.Migration):

    dependencies = [
        ('osf', '0032_unquote_gd_nodesettings_folder_path'),
    ]

    operations = [
        migrations.CreateModel(
            name='Email',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('address', LowercaseEmailField(max_length=254, unique=True, db_index=True, validators=[validate_email])),
                ('user', models.ForeignKey(blank=False, null=False, on_delete=CASCADE, related_name='_emails', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.RunPython(
            populate_email_model, restore_old_emails
        ),
        migrations.RemoveField(
            model_name='osfuser',
            name='emails'
        ),
    ]
Exemple #14
0
class SubmissionHelp(models.Model):
    """Users can ask for help with a given submission"""
    PUBLISHED = 1
    DRAFT = 2
    STATUS_CHOICES = (
        (PUBLISHED, 'Published'),
        (DRAFT, 'Draft'),
    )
    parent = models.OneToOneField('challenges.SubmissionParent')
    created = CreationDateTimeField()
    updated = ModificationDateTimeField()
    notes = models.TextField()
    status = models.IntegerField(choices=STATUS_CHOICES, default=DRAFT)

    # managers
    objects = SubmissionHelpManager()

    class Meta:
        verbose_name_plural = 'Submission Help'
        ordering = ('-updated', )

    def __unicode__(self):
        return u'Help needed for %s' % self.parent

    @property
    def is_published(self):
        return self.status == self.PUBLISHED
Exemple #15
0
class Addon(models.Model):
    """Optional add-ons (applications) that are installed by the user."""

    name = models.CharField(unique=True, max_length=60)
    version = models.CharField(max_length=20,
                               help_text='Don\'t include a leading "V".')
    manufacturer = models.CharField(max_length=80)

    url_root = \
        models.CharField(unique=True,
                         max_length=40,
                         help_text="The urlconf is rooted here. "
                         "Don't use leading or trailing slashes.")

    notes = models.TextField(blank=True,
                             help_text="Instructions, release notes, etc.")

    installed_date = CreationDateTimeField()
    updated_date = ModificationDateTimeField()

    objects = ApplicationManager()

    def __unicode__(self):
        """Return a useful string."""

        return "%s v%s from %s, rooted at %s" % \
            (self.name, self.version, self.manufacturer, self.url_root)
Exemple #16
0
class Terms(models.Model):
    author = models.ForeignKey(settings.AUTH_USER_MODEL)

    created = CreationDateTimeField(_('creation date'))
    updated = ModificationDateTimeField(_('last modification'))

    date = models.DateTimeField()

    contents = models.CharField(max_length=500000)
    version = models.CharField(max_length=40)

    def __unicode__(self):
        return 'Terms {0} - {1}'.format(self.version, self.date.date())

    class Meta:
        ordering = ('-date', )
        verbose_name_plural = _('Terms')
        verbose_name = _('Term')

    @classmethod
    def get_current(cls):
        queryset = cls.objects.filter(date__lte=now()).order_by('-date')
        if queryset.count():
            return queryset.all()[0]
        return None
class OfflineMap(models.Model):
    class Meta:
        app_label = 'city_viewer'
        verbose_name = verbose_name_plural = _('离线地图')

    file = models.FileField(_('地图文件'), upload_to='uploads/offlinemaps')
    url = models.URLField(_('下载链接'), verify_exists=True, blank=True)
    center = models.CharField(_('中心坐标'),
                              max_length=100,
                              help_text=_('格式: 纬度,经度'),
                              default='0,0')
    zoom = models.CharField(_('默认层级'), max_length=2, default='16')
    min_zoom = models.CharField(_('最小层级'), max_length=2, default='12')
    max_zoom = models.CharField(_('最大层级'), max_length=2, default='18')
    in_area = models.ForeignKey(Area,
                                verbose_name=_("所属城市"),
                                blank=True,
                                null=True,
                                on_delete=models.SET_NULL)
    version = models.SmallIntegerField(default=1)
    modified_at = ModificationDateTimeField()

    def __unicode__(self):
        return self.in_area.zh_name

    def upload(self):
        try:
            url = upload(self.file,
                         bucket_name=settings.UPYUN_MAPS_BUCKET,
                         bucket_url=settings.UPYUN_MAPS_BINDING_DOMAIN)
            self.url = "http://" + settings.UPYUN_MAPS_BINDING_DOMAIN + "/" + url
            self.save()
            return True
        except Exception:
            return False
Exemple #18
0
class Enquiry(models.Model):
    email = models.EmailField()
    name = models.CharField(_('Name'), max_length=255)
    message = models.TextField(_('Message'))
    created = CreationDateTimeField()
    modified = ModificationDateTimeField()

    def get_full_name(self):
        return "{0} {1}".format(self.name)

    def __unicode__(self):
        return self.email

    class Meta:
        verbose_name = 'Enquiry'
        verbose_name_plural = 'Enquiries'
        ordering = [
            'created',
        ]

    def save(self, *args, **kwargs):
        super(Enquiry, self).save(*args, **kwargs)
        send_mail(
            '[enquiry] From Chiswick Website',
            'From {0} email: {1} \n {2}'.format(self.name, self.email,
                                                self.message),
            settings.DEFAULT_FROM_EMAIL,
            [
                '*****@*****.**',
            ],
            fail_silently=False,
        )
Exemple #19
0
class Server(models.Model):
    host = models.CharField(_('host'),
                            max_length=255,
                            help_text=_('domain or ip address'))
    user = models.ForeignKey(to=get_user_model())

    created = CreationDateTimeField(_('created'))
    modified = ModificationDateTimeField(_('modified'))

    objects = ServerManager()

    def __unicode__(self):
        return u'%s' % self.host

    class Meta:
        get_latest_by = 'modified'
        ordering = (
            '-modified',
            '-created',
        )

    def get_absolute_url(self):
        return reverse('servers:server', kwargs={'server_id': self.pk})

    def get_last_scan(self):
        scans = ScanTask.objects.get_by_server(self)
        return scans[0] if scans else None
Exemple #20
0
class BaseModel(models.Model):

    created = CreationDateTimeField()
    updated = ModificationDateTimeField()

    class Meta:
        abstract = True
Exemple #21
0
class BaseModel(models.Model):

    created = CreationDateTimeField(
        _(u'Fecha y hora de creación')
    )
    modified = ModificationDateTimeField(
        _(u'Fecha y hora de modificación')
    )

    class Meta:
        get_latest_by = 'modified'
        ordering = ('-modified', '-created',)
        abstract = True

    def __str__(self):
        return unidecode(self.__unicode__())

    def __unicode__(self):
        return u'Objeto %s (PK: %d)' % (
            self.__class__.__name__,
            self.pk
        )

    def __repr__(self):
        return '<%s object %s (PK: %d) at %s>' % (
            self.__class__.__name__,
            str(self),
            self.pk,
            hex(id(self))
        )

    def save(self, *args, **kwargs):
        self.full_clean()
        super(BaseModel, self).save(*args, **kwargs)
Exemple #22
0
class Hit(models.Model):
    created = CreationDateTimeField(editable=False)
    edited = ModificationDateTimeField(editable=False)
    path = models.CharField(db_index=True,
                            max_length=255,
                            verbose_name=_("Path"))
    method = models.CharField(max_length=6, verbose_name=_("Method"))
    ip = models.CharField(max_length=12, verbose_name=_("Ip"))
    user_agent = models.CharField(max_length=255, verbose_name=_("User agent"))
    authenticated = models.BooleanField(verbose_name=_("Authenticated user"),
                                        default=False)
    staff = models.BooleanField(verbose_name=_("Staff user"), default=False)
    superuser = models.BooleanField(verbose_name=_("Superuser"), default=False)
    username = models.CharField(db_index=True,
                                max_length=120,
                                verbose_name=_("Username"))
    referer = models.CharField(max_length=255,
                               blank=True,
                               verbose_name=_("Referer"))
    view = models.CharField(max_length=120, blank=True, verbose_name=_("View"))
    module = models.CharField(max_length=120,
                              blank=True,
                              verbose_name=_("Module"))
    status_code = models.PositiveSmallIntegerField(
        verbose_name=_("Status code"))
    reason_phrase = models.CharField(max_length=120,
                                     blank=True,
                                     verbose_name=_("Reason phrase"))
    request_time = models.PositiveIntegerField(verbose_name=_("Request time"))
    doc_size = models.PositiveIntegerField(verbose_name=_("Document size"))
    num_queries = models.PositiveIntegerField(
        verbose_name=_("Number of queries"))
    queries_time = models.PositiveIntegerField(verbose_name=_("Queries time"))
    is_tablet = models.BooleanField(default=False, verbose_name=_("Tablet"))
    is_pc = models.BooleanField(default=False, verbose_name=_("PC"))
    is_bot = models.BooleanField(default=False, verbose_name=_("Bot"))
    os = models.CharField(max_length=120, verbose_name=_("Operating system"))
    os_version = models.CharField(max_length=120,
                                  verbose_name=_("Operating system version"))
    is_tablet = models.BooleanField(default=False, verbose_name=_("Tablet"))
    is_mobile = models.BooleanField(default=False, verbose_name=_("Mobile"))
    is_touch = models.BooleanField(default=False,
                                   verbose_name=_("Has touch capabilities"))
    browser = models.CharField(max_length=255, verbose_name=_("Browser"))
    device = models.CharField(max_length=255, verbose_name=_("Device"))
    country = models.CharField(max_length=120, verbose_name=_("Country"))
    city = models.CharField(max_length=120, verbose_name=_("City"))
    latitude = models.CharField(max_length=24, verbose_name=_("Latitude"))
    longitude = models.CharField(max_length=25, verbose_name=_("Longitude"))
    region = models.CharField(max_length=120, verbose_name=_("Region"))
    city = models.CharField(max_length=120, verbose_name=_("City"))

    class Meta:
        app_label = 'watchtower'
        verbose_name = _(u'Hit')
        verbose_name_plural = _(u'Hits')
        ordering = ['-created']

    def __str__(self):
        return self.path + ' - ' + str(self.created)
Exemple #23
0
class SalesContract(models.Model):
    external_reference = models.CharField(verbose_name=_("External Reference"),
                                          max_length=100,
                                          blank=True)
    discount = models.DecimalField(max_digits=5,
                                   decimal_places=2,
                                   verbose_name=_("Discount"),
                                   blank=True,
                                   null=True)
    customer = models.ForeignKey('crm_core.Customer',
                                 verbose_name=_("Customer"))
    dateofcreation = CreationDateTimeField(verbose_name=_("Created at"),
                                           editable=False)
    lastmodification = ModificationDateTimeField(
        verbose_name=_("Last modified"), editable=False)
    lastmodifiedby = models.ForeignKey(settings.AUTH_USER_MODEL,
                                       limit_choices_to={'is_staff': True},
                                       blank=True,
                                       verbose_name=_("Last modified by"),
                                       null=True)
    pdf_path = models.CharField(max_length=200,
                                null=True,
                                blank=True,
                                editable=False)

    class Meta:
        abstract = True

    @transaction.atomic()
    @reversion.create_revision()
    def save(self, *args, **kwargs):
        super(SalesContract, self).save(*args, **kwargs)
Exemple #24
0
class Realm(models.Model):
    name = models.CharField(strings.NAME, max_length=128, unique=True)
    prefix = models.SlugField(strings.PREFIX)
    description = models.TextField(strings.DESCRIPTION)
    created_at = CreationDateTimeField(strings.CREATED_AT)
    updated_at = ModificationDateTimeField(strings.UPDATED_AT)

    class Meta:
        ordering = (
            'name',
            'created_at',
        )
        verbose_name = strings.REALM
        verbose_name_plural = strings.REALM_PLURAL

    def __unicode__(self):
        return self.name

    def apply_text_substitutions(self, text):
        substitutions = self.textsubstitution_set.all()
        for s in substitutions:
            regexp = re.compile(s.regexp)
            result = regexp.subn(s.sub, text)
            text = result[0]
        return text
Exemple #25
0
class BRCreationModificationModel(models.Model):

    data_criacao = CreationDateTimeField(_(u'Data de criação'))
    data_modificacao = ModificationDateTimeField(_(u'Data de modificação'))

    class Meta:
        abstract = True
Exemple #26
0
class Base(models.Model):
    id = models.AutoField(primary_key=True)
    created = CreationDateTimeField()
    modified = ModificationDateTimeField()

    class Meta(object):
        abstract = True
Exemple #27
0
class Comments(CommentAbstractModel):
    DEFAULT = 'default'
    DECLINE_PREVIEW = 'decline_preview'

    modified = ModificationDateTimeField(_('modified'))

    # comment type added to differentiate weather comment is for preview decline or a
    # normal comment on content of course/course run.
    comment_type = models.CharField(
        max_length=255, null=True, blank=True, choices=CommentTypeChoices.choices, default=CommentTypeChoices.Default
    )

    def save(self, *args, **kwargs):
        if self.comment_type == CommentTypeChoices.Decline_Preview:
            try:
                mark_preview_url_as_decline(self)
            except Exception:  # pylint: disable=broad-except
                # in case of exception don't save the comment
                return
        else:
            if waffle.switch_is_active('enable_publisher_email_notifications'):
                created = False if self.id else True
                send_email_for_comment(self, created)

        super(Comments, self).save(*args, **kwargs)
Exemple #28
0
class ShipmentDetails(models.Model):
    STATUS_TYPE_PENDING = 'PENDING'
    STATUS_TYPE_PROCESSED = 'PROCESSED'

    status_type_choices = ((STATUS_TYPE_PENDING, STATUS_TYPE_PENDING),
                           (STATUS_TYPE_PROCESSED, STATUS_TYPE_PROCESSED))

    id = models.CharField(max_length=24, primary_key=True, default=get_24_char_uuid)
    shipment_id = models.IntegerField(unique=True)
    shipment_date = models.DateTimeField()
    transport_id = models.CharField(max_length=30, unique=True)
    transport_label = models.CharField(max_length=15, blank=True, null=True)
    shipment_reference = models.CharField(max_length=50)
    status = models.CharField(max_length=30, choices=status_type_choices, default=STATUS_TYPE_PENDING)
    seller = models.ForeignKey(SellerDetails, on_delete=models.DO_NOTHING)
    user = models.ForeignKey(CustomerDetails, on_delete=models.DO_NOTHING, blank=True, null=True)

    created = CreationDateTimeField()
    modified = ModificationDateTimeField()

    def __unicode__(self):
        return '{} {}'.format(self.shipment_id, self.shipment_reference)

    class Meta:
        verbose_name = 'Shipment detail'
Exemple #29
0
class Contact(models.Model):
    contact_name = models.CharField(max_length=200, null=False)
    email = models.CharField(max_length=70, null=False)
    subject = models.CharField(max_length=40, null=False)
    message = models.TextField(null=True)
    created_date = CreationDateTimeField()
    updated_date = ModificationDateTimeField()
Exemple #30
0
class RechargeRecord(models.Model):
    FINISHED_CHOICES = [
        (-1, '充值失败'),
        (1, '充值成功'),
        (0, '等待管理员确认'),
    ]

    id = models.AutoField(primary_key=True, verbose_name="序号")
    user = models.ForeignKey(User,
                             on_delete=models.DO_NOTHING,
                             db_constraint=False,
                             verbose_name='用户')
    amount = models.IntegerField(verbose_name='充值金额')
    is_finished = models.IntegerField(default=0,
                                      verbose_name='充值状态',
                                      choices=FINISHED_CHOICES)
    created = CreationDateTimeField(verbose_name='充值时间')
    modified = ModificationDateTimeField(verbose_name='最后修改时间')

    class Meta:
        db_table = 'T_Recharge'
        # 末尾不加s
        verbose_name_plural = '充值记录'
        # 末尾加s
        # verbose_name='标签'

    def __str__(self):
        return str(self.user.username) + ", recharge: " + str(self.amount)