예제 #1
0
class RefundPolicy(models.Model):
    category = models.ForeignKey(Category,
                                 on_delete=models.DO_NOTHING,
                                 related_name='refunds')
    provider = models.ForeignKey(Company,
                                 on_delete=models.DO_NOTHING,
                                 related_name='refunds')
    validity = models.IntegerField()
    cover = models.CharField(
        max_length=160,
        error_messages={'max_length': 'Should be of 160 Characters'})
    type_acceptance = models.CharField(
        max_length=160,
        error_messages={'max_length': 'Should be of 160 Characters'})
    description = models.TextField()
    is_deleted = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = CustomModelManager.from_queryset(CustomModelQuerySet)()

    class Meta:
        db_table = 'refunds_refund_policy'

    def __str__(self):
        return '{}'.format(self.category)
예제 #2
0
class Comment(models.Model):
    user = models.ForeignKey(User,
                             on_delete=models.DO_NOTHING,
                             related_name='comments',
                             null=True,
                             blank=True)
    guest_user = models.ForeignKey(GuestEmail,
                                   on_delete=models.DO_NOTHING,
                                   related_name='comments',
                                   null=True,
                                   blank=True)
    item = models.ForeignKey(Item,
                             on_delete=models.DO_NOTHING,
                             related_name='comments')
    fiscal_year = models.ForeignKey(FiscalYear,
                                    on_delete=models.DO_NOTHING,
                                    related_name='comments')
    comment = models.TextField()
    is_deleted = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = CustomModelManager.from_queryset(CustomModelQuerySet)()

    class Meta:
        db_table = 'comments_comment'

    def __str__(self):
        if not self.user == None:
            return '{}'.format(self.user.email)
        elif not self.guest_user == None:
            return '{}'.format(self.guest_user.email)
        else:
            return 'random '
예제 #3
0
class FiscalYear(models.Model):
    name = models.CharField(
        max_length=64,
        error_messages={
            'max_length': 'Length Shouldnot exceed 64 Characters'}
    )
    is_active = models.BooleanField(default=False)
    is_deleted = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = CustomModelManager.from_queryset(CustomModelQuerySet)()

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'settings_fiscal_year'
        verbose_name = 'Fiscal Year'
        verbose_name_plural = 'Fiscal Years'

    @staticmethod
    def get_active_fiscal_year():
        try:
            fiscal_year = FiscalYear.objects.get(is_active=True, is_deleted=False)
        except FiscalYear.DoesNotExist:
            fiscal_year = None
        return fiscal_year
예제 #4
0
class CompanyAdmin(models.Model):
    full_name = models.CharField(max_length=120,
                                 error_messages={
                                     'max_length':
                                     'Length Shouldnot exceed 120 Characters'
                                 })
    user = models.OneToOneField(User,
                                related_name='company_admin',
                                on_delete=models.DO_NOTHING,
                                null=True,
                                blank=True)
    company = models.ForeignKey(Company,
                                related_name='company_admins',
                                on_delete=models.DO_NOTHING,
                                null=True,
                                blank=True)
    email = models.EmailField(
        validators=[EmailValidator(message="Invalid Email Address")])
    password = models.CharField(max_length=20)
    is_deleted = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = CustomModelManager.from_queryset(CustomModelQuerySet)()

    def __str__(self):
        return '{}'.format(self.full_name)

    class Meta:
        db_table = 'companies_company_admin'
        verbose_name = 'Company Admin'
        verbose_name_plural = 'Company Admins'
예제 #5
0
class CompanyCategory(models.Model):
    company = models.OneToOneField(Company,
                                   related_name='company_category',
                                   on_delete=models.DO_NOTHING)
    category = models.ManyToManyField(Category,
                                      related_name='company_categories')
    is_deleted = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = CustomModelManager.from_queryset(CustomModelQuerySet)()

    def __str__(self):
        return '{0}'.format(self.id)

    class Meta:
        db_table = 'companies_company_category'
        verbose_name = 'Company Category'
        verbose_name_plural = 'Company Categories'
예제 #6
0
class Category(models.Model):
    name = models.CharField(max_length=120, error_messages={'max_length':'Length Should Not Exceed 120 Characters '})
    slug = models.SlugField(max_length=100, blank=True, null=True)
    description = models.TextField(null=True, blank=True)
    is_deleted = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = CustomModelManager.from_queryset(CustomModelQuerySet)()

    class Meta:
        db_table = 'categories_category'
        verbose_name = 'Category'
        

    def __str__(self):
        return self.name

    def __unicode__(self):
        return self.name
예제 #7
0
class Company(models.Model):
    name = models.CharField(max_length=64,
                            error_messages={
                                'max_length':
                                "Length Shouldn't exceed 64 characters "
                            })

    address = models.CharField(
        max_length=64,
        error_messages={'max_length': "Length Shouldn't exceed 64 characters"})
    postal = models.CharField(
        max_length=20,
        error_messages={'max_length': "Length Shouldn't exceed 20 characters"})
    city = models.CharField(
        max_length=64,
        error_messages={'max_length': "Length Shouldn't exceed 64 characters"})
    email = models.EmailField(
        validators=[EmailValidator(message="Invalid Email Address")])

    phone_number = models.CharField(
        max_length=15,
        error_messages={'max_length': "Length Shouldn't exceed 15 digits "})

    is_deleted = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = CustomModelManager.from_queryset(CustomModelQuerySet)()

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'companies_company'
        verbose_name = 'Company'
        verbose_name_plural = 'Companies'