class Team(models.Model): """This class represents a working group within UTN""" class Meta: verbose_name = _('Team') verbose_name_plural = _('Teams') default_permissions = () permissions = (('admin', _('Can administrate the recruitment process')), ) group = models.OneToOneField( Group, on_delete=models.PROTECT, ) # ---- General Information ------ name_en = models.CharField( max_length=255, verbose_name=_('English team name'), help_text=_('Enter the name of the team'), blank=False, ) name_sv = models.CharField( max_length=255, verbose_name=_('Swedish team name'), help_text=_('Enter the name of the team'), blank=False, ) name = TranslatedField('name_en', 'name_sv') logo = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') description_en = models.TextField( verbose_name=_('English team description'), help_text=_('Enter a description of the team'), blank=True, ) description_sv = models.TextField( verbose_name=_('Swedish team description'), help_text=_('Enter a description of the team'), blank=True, ) description = TranslatedField('description_en', 'description_sv') def __str__(self) -> str: return '{}'.format(self.name) def get_members(self): return get_user_model().objects.filter( application__position__role__team=self, application__position__term_from__lte=date.today(), application__position__term_to__gte=date.today(), application__status='appointed', ) def get_manual_members(self): members = self.get_members().values('pk') return get_user_model().objects.filter(groups=self.group).exclude( pk__in=members) # ------ Administrator settings ------ panels = [ MultiFieldPanel([ FieldRowPanel([ FieldPanel('name_en'), FieldPanel('name_sv'), ]), FieldPanel('group'), ImageChooserPanel('logo'), FieldPanel('description_en'), FieldPanel('description_sv'), ]) ]
class Application(ClusterableModel): """An application is made to strive to acquire an position""" position = models.ForeignKey( 'Position', related_name='applications', on_delete=models.PROTECT, blank=False, ) applicant = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=False, ) class Meta: verbose_name = _('Application') verbose_name_plural = _('Applications') unique_together = ('position', 'applicant') default_permissions = () STATUS_CHOICES = ( ('draft', _('Draft')), ('submitted', _('Submitted')), ('approved', _('Approved')), ('disapproved', _('Disapproved')), ('appointed', _('Appointed')), ('turned_down', _('Turned down')), ) status = models.CharField( max_length=20, choices=STATUS_CHOICES, verbose_name=_('Status'), blank=False, null=False, ) # ---- Application Information ------ cover_letter = models.TextField( verbose_name=_('Cover Letter'), help_text=_('Present yourself and state why you are who we are ' 'looking for'), blank=True, ) qualifications = models.TextField( verbose_name=_('Qualifications'), help_text=_('Give a summary of relevant qualifications'), blank=True, ) # Access overhead removed = models.BooleanField(default=False, ) # ------ Administrator settings ------ panels = [ MultiFieldPanel([ FieldRowPanel([ FieldPanel('applicant'), FieldPanel('position'), ]), FieldPanel('cover_letter'), FieldPanel('qualifications'), InlinePanel('references'), FieldPanel('status'), ]) ]
class Role(models.Model): """ This class represents a role within a team or UTN """ class Meta: verbose_name = _('Role') verbose_name_plural = _('Roles') default_permissions = () team = models.ForeignKey( 'Team', related_name='roles', on_delete=models.PROTECT, null=True, blank=True, ) official = models.BooleanField( verbose_name=_('Official'), help_text=_('This is an official role'), default=False, ) # Display position in selection? archived = models.BooleanField( verbose_name=_('Archived'), help_text=_('Hide the role from menus'), default=False, ) # ---- General Information ------ name_en = models.CharField( max_length=255, verbose_name=_('English role name'), help_text=_('Enter the name of the role'), blank=False, ) name_sv = models.CharField( max_length=255, verbose_name=_('Swedish role name'), help_text=_('Enter the name of the role'), blank=False, ) name = TranslatedField('name_en', 'name_sv') description_en = models.TextField( verbose_name=_('English role description'), help_text=_('Enter a description of the role'), blank=True, ) description_sv = models.TextField( verbose_name=_('Swedish role description'), help_text=_('Enter a description of the role'), blank=True, ) description = TranslatedField('description_en', 'description_sv') election_email = models.EmailField( verbose_name=_('Election contact email address'), help_text=_('The email address to contact for more information ' 'regarding the role.'), blank=False, default='*****@*****.**', ) def in_role(self): member_model = apps.get_model(settings.AUTH_USER_MODEL) return member_model.objects.filter( application__position__role=self, application__status='appointed', application__position__term_from__lte=date.today(), application__position__term_to__gte=date.today(), ) def __str__(self) -> str: if self.team: return _('%(role)s in %(team)s') % { 'role': self.name, 'team': self.team, } else: return self.name # ------ Administrator settings ------ panels = [ MultiFieldPanel([ FieldPanel('team'), FieldRowPanel([ FieldPanel('name_en'), FieldPanel('name_sv'), ]), FieldPanel('election_email'), FieldPanel('description_en'), FieldPanel('description_sv'), FieldRowPanel([ FieldPanel('archived'), FieldPanel('official'), ]), ]) ]
elif self.email and not self.external_url: self.link_type = self.LINK_TYPE_EMAIL super(BaseLink, self).save(*args, **kwargs) @classmethod def get_edit_handler(cls): """ Returns edit handler instance. :rtype: wagtail.wagtailadmin.edit_handlers.ObjectList. """ return ObjectList(cls.content_panels) class Link(BaseLink): """ Concrete implementation of link. """ pass Link.content_panels = [ FieldPanel('title', classname='full title'), MultiFieldPanel([ FieldRowPanel([ FieldPanel('external_url', classname='col6'), FieldPanel('email', classname='col6'), ], classname='label-above'), ], _(u'Link Type (complete one or the other)')), FieldPanel('tags'), ]