示例#1
0
class Customer(BaseModel):

    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    user = models.ForeignKey(
        User, null=True, blank=True,related_name='cutomers',on_delete=models.PROTECT)
    address = models.TextField(max_length=200)
    email = models.CharField(max_length=30)
    phone = models.CharField(max_length=20)
    point_of_contact = models.CharField(max_length=50)
    city = models.CharField(max_length=50)
    state = models.CharField(max_length=50)
    zip_code = models.CharField(max_length=50)
    country = CountryField()
    webiste = models.CharField(max_length=50)


    class Meta:
        ordering = ('-pk',)

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

    def __str__(self):
        return '{}-{}'.format(self.name, self.email)    

    def get_absolute_url(self):
        return reverse('customer_detail', args=(self.slug,))


    def get_update_url(self):
        return reverse('customer_update', args=(self.slug,))
示例#2
0
class member_acceptance(models.Model):

    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='member_no',
                                          blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    member_no = models.CharField(max_length=20)
    status = models.DecimalField(max_digits=1, decimal_places=0)
    status_date = models.DateField(default=datetime.date.today)
    user_id = models.CharField(max_length=10)
    date_entered = models.DateField(default=datetime.date.today)

    class Meta:
        ordering = ('last_updated', )

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

    def get_absolute_url(self):
        return reverse('payments_member_acceptance_detail', args=(self.slug, ))

    def get_update_url(self):
        return reverse('payments_member_acceptance_update', args=(self.slug, ))
示例#3
0
class program(models.Model):

    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    description = models.TextField(max_length=1000)

    def __str__(self):
        return self.name

    class Meta:
        ordering = ('-created', )
        verbose_name = _('Program')
        verbose_name_plural = _('Programs')

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

    def get_absolute_url(self):
        return reverse('afro_app_program_detail', args=(self.slug, ))

    def get_update_url(self):
        return reverse('afro_app_program_update', args=(self.slug, ))
示例#4
0
class principal_applicant(models.Model):

    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    family_no = models.CharField(max_length=20, null=False, blank=False)
    first_name = models.CharField(max_length=40)
    postal_add = models.CharField(max_length=15)
    town = models.DecimalField(max_digits=5, decimal_places=0)
    email = models.EmailField()
    other_names = models.CharField(max_length=40)
    corp_id = models.CharField(max_length=10)
    mobile_no = models.CharField(max_length=20)
    family_size = models.DecimalField(max_digits=2, decimal_places=0)
    user_id = models.CharField(max_length=10)
    category = models.CharField(max_length=10)

    class Meta:
        ordering = ('last_updated', )

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

    def get_absolute_url(self):
        return reverse('payments_principal_applicant_detail',
                       args=(self.slug, ))

    def get_update_url(self):
        return reverse('payments_principal_applicant_update',
                       args=(self.slug, ))
示例#5
0
class member_anniversary(models.Model):

    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='member_no',
                                          blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    member_no = models.CharField(max_length=20)
    start_date = models.DateField(default=datetime.date.today)
    end_date = models.DateField(default=datetime.date.today)
    anniv = models.IntegerField()

    class Meta:
        ordering = ('last_updated', )

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

    def get_absolute_url(self):
        return reverse('payments_member_anniversary_detail',
                       args=(self.slug, ))

    def get_update_url(self):
        return reverse('payments_member_anniversary_update',
                       args=(self.slug, ))
示例#6
0
class Article(models.Model):
    title = models.CharField(max_length=200, default="No Title")
    slug = fields.AutoSlugField(unique=True, populate_from='title')
    content = models.TextField(default="Missing Text")
    creation_date = models.DateField(default=timezone.now)

    def __str__(self):
        return self.slug
