Example #1
0
class Person(models.Model):
    first_name = models.CharField(max_length=100)
    second_name = models.CharField(max_length=100, null=True, blank=True)
    last_name = models.CharField(max_length=100)
    second_last_name = models.CharField(max_length=100, null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True, null=True)
    updated_at = models.DateTimeField(auto_now=True, null=True)

    class Meta:
        default_permissions = ()
        db_table = "users_person"
        verbose_name = 'Persona'
        verbose_name_plural = 'Personas'
Example #2
0
class TimeClock(models.Model):
    employee = models.ForeignKey(Employee, related_name='time_clock')
    time_in = models.DateTimeField()
    time_out = models.DateTimeField(null=True)
    archived = models.BooleanField(default=False)

    def time_range(self):
        try:
            return self.time_out - self.time_in
        except:
            pass
        return timedelta(seconds=0)

    def __unicode__(self):
        return u'Time entry for %s' % self.employee.name
Example #3
0
class Article(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    title = models.CharField(max_length=100, blank=False, default='')
    content = models.TextField()

    category_id = models.ForeignKey(Category, related_name='article_cat', on_delete=models.CASCADE)
    created_by_user_id = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='created_by_user_id',
                                           on_delete=models.SET_NULL, blank=True, null=True)

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

    def __str__(self):
        return self.title
Example #4
0
class Supplier(models.Model):
    supplier = models.CharField(verbose_name=_('Supplier Name'), max_length=32)
    default_markup = models.PositiveIntegerField(
        verbose_name=_('Default Markup'), default=0, max_length=255)
    description = models.TextField(blank=True, verbose_name=_('Description'))
    company = models.CharField(verbose_name=_('Company'), max_length=32)
    first_name = models.CharField(verbose_name=_('First Name'), max_length=32)
    last_name = models.CharField(verbose_name=_('Last Name'), max_length=32)
    archived = models.BooleanField(default=False)
    created = models.DateTimeField(editable=False)
    phone = models.CharField(verbose_name=_('Phone'),
                             max_length=60,
                             null=True,
                             blank=True)
    mobile = models.CharField(verbose_name=_('Mobile Phone'),
                              max_length=60,
                              null=True,
                              blank=True)
    fax = models.CharField(verbose_name=_('Fax'),
                           max_length=60,
                           null=True,
                           blank=True)
    email = models.EmailField(unique=True,
                              verbose_name=_('Email'),
                              null=False,
                              blank=False)
    website = models.URLField(verbose_name=_('Website'), null=True, blank=True)
    street = models.CharField(verbose_name=_('Street'),
                              max_length=32,
                              null=True,
                              blank=True)
    suburb = models.CharField(verbose_name=_('Suburb'),
                              max_length=32,
                              null=True,
                              blank=True)
    city = models.CharField(verbose_name=_('City'),
                            max_length=32,
                            null=True,
                            blank=True)
    postcode = models.CharField(verbose_name=_('Post Code'),
                                max_length=8,
                                null=True,
                                blank=True)
    state = models.CharField(verbose_name=_('State'),
                             max_length=2,
                             choices=STATE_CHOICES,
                             null=True,
                             blank=True)
    country = CountryField(blank_label='(select a country)')

    def __unicode__(self):
        return u'%s %s' % (self.first_name, self.last_name)

    def save(self, *args, **kwargs):
        """
        On save, update timestamps
        """
        if not self.id:
            self.created = datetime.today()
        return super(Supplier, self).save(*args, **kwargs)
Example #5
0
class Post(models.Model):
    title = models.CharField(max_length=100, default='sample title')
    content = models.TextField()
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    date_posted = models.DateTimeField(default=datetime.now)

    def __str__(self):
        return self.title
Example #6
0
class ProfileImage(models.Model):
    user = models.ForeignKey(User,
                             related_name='profile_picture',
                             on_delete=models.CASCADE)
    profile_image = models.ImageField(upload_to='profile_picture',
                                      max_length=255)
    created_at = models.DateTimeField(auto_now_add=True, null=True)

    class Meta:
        default_permissions = ()
        db_table = "users_profile_image"
Example #7
0
class PersonalInformation(models.Model):
    user = models.OneToOneField(User,
                                related_name='personal_information',
                                on_delete=models.CASCADE)
    place_birth = models.CharField(max_length=255, null=True, blank=True)
    birth_date = models.DateField(null=True, blank=True)
    has_children = models.BooleanField(null=True, blank=True, default=None)
    number_of_children = models.IntegerField(null=True,
                                             blank=True,
                                             default=None)
    gender = models.ForeignKey(Gender,
                               related_name='gender',
                               null=True,
                               blank=True,
                               on_delete=models.CASCADE)
    marital_status = models.ForeignKey(MaritalStatus, on_delete=models.CASCADE)
    marital_status_description = models.TextField(null=True, blank=True)
    height = models.FloatField(null=True, blank=True)
    weight = models.FloatField(null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True, null=True)
    updated_at = models.DateTimeField(auto_now=True, null=True)
