예제 #1
0
class MindSETModule(models.Model):
    title = models.CharField(max_length=128)
    concepts = models.TextField()
    presentation          = ContentTypeRestrictedFileField(
        upload_to='mindset_module_presentations',
        content_types=presentation_types,
        max_upload_size=262144000,
        blank=True
    )
    worksheet          = ContentTypeRestrictedFileField(
        upload_to='mindset_module_worksheets',
        content_types=worksheet_types,
        max_upload_size=262144000,
        blank=True
    )
    def __unicode__(self):
        return self.title
예제 #2
0
class CorporateResourceGuide(models.Model):
    active = models.BooleanField()
    name = models.CharField(max_length=64)
    resource_guide = ContentTypeRestrictedFileField(
        upload_to='corporate_resources',
        content_types=pdf_types,
        max_upload_size=104857600,
        blank=False)
예제 #3
0
class VolunteerFile(models.Model):
    name = models.CharField(max_length=128)
    description=models.TextField(blank=True)
    the_file          = ContentTypeRestrictedFileField(
        upload_to='mindset_volunteer_files',
        content_types=pdf_types,
        max_upload_size=262144000,
        blank=False
    )
예제 #4
0
class VolunteerFile(models.Model):
    """ Files needed by volunteers e.g. the background check form.
    """
    name = models.CharField(max_length=128)
    description = models.TextField(blank=True)
    the_file = ContentTypeRestrictedFileField(
        upload_to='mindset_volunteer_files',
        content_types=pdf_types,
        max_upload_size=262144000,
        blank=False
    )
예제 #5
0
class ElecteeResource(models.Model):
    resource_type = models.ForeignKey(ElecteeResourceType)
    term = models.ForeignKey('mig_main.AcademicTerm')

    resource_file = ContentTypeRestrictedFileField(
        upload_to='electee_resources',
        content_types=pdf_types,
        max_upload_size=104857600,
        blank=False)

    def __unicode__(self):
        return str(self.resource_type) + ' for ' + str(self.term)
예제 #6
0
class GoverningDocument(models.Model):
    document_type = models.ForeignKey(GoverningDocumentType)
    active = models.BooleanField(default=True)
    pdf_file = ContentTypeRestrictedFileField(
        upload_to='governing_docs',
        content_types=pdf_types,
        max_upload_size=104857600,
    )

    def __unicode__(self):
        if self.active:
            return 'Current ' + unicode(self.document_type)
        else:
            return 'Old ' + unicode(self.document_type)
예제 #7
0
class Publication(models.Model):
    date_published = models.DateField()
    volume_number = models.PositiveSmallIntegerField()
    edition_number = models.PositiveSmallIntegerField()
    name = models.CharField(max_length=70)
    PUBlICATION_TYPES = [('CS', 'Cornerstone'), ('AN', 'Alumni News')]
    type = models.CharField(max_length=2,
                            choices=PUBlICATION_TYPES,
                            default='CS')
    pdf_file = ContentTypeRestrictedFileField(
        upload_to='newsletters',
        content_types=pdf_types,
        max_upload_size=104857600,
    )

    def __unicode__(self):
        return self.name
예제 #8
0
class BookSwapContract(models.Model):
    """ Contracts for buyers or sellers"""
    TYPE_CHOICES = (
        ('S', 'Seller'),
        ('B', 'Buyer'),
    )
    contract_file = ContentTypeRestrictedFileField(
        upload_to=contract_file_name,
        content_types=pdf_types,
        max_upload_size=104857600,
        blank=True)
    term = models.ForeignKey('mig_main.AcademicTerm', default=default_term)
    type = models.CharField(max_length=1, choices=TYPE_CHOICES, default='S')

    def __unicode__(self):
        return (self.term.get_abbreviation() + ' ' + self.get_type_display() +
                ' Contract')
예제 #9
0
class CorporateResourceGuide(models.Model):
    """ A Django model for keeping track of the corporate resource guide pdf

    Instances of this class keep track of the currently used, and all previous
    versions, of the corporate resource guide. The active version of this guide
    is used in mass emails, in resume zip files, and in other corporate
    activities.
    """
    active = models.BooleanField(default=False)
    name = models.CharField(max_length=64)
    resource_guide = ContentTypeRestrictedFileField(
        upload_to='corporate_resources',
        content_types=pdf_types,
        max_upload_size=104857600,
        blank=False)

    def __unicode__(self):
        return self.name + (' (active)' if self.active else '')