示例#7
0
class BaseInitiative(models.Model):
    title = models.CharField(_('Titre'), max_length=250)
    acronym = models.CharField(_('Sigle'),
                               blank=True,
                               null=True,
                               max_length=250)
    description = models.TextField(_(u'Description'), blank=True, null=True)
    uri = models.CharField(_(u'URI principale'),
                           blank=True,
                           null=True,
                           max_length=250,
                           editable=False)

    tags = models.ManyToManyField(Term)
    #sites = models.ManyToManyField('coop_local.Site',related_name='old_rel')
    members = models.ManyToManyField('coop_local.Membre',
                                     through='coop_local.Engagement',
                                     verbose_name=_(u'Membres'))

    telephone_fixe = models.CharField(_(u'Téléphone fixe'),
                                      blank=True,
                                      null=True,
                                      max_length=14)
    email = models.EmailField(_(u'Email général'), blank=True, null=True)
    web = models.URLField(_(u'Site web'),
                          blank=True,
                          null=True,
                          verify_exists=True)
    rss = models.URLField(_(u'Flux RSS'),
                          blank=True,
                          null=True,
                          verify_exists=True)
    slug = exfields.AutoSlugField(populate_from='title', blank=True,
                                  null=True)  #TODO enlever null ensuite
    created = exfields.CreationDateTimeField(_(u'Création'), null=True)
    modified = exfields.ModificationDateTimeField(_(u'Modification'),
                                                  null=True)
    active = models.BooleanField(default=True)

    class Meta:
        abstract = True

    def __unicode__(self):
        if (self.acronym != None and len(self.title) > 40):
            return unicode(self.acronym)
        else:
            return unicode(self.title)

    #@models.permalink
    def get_absolute_url(self):
        return reverse('initiative_detail', args=[self.slug])

    # return ('/initiative/'+self.slug+'.html')
    def get_tags(self):
        return self.tags.all()

    def local_uri(self):
        return ('http://dev.credis.org:8000/initiative/' + self.slug + '/')
示例#8
0
class Timeslot(models.Model):

    # Fields 1
    title = models.IntegerField()
    slug = extension_fields.AutoSlugField(populate_from='title', blank=True)
    last_updated = models.DateTimeField(auto_now=True, editable=False)

    def __str__(self):
        return f'TS-{self.title} '
示例#9
0
class City(models.Model):

    # Fields 1
    title = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='title', blank=True)
    last_updated = models.DateTimeField(auto_now=True, editable=False)

    def __str__(self):
        return f'{self.title}'
示例#10
0
文件: models.py 项目: supracd/law2go
class Document(models.Model):

    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)

    # Relationship Fields
    client = models.ForeignKey(User, on_delete=models.CASCADE)
    type = models.ForeignKey('DocumentType', on_delete=models.CASCADE)

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

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

    def get_absolute_url(self):
        return reverse('legal_redux_document_detail', args=(self.slug, ))

    def get_update_url(self):
        return reverse('legal_redux_document_update', args=(self.slug, ))

    def save(self, *args, **kwargs):
        super(Document, self).save(*args, **kwargs)
        pdf = PdfFileReader(self.type.template.path_full)
        for field in pdf.getFormTextFields().keys():
            m = re.search(r'^(.*?)_(\d)$', field)
            if m:
                field = m.groups()[0]
            if '|' in field:
                field = field.split('|')[0]
            document_info = DocumentInfo.objects.get_or_create(name=field)[0]
            document_info.save()
            client_answer = ClientAnswer.objects.get_or_create(
                document=self, client=self.client,
                document_info=document_info)[0]
            client_answer.save()
        # Save the Document

    def generate_document(self):
        pdf = PdfFileReader(self.template.path_full)
        pdf_out = PdfFileWriter()
        for page in range(pdf.getNumPages()):
            pdf_out.addPage(pdf.getPage(page))
            values = {}
            for answer in ClientAnswer.objects.filter(document=self,
                                                      client=self.client):
                values[answer.document_info.name] = answer.answer
                for _ in range(1, 6):

                    values['{}_{}'.format(str(answer.document_info.name),
                                          str(_))] = answer.answer

            pdf_out.updatePageFormFieldValues(pdf_out.getPage(page), values)
        return pdf_out
