class Profile(models.Model): GENDERS = (('male', 'Male'), ('female', 'Female'), ('other', 'Other')) user = models.OneToOneField(settings.AUTH_USER_MODEL, default=-1, primary_key=True, on_delete=models.CASCADE) birth_date = models.DateField(null=True, blank=True, verbose_name='Date of birth') gender = models.CharField(max_length=10, choices=GENDERS, blank=True) phone_number = models.CharField(max_length=15, null=True, blank=True) dietary_restrictions = models.ManyToManyField(DietaryRestriction, blank=True) other_dietary_restrictions = models.CharField(max_length=75, blank=True, null=True) no_dietary_restrictions = models.BooleanField( null=False, blank=False) # required if no dietary_restrictions are selected programme = models.ForeignKey(Programme, null=True, blank=True, on_delete=models.CASCADE, verbose_name='Program') registration_year = models.IntegerField(null=True, blank=True) planned_graduation = models.IntegerField(null=True, blank=True) linkedin_url = models.URLField(null=True, blank=True, verbose_name='Linkedin URL') token = models.CharField(max_length=255, null=True, blank=False, default=uuid.uuid4) slack_id = models.CharField(max_length=255, null=True, blank=True, verbose_name='Slack ID') preferred_language = models.ForeignKey(Language, null=True, blank=True, on_delete=models.CASCADE) kth_synchronize = models.BooleanField( null=False, blank=False, default=True, verbose_name='Synchronize account data with KTH') picture_original = models.ImageField(upload_to=UploadToDirUUID( 'profiles', 'picture_original'), blank=True) picture = models.ImageField(upload_to=UploadToDir('profiles', 'picture'), blank=True) def __str__(self): return self.user.get_full_name() class Meta: db_table = 'profile' permissions = [('base', 'People')]
class Building(models.Model): name = models.CharField(max_length=50, blank=False) map_image = models.ImageField(upload_to=UploadToDir('building'), blank=False) def __str__(self): return self.name
class Profile(models.Model): # defining shirt sizes SHIRT_SIZES = ( ('WXS', 'Woman X-Small'), ('WS', 'Woman Small'), ('WM', 'Woman Medium'), ('WL', 'Woman Large'), ('WXL', 'Woman X-Large'), ('MXS', 'Man X-Small'), ('MS', 'Man Small'), ('MM', 'Man Medium'), ('ML', 'Man Large'), ('MXL', 'Man X-Large'), ) GENDERS = (('male', 'Male'), ('female', 'Female'), ('other', 'Other')) user = models.OneToOneField(settings.AUTH_USER_MODEL, default=-1, primary_key=True) birth_date = models.DateField(null=True, blank=True) gender = models.CharField(max_length=10, choices=GENDERS, blank=True) shirt_size = models.CharField(max_length=3, choices=SHIRT_SIZES, blank=True) phone_number = models.CharField(max_length=15, null=True, blank=True) drivers_license = models.CharField(max_length=10, null=True, blank=True) allergy = models.CharField(max_length=30, null=True, blank=True) programme = models.ForeignKey(Programme, null=True, blank=True) registration_year = models.IntegerField(null=True, blank=True) planned_graduation = models.IntegerField(null=True, blank=True) linkedin_url = models.URLField(null=True, blank=True) picture_original = models.ImageField( upload_to=UploadToDirUUID('profiles', 'picture_original'), blank=True, ) picture = models.ImageField( upload_to=UploadToDir('profiles', 'picture'), blank=True, ) def __str__(self): return '%s' % (self.user.get_full_name()) def save(self, *args, **kwargs): super(Profile, self).save(*args, **kwargs) self.picture = update_image_field(self.picture_original, self.picture, 480, 640, 'jpg') super(Profile, self).save(*args, **kwargs) class Meta: db_table = 'profile' permissions = (('view_people', 'View people'), )
class Event(models.Model): # Add event attendence per model fair = models.ForeignKey(Fair) name = models.CharField(max_length=75) event_start = models.DateTimeField() event_end = models.DateTimeField() capacity = models.PositiveSmallIntegerField(default=0, blank=True) description = models.TextField(blank=True) description_short = models.TextField(blank=True) location = models.CharField(max_length=75, blank=True) attendence_description = models.TextField( blank=True, help_text="This is a text only shown in the attendence form, example \ 'To be accepted to this event you need to pay the event fee of \ 500 SEK'") attendence_approvement_required = models.BooleanField( default=True, help_text="If this is checked all users that attends the event needs to \ be accepted by an admin.") external_signup_url = models.URLField(blank=True) registration_required = models.BooleanField(default=True) registration_start = models.DateTimeField() registration_end = models.DateTimeField() registration_last_day_cancel = models.DateTimeField( null=True, help_text="Last day a user can cancel the attendence to the event") public_registration = models.BooleanField( default=False, help_text="If users without an account should be able to sign up for \ this event.") published = models.BooleanField( default=False, help_text= "If the event should be published in the apps and on the website.") allowed_groups = models.ManyToManyField( Group, blank=True, help_text="Choose which groups in armada should be able to see and \ attend this event. NOTE: No groups make the event accesible to all \ ais-users.") send_submission_mail = models.BooleanField( default=False, help_text="If checked an email will be sent when a user attends \ the event") submission_mail_subject = models.CharField(max_length=78, blank=True) submission_mail_body = models.TextField(blank=True) confirmation_mail_subject = models.CharField(max_length=78, blank=True) confirmation_mail_body = models.TextField(blank=True) rejection_mail_subject = models.CharField(max_length=78, blank=True) rejection_mail_body = models.TextField(blank=True) image_original = models.ImageField(upload_to=UploadToDirUUID( 'events', 'image_original'), blank=True) image = models.ImageField(upload_to=UploadToDir('events', 'image'), blank=True) tags = models.ManyToManyField(Tag, blank=True) extra_field = models.ForeignKey(ExtraField, blank=True, null=True) def __str__(self): return '%s: %s' % (self.fair, self.name) def save(self, *args, **kwargs): super(Event, self).save(*args, **kwargs) if not self.extra_field: self.extra_field = ExtraField.objects.create() self.image = update_image_field(self.image_original, self.image, 1000, 1000, 'jpg') super(Event, self).save(*args, **kwargs)
class CatalogInfo(models.Model): exhibitor = models.OneToOneField( Exhibitor, on_delete=models.CASCADE, ) display_name = models.CharField(max_length=200) slug = models.SlugField(db_index=False, blank=True) short_description = models.CharField(max_length=200, blank=True) description = models.TextField() employees_sweden = models.IntegerField(default=0) employees_world = models.IntegerField(default=0) countries = models.IntegerField(default=0) website_url = models.CharField(max_length=300, blank=True) facebook_url = models.CharField(max_length=300, blank=True) twitter_url = models.CharField(max_length=300, blank=True) linkedin_url = models.CharField(max_length=300, blank=True) # Image fields # Field with name ending with original serves as the original uploaded # image and should be the only image uploaded, # the others are auto generated logo_original = models.ImageField( upload_to=UploadToDirUUID('exhibitors', 'logo_original'), blank=True, ) logo_small = models.ImageField(upload_to=UploadToDir( 'exhibitors', 'logo_small'), blank=True) logo = models.ImageField(upload_to=UploadToDir('exhibitors', 'logo'), blank=True) ad_original = models.ImageField(upload_to=UploadToDirUUID( 'exhibitors', 'ad_original'), blank=True) ad = models.ImageField(upload_to=UploadToDir('exhibitors', 'ad'), blank=True) location_at_fair_original = models.ImageField(upload_to=UploadToDirUUID( 'exhibitors', 'location_at_fair_original'), blank=True) location_at_fair = models.ImageField(upload_to=UploadToDir( 'exhibitors', 'location_at_fair'), blank=True) # ManyToMany relationships programs = models.ManyToManyField('people.Programme', blank=True) main_work_field = models.ForeignKey(WorkField, blank=True, null=True, related_name='+') work_fields = models.ManyToManyField(WorkField, blank=True, related_name='+') job_types = models.ManyToManyField(JobType, blank=True) continents = models.ManyToManyField(Continent, blank=True) values = models.ManyToManyField(Value, blank=True) tags = models.ManyToManyField('fair.Tag', blank=True) def __str__(self): return self.display_name # Override default save method to automatically generate associated images # if the original has been changed def save(self, *args, **kwargs): if self.pk is None: self.slug = slugify(self.display_name[:50]) super(CatalogInfo, self).save(*args, **kwargs) self.logo = update_image_field(self.logo_original, self.logo, 400, 400, 'png') self.logo_small = update_image_field(self.logo_original, self.logo_small, 200, 200, 'png') self.ad = update_image_field(self.ad_original, self.ad, 640, 480, 'jpg') self.location_at_fair = update_image_field( self.location_at_fair_original, self.location_at_fair, 1000, 1000, 'png') super(CatalogInfo, self).save(*args, **kwargs)