Example #8
0
class CsvCustomer(models.Model):
    group_csv = models.FileField(upload_to='csv', blank=False, null=False)
    created = models.DateTimeField(editable=False)

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

    def save(self, *args, **kwargs):
        ''' On save, update timestamps '''
        if not self.id:
            self.created = datetime.today()
        return super(CsvCustomer, self).save(*args, **kwargs)
Example #9
0
class Customer(models.Model):
    first_name = models.CharField(max_length=32)
    last_name = models.CharField(max_length=32)
    email = models.EmailField(null=True, blank=True)
    phone = models.CharField(max_length=32, null=True, blank=True)
    profile_key = models.CharField(max_length=32, null=True, blank=True)
    address = models.CharField(max_length=32, null=True, blank=True)
    rewards_points = models.IntegerField(null=True, blank=True)
    account_number = models.CharField(max_length=64, blank=True)
    notes = models.TextField(null=True, blank=True)
    archived = models.BooleanField(default=False)
    created = models.DateTimeField(editable=False)
    city = models.CharField(verbose_name=_('City'),
                            max_length=58,
                            null=True,
                            blank=True)
    state = models.CharField(verbose_name=_('State'),
                             max_length=2,
                             choices=STATE_CHOICES,
                             null=True,
                             blank=True)
    zipcode = models.CharField(verbose_name=_('Zip code'),
                               max_length=8,
                               null=True,
                               blank=True)
    group = models.ForeignKey(CustomerGroup,
                              blank=True,
                              null=True,
                              related_name='taskin_group')

    def __unicode__(self):
        return u'%s %s' % (self.first_name, self.last_name)

    def save(self, *args, **kwargs):
        """
        On save, update timestamps
        """
        if not self.id:
            self.created = datetime.today()
        return super(Customer, self).save(*args, **kwargs)

    def get_full_name(self):
        return self.first_name + ' ' + self.last_name
Example #10
0
class Doctor(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    updated_at = models.DateTimeField(auto_now=True, null=True)

    class Meta:
        default_permissions = ()
Example #11
0
class TimeStampedModel(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True
Example #12
0
class Employee(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(unique=True,
                              verbose_name=_('Email'),
                              null=False,
                              blank=False)
    photo = models.ImageField(upload_to='employee_photo/',
                              verbose_name=_('P'),
                              blank=True,
                              default='employee_photo/def.jpg')
    name = models.CharField(verbose_name=_('Name'), max_length=32)
    address = models.CharField(verbose_name=_('Address'),
                               max_length=32,
                               null=True,
                               blank=True)
    address2 = models.CharField(verbose_name=_("Address2"),
                                null=True,
                                blank=True,
                                max_length=32)
    city = models.CharField(verbose_name=_('City'),
                            max_length=32,
                            null=True,
                            blank=True)
    state = models.CharField(verbose_name=_('State'),
                             max_length=2,
                             choices=STATE_CHOICES,
                             null=True,
                             blank=True)
    zipcode = models.CharField(verbose_name=_('Zip code'),
                               max_length=8,
                               null=True,
                               blank=True)
    phone = models.CharField(verbose_name=_('Phone'),
                             max_length=60,
                             null=True,
                             blank=True)
    pin = models.IntegerField(verbose_name=_('Pin'), unique=True, null=True)
    role = models.IntegerField(verbose_name=_('Role'), choices=ROLES)
    vein_string = models.TextField(blank=True, verbose_name=_('Vein String'))
    hourly_rate = models.DecimalField(blank=True,
                                      null=True,
                                      verbose_name=_('Hourly Rate'),
                                      decimal_places=2,
                                      max_digits=5)
    archived = models.BooleanField(default=False)
    store = models.ForeignKey(Store,
                              verbose_name='Store',
                              blank=True,
                              null=True)

    USERNAME_FIELD = 'email'

    is_staff = models.BooleanField(default=False)
    is_active = models.BooleanField(default=False)
    created = models.DateTimeField(editable=False)

    objects = EmployeeManager()

    def __unicode__(self):
        return u"%s" % self.name

    def get_full_name(self):
        return self.name

    def get_short_name(self):
        return self.name

    def check_is_owner(self):
        return self.role == ROLES[0][0]

    def return_id(self):
        return self.id

    def save(self, *args, **kwargs):
        ''' On save, update timestamps '''
        if self.photo:
            try:
                self.photo = resize_image(self.photo,
                                          newsize=EMPLOYEE_PHOTO_SIZE)
            except:
                logger.exception("Error resizing image for product %s" %
                                 self.pk)
                pass
        if not self.id:
            self.created = datetime.today()
        return super(Employee, self).save(*args, **kwargs)