示例#11
0
class University(models.Model):

    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    scholarship_availability = models.CharField(
        max_length=100,
        choices=(("none", "None"), ("merit-based", "Merit-based"),
                 ("need-based", "Need-based")))
    description = models.TextField(max_length=1000)
    university_type = models.CharField(max_length=100,
                                       choices=(("private", "Private"),
                                                ("public", "Public")))
    cost = models.IntegerField()
    how_to_apply = models.TextField(max_length=500)
    on_campus_housing = models.BooleanField()
    campusview = models.ImageField(upload_to="upload/images/")
    geolocation = models.TextField(max_length=1000)  #JSONField()
    application_deadline = models.DateTimeField()
    logo = models.ImageField(upload_to="upload/images/")
    pre_univ = models.BooleanField()

    def __str__(self):
        return self.name

    # Relationship Fields
    author = models.ForeignKey(
        User,
        on_delete=models.CASCADE,
        related_name="universities",
    )
    programs_offered = models.ManyToManyField(
        'afro_app.program',
        related_name="universities",
    )
    location = models.OneToOneField(
        'afro_app.Country',
        on_delete=models.CASCADE,
        related_name="universities",
    )

    class Meta:
        ordering = ('-created', )
        verbose_name = _('University')
        verbose_name_plural = _('universities')

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

    def get_absolute_url(self):
        return reverse('afro_app_university_detail', args=(self.slug, ))

    def get_update_url(self):
        return reverse('afro_app_university_update', args=(self.slug, ))
示例#12
0
文件: models.py 项目: sonicdm/pyLapse
class CollectionOptions(models.Model):
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    auto_resize = models.BooleanField(default=False)
    resize_x = models.IntegerField(blank=True)
    resize_y = models.IntegerField(blank=True)
    quality = models.IntegerField(blank=True)
    optimize = models.BooleanField(default=True)
示例#13
0
class Scholarship(models.Model):

    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    type = models.TextField(max_length=100,
                            choices=(("research scholarship",
                                      "Research scholarship"),
                                     ("study scholarship",
                                      "Study scholarship")))
    study_level = models.TextField(max_length=100,
                                   choices=(("undergraduate", "Undergraduate"),
                                            ("master", "Master"),
                                            ("doctorate", "Doctorate")))
    description = models.TextField(max_length=1000)
    application_deadline = models.DateTimeField()
    logo = models.ImageField(upload_to="upload/images/")

    def __str__(self):
        return self.name

    # Relationship Fields
    author = models.ForeignKey(
        User,
        on_delete=models.CASCADE,
        related_name="scholarships",
    )
    programs_applicable = models.ManyToManyField(
        'afro_app.program',
        related_name="scholarships",
    )
    eligible_nationalities = models.ManyToManyField(
        'afro_app.Country',
        related_name="scholarships",
    )
    university_applicable = models.ManyToManyField(
        'afro_app.University',
        related_name="scholarships",
    )

    class Meta:
        ordering = ('-created', )
        verbose_name = _('scholarship')
        verbose_name_plural = _('scholarships')

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

    def get_absolute_url(self):
        return reverse('afro_app_scholarship_detail', args=(self.slug, ))

    def get_update_url(self):
        return reverse('afro_app_scholarship_update', args=(self.slug, ))
示例#14
0
class EngineBase(models.Model):
    class Meta:
        abstract = True

    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    instance = models.CharField(max_length=100)
    parameters = models.TextField(max_length=200, blank=True, null=True)
    enable = models.NullBooleanField(default=False, blank=True, null=True)
示例#15
0
class LocationCategory(models.Model):
    label = models.CharField(max_length=60, verbose_name=_(u"label"))
    slug = exfields.AutoSlugField(populate_from=('label'))

    class Meta:
        ordering = ['label']
        verbose_name = _(u'Location category')
        verbose_name_plural = _(u'Location categories')

    def __unicode__(self):
        return unicode(self.label)
示例#16
0
class TrackedMixin(models.Model):
    slug = extension_fields.AutoSlugField(populate_from='id', blank=True)
    created = models.DateTimeField(default=timezone.now, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)

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

    def __unicode__(self):
        return u'%s' % self.slug