예제 #10
0
class MeetingMinutes(models.Model):
    pdf_file = ContentTypeRestrictedFileField(
        upload_to='minutes',
        content_types=pdf_types,
        max_upload_size=104857600,
    )
    MEETING_TYPES = [
        ('NI', 'New Initiatives'),
        ('MM', 'Main Meetings'),
        ('OF', 'Officer Meetings'),
        ('AD', 'Advisory Board Meetings'),
    ]
    meeting_type = models.CharField(max_length=2,
                                    choices=MEETING_TYPES,
                                    default='MM')
    semester = models.ForeignKey('mig_main.AcademicTerm')
    meeting_name = models.CharField(max_length=80)

    def __unicode__(self):
        return self.meeting_name + ' minutes.'
예제 #11
0
class ElecteeResource(models.Model):
    """ An electee resource to include in the packet/on the website."""
    resource_type = models.ForeignKey(ElecteeResourceType)
    standing = models.ForeignKey('mig_main.Standing',
                                 default=get_default_standing,
                                 null=True,
                                 blank=True)
    term = models.ForeignKey('mig_main.AcademicTerm')

    resource_file = ContentTypeRestrictedFileField(
        upload_to='electee_resources',
        content_types=pdf_types,
        max_upload_size=104857600,
        blank=False)

    def __unicode__(self):
        if self.standing:
            standing_string = unicode(self.standing) + ' '
        else:
            standing_string = ''
        return (standing_string + unicode(self.resource_type) + ' for ' +
                unicode(self.term))
예제 #12
0
class MemberProfile(UserProfile):

    #Alumni Mail Frequency Options
    ALUM_MAIL_FREQ_CHOICES = (
        ("NO", "None"),
        ("YR", "Yearly"),
        ("SM", "Semesterly"),
        ("MO", "Monthly"),
        ("WK", "Weekly (left on tbp.all)"),
    )

    #Preferred Email address
    MAIL_PREF_CHOICES = (
        ("UM", "Umich email"),
        ("ALT", "Alternate email"),
    )

    #Gender Choices
    GENDER_CHOICES = (
        ("F", "Female"),
        ("M", "Male"),
        ("O", "Other/Prefer not to respond"),
    )

    #Actual Fields
    #Name Stuff

    #Classifications
    major = models.ManyToManyField(Major)

    status = models.ForeignKey(Status, on_delete=models.PROTECT)

    UMID = models.CharField(max_length=8,
                            validators=[
                                RegexValidator(
                                    regex=r'^[0-9]{8}$',
                                    message="Your UMID must be 8 numbers.")
                            ])
    init_chapter = models.ForeignKey(TBPChapter,
                                     on_delete=models.PROTECT,
                                     verbose_name="Initiating Chapter")

    standing = models.ForeignKey(Standing, on_delete=models.PROTECT)

    alt_email = models.EmailField("Alternate email",
                                  max_length=254,
                                  blank=True)

    jobs_email = models.BooleanField("Receive corporate emails?", default=True)

    alum_mail_freq = models.CharField(
        "How frequently would you like alumni emails?",
        max_length=2,
        choices=ALUM_MAIL_FREQ_CHOICES,
        default="WK")
    job_field = models.CharField("What is your job field?",
                                 max_length=50,
                                 blank=True)  #Only for alums

    employer = models.CharField("Your employer", max_length=60,
                                blank=True)  #Only for alums
    preferred_email = models.CharField(max_length=3,
                                       choices=MAIL_PREF_CHOICES,
                                       default="UM")
    meeting_speak = models.BooleanField(
        "Are you interested in speaking at a meeting?",
        default=False)  #Willingness to speak at a meeting/event

    edu_bckgrd_form = ContentTypeRestrictedFileField(
        upload_to='grad_background_forms',
        content_types=pdf_types,
        max_upload_size=104857600,
        blank=True,
        verbose_name="Educational Background Form (Grad Electees only)",
    )  #File of this, grad electees only
    shirt_size = models.ForeignKey(ShirtSize, on_delete=models.PROTECT)
    short_bio = models.TextField()
    init_term = models.ForeignKey(AcademicTerm,
                                  on_delete=models.PROTECT,
                                  verbose_name="Initiation term")
    gender = models.CharField(max_length=1,
                              choices=GENDER_CHOICES,
                              default="O")
    expect_grad_date = models.DateField("Expected graduation date")
    still_electing = models.BooleanField(default=True)

    #Uncomment this on actual server with Python Image Library installed
    photo = StdImageField(upload_to='member_photos', thumbnail_size=(555, 775))
    resume = ContentTypeRestrictedFileField(upload_to=resume_file_name,
                                            content_types=pdf_types,
                                            max_upload_size=104857600,
                                            blank=True)
    phone = PhoneNumberField()

    #Methods
    def get_num_terms_distinction(self, distinction):
        distinctions = self.distinction_set.filter(
            distinction_type=distinction)
        return distinctions.count()

    def get_email(self):
        if self.preferred_email == "UM" or not self.alt_email:
            return self.uniqname + "@umich.edu"
        else:
            return self.alt_email