示例#17
0
class Customer(models.Model):

    # Fields
    name = models.CharField(max_length=255)
    pic = models.ImageField(upload_to='contacts/customer/pic/',
                            null=True,
                            blank=True)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    phonenumber = models.CharField(max_length=15)
    Address = models.TextField(max_length=100, blank=True)
    ctype = (('Wh', 'Wholesale'), ('Re', 'Retail'))
    type = models.CharField(max_length=30, choices=ctype, default='Re')
    ras = (('S/o', 'S/o'), ('D/o', 'D/o'), ('W/o', 'W/o'), ('R/o', 'R/o'))
    relatedas = models.CharField(max_length=5, choices=ras, default='S/o')
    relatedto = models.CharField(max_length=30, blank=True)
    area = models.CharField(max_length=50, blank=True)

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

    def __str__(self):
        return f"{self.name} {self.relatedas} {self.relatedto} {self.phonenumber}"

    def get_absolute_url(self):
        return reverse('contact_customer_detail', args=(self.slug, ))

    def get_update_url(self):
        return reverse('contact_customer_update', args=(self.slug, ))

    @property
    def get_loans(self):
        return self.loan_set.all()

    def get_total_loanamount(self):
        amount = self.loan_set.aggregate(total=Sum('loanamount'))
        return amount['total']

    @property
    def get_loans_count(self):
        return self.loan_set.count()

    # def get_interestdue(Self):
    #     interestdue=self.loan_set.aggregate(total=Sum('interestdue'))
    def get_gold_weight(self):
        gold = self.loan_set.filter(itemtype='Gold').aggregate(
            total=Sum('itemweight'))
        return gold['total']

    def get_silver_weight(self):
        silver = self.loan_set.filter(itemtype='Silver').aggregate(
            total=Sum('itemweight'))
        return silver['total']
示例#18
0
class Tag(models.Model):
    name = models.CharField(max_length=31, unique=True)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)

    # projects = models.ManyToManyField(Project, related_name='project_tag')

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['name']
示例#19
0
class Gender(models.Model):
    name = models.CharField(max_length=32, unique=True)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)

    created = models.DateTimeField(null=False, auto_now_add=True)
    updated = models.DateTimeField(null=False, auto_now=True)

    class Meta:
        ordering = ('name',)

    def __str__(self):
        return self.name
示例#20
0
class Barbershop(models.Model):

    # Fields
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(unique=True,
                                          populate_from='name',
                                          blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    review_rate = models.FloatField(validators=[
        MaxValueValidator(10),
        MinValueValidator(0),
    ],
                                    default=0)
    about = models.CharField(max_length=1000, null=True)
    # Relationship Fields
    owner = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        on_delete=models.CASCADE,
        related_name="barbershops",
    )
    address = models.OneToOneField('berberim.Address',
                                   on_delete=models.CASCADE,
                                   related_name="barbershops_2",
                                   null=True,
                                   blank=True)

    @property
    def active_services(self):
        return [brb_srv.service for brb_srv in self.services.all()]

    def set_new_review_rate(self, incoming_rate):
        crc = self.customer_reviews.count()
        if crc == 0: crc = 1
        new_review_rate = (float(self.review_rate * crc) +
                           incoming_rate) / float(crc + 1)
        self.review_rate = new_review_rate
        self.save()

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

    def __str__(self):
        return self.name

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

    def get_absolute_url(self):
        return reverse('berberim_barbershop_detail', args=(self.slug, ))

    def get_update_url(self):
        return reverse('berberim_barbershop_update', args=(self.slug, ))
示例#21
0
class BaseRole(models.Model):
    label = models.CharField(_(u'Intitulé'), max_length=30)
    slug = exfields.AutoSlugField(populate_from=('label'))

    class Meta:
        abstract = True

    def __unicode__(self):
        return unicode(self.label)

    def get_absolute_url(self):
        return reverse('role_detail', args=[self.slug])
示例#22
0
文件: models.py 项目: me2d09/prius
class ProposalCategory(models.Model):
    name = models.CharField(max_length=200)
    slug = extension_fields.AutoSlugField(populate_from='name',
                                          blank=True,
                                          null=True)

    class Meta:
        ordering = ('name', )
        verbose_name_plural = "categories"

    def __str__(self):
        return f'{self.name}'
示例#23
0
class Album(models.Model):
    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    description = models.TextField(max_length=500, blank=True, null=True)
    is_public = models.BooleanField(default=True)
    album_type = models.PositiveIntegerField(choices=GENERIC_ALBUM_CHOICES, default=GENERIC_ALBUM)

    # Relationship Fields
    profile = models.ForeignKey('profiles.BaseProfile', on_delete=models.CASCADE, related_name='profile_albums')

    class Meta:
        ordering = ('name',)
        unique_together = ('name', 'profile')

    def __str__(self):
        return self.name

    # auth
    def verify_ownership(self, user):
        return user == self.profile.user

    # utils
    def toggle_privacy(self):
        if self.is_public:
            self.is_public = False
        else:
            self.is_public = True
        self.save()
        return self

    def get_primary_photo(self, return_null=False):
        try:
            return self.album_photos.get(is_primary=True)
        except Photo.DoesNotExist:
            if return_null:
                return None
            else:
                return self.get_null_photo()

    def get_public_photos(self):
        return self.album_photos.filter(is_public=True)

    def get_null_photo(self):
        if self.album_type == PROFILE_PHOTO_ALBUM:
            return f"{settings.STATIC_URL}neo/images/profile-dummy.png"
        elif self.album_type == COVER_PHOTO_ALBUM:
            return f"{settings.STATIC_URL}neo/images/bg-01-01.jpg"
        else:
            return f"{settings.STATIC_URL}neo/images/colors-png/darkgray-1.png"
示例#24
0
class Term(base_models.BaseModel):
    value = models.CharField(max_length=255, unique=True)
    slug = fields.AutoSlugField(populate_from=('value', ))

    def __str__(self):
        return self.value

    @property
    def definitions(self):
        return self.definition_set.all()

    def get_absolute_url(self):
        return reverse('term-detail', kwargs={'slug': self.slug})
示例#25
0
文件: models.py 项目: sonicdm/pyLapse
class Collection(models.Model):
    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    collection_dir = models.CharField(max_length=255)

    class Meta:
        ordering = ('-last_updated',)

    def __unicode__(self):
        return u'%s' % self.slug
class MedicalInstitutionType(models.Model):
    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    metadata = JSONField(default=dict, blank=True, null=True)
    is_approved = models.BooleanField(default=True)

    class Meta:
        ordering = ('name', )

    def __str__(self):
        return f'{self.name}'
示例#27
0
文件: models.py 项目: bengosney/rhgd3
class WorkType(statusMixin, models.Model):
    title = models.CharField(max_length=150)
    slug = fields.AutoSlugField(populate_from="title")
    description = RichTextField(_("Description"))

    position = models.PositiveIntegerField(default=0)

    class Meta:
        ordering = ("position",)
        verbose_name = _("Work Type")
        verbose_name_plural = _("Work Types")

    def __str__(self):
        return self.title
示例#28
0
class DosageForm(models.Model):
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)

    name = models.CharField(max_length=512, unique=True)
    slug = extension_fields.AutoSlugField(populate_from="name", blank=True)

    objects = DosageFormManager()

    class Meta:
        ordering = ('name', )

    def __str__(self):
        return self.name
示例#29
0
class Category(models.Model):
    # Fields
    name = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='name', blank=True)
    image = models.ImageField(upload_to='categories/')

    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)

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

    def __unicode__(self):
        return u'%s' % self.slug
示例#30
0
class AggregatorsType(models.Model):

    # Fields 1
    title = models.CharField(max_length=255)
    slug = extension_fields.AutoSlugField(populate_from='title', blank=True)
    created = models.DateTimeField(auto_now_add=True, editable=False)
    last_updated = models.DateTimeField(auto_now=True, editable=False)
    # Fields 2
    manufacturer = models.CharField(max_length=255, default='N/A')
    linksIn = models.IntegerField(default=0)
    linksOut = models.IntegerField(default=0)

    def __str__(self):
        return f'Агрегатор линков {self.title} by {self.manufacturer}\