예제 #13
0
class MemberProfile(UserProfile):
    """ A profile for a TBP member.

    The basic building block of almost everything on the site. Houses a
    member's information in terms of major, contact info, etc.
    """
    # Preferred Email address
    MAIL_PREF_CHOICES = (
        ("UM", "Umich email"),
        ("ALT", "Alternate email"),
    )

    # Classifications
    major = models.ManyToManyField(Major)
    status = models.ForeignKey(Status, on_delete=models.PROTECT)
    UMID = models.CharField(
            max_length=8,
            validators=[RegexValidator(
                            regex=r'^[0-9]{8}$',
                            message="Your UMID must be 8 numbers."
                        )
                        ]
    )
    init_chapter = models.ForeignKey(
                    TBPChapter,
                    on_delete=models.PROTECT,
                    verbose_name="Initiating Chapter"
    )
    standing = models.ForeignKey(Standing, on_delete=models.PROTECT)
    alt_email = models.EmailField(
                    "Alternate email",
                    max_length=254,
                    blank=True
    )
    jobs_email = models.BooleanField(
                    "Receive corporate emails?",
                    default=True
    )
    alum_mail_freq = models.CharField(
                    "How frequently would you like alumni emails?",
                    max_length=2,
                    choices=ALUM_MAIL_FREQ_CHOICES,
                    default="WK"
    )
    preferred_email = models.CharField(
                            max_length=3,
                            choices=MAIL_PREF_CHOICES,
                            default="UM"
    )
    shirt_size = models.ForeignKey(ShirtSize, on_delete=models.PROTECT)
    short_bio = models.TextField()
    init_term = models.ForeignKey(
                        AcademicTerm,
                        on_delete=models.PROTECT,
                        verbose_name="Initiation term"
    )
    gender = models.CharField(
                        max_length=1,
                        choices=GENDER_CHOICES,
                        default="O"
    )
    pronouns = models.ManyToManyField(Pronoun)
    expect_grad_date = models.DateField("Expected graduation date")
    still_electing = models.BooleanField(default=True)
    photo = StdImageField(
                upload_to='member_photos',
                variations={'thumbnail': (555, 775)}
    )
    resume = ContentTypeRestrictedFileField(
        upload_to=resume_file_name,
        content_types=pdf_types,
        max_upload_size=104857600,
        blank=True
    )
    phone = PhoneNumberField()
    location = LocationField(blank=True)

    # Methods
    @classmethod
    def get_members(cls, include_alums=True):
        query = Q(status__name='Active') | Q(status__name='Electee',
                                             still_electing=True)
        if include_alums:
            output = cls.objects.filter(query)
        else:
            output = cls.objects.filter(query).exclude(standing__name='Alumni')

        return output.order_by('last_name',
                               'first_name',
                               'uniqname')
            

    @classmethod
    def get_actives(cls):
        query = Q(status__name='Active')
        return cls.objects.filter(query).order_by('last_name',
                                                  'first_name',
                                                  'uniqname')

    @classmethod
    def get_electees(cls):
        query = Q(status__name='Electee', still_electing=True)
        return cls.objects.filter(query).order_by('last_name',
                                                  'first_name',
                                                  'uniqname')

    def get_num_terms_distinction(self, distinction):
        distinctions = self.distinction_set.filter(
                            distinction_type=distinction
        )
        return distinctions.count()

    def get_email(self):
        if self.preferred_email == "UM" or not self.alt_email:
            return self.uniqname+"@umich.edu"
        else:
            return self.alt_email

    def save(self, *args, **kwargs):
        super(MemberProfile, self).save(*args, **kwargs)
        cache.delete('active_list_html')

    def delete(self, *args, **kwargs):
        super(MemberProfile, self).delete(*args, **kwargs)
        cache.delete('active_list_html')

    def get_resume_name(self):
        if not self.resume:
            return None
        return slugify(self.last_name +
                       '_' + self.first_name + '_' + self.uniqname) + '.pdf'