Exemplo n.º 1
0
class ApplicantStandardCategoryGrade(models.Model):
    """ Grade for a category and result """
    category = models.ForeignKey('standard_test.StandardCategory')
    result = models.ForeignKey(ApplicantStandardTestResult)
    grade = models.DecimalField(max_digits=6, decimal_places=2)
Exemplo n.º 2
0
class Applicant(models.Model, CustomFieldModel):
    fname = models.CharField(max_length=255, verbose_name="First Name")
    mname = models.CharField(max_length=255,
                             verbose_name="Middle Name",
                             blank=True)
    lname = models.CharField(max_length=255, verbose_name="Last Name")
    pic = models.ImageField(upload_to="applicant_pics", blank=True, null=True)
    sex = models.CharField(max_length=1,
                           choices=(('M', 'Male'), ('F', 'Female')),
                           blank=True)
    bday = models.DateField(blank=True,
                            null=True,
                            verbose_name="Birth Date",
                            validators=settings.DATE_VALIDATORS)
    unique_id = models.IntegerField(blank=True, null=True, unique=True)
    street = models.CharField(max_length=150, blank=True)
    city = models.CharField(max_length=360, blank=True)
    state = USStateField(blank=True)
    zip = models.CharField(max_length=10, blank=True)
    #single_parent = models.BooleanField()
    #qualify_for_reduced_lunch = models.BooleanField()
    ssn = models.CharField(max_length=11, blank=True, verbose_name="SSN")
    parent_email = models.EmailField(blank=True, null=True)
    email = models.EmailField(blank=True, null=True)
    notes = models.TextField(blank=True)
    family_preferred_language = models.ForeignKey('sis.LanguageChoice',
                                                  blank=True,
                                                  null=True,
                                                  on_delete=models.SET_NULL,
                                                  default=get_default_language)
    siblings = models.ManyToManyField('sis.Student', blank=True)
    year = models.ForeignKey('sis.GradeLevel',
                             blank=True,
                             null=True,
                             on_delete=models.SET_NULL,
                             help_text="Applying for this grade level",
                             default=get_year)
    school_year = models.ForeignKey('sis.SchoolYear',
                                    blank=True,
                                    null=True,
                                    on_delete=models.SET_NULL,
                                    default=get_school_year)
    parent_guardians = models.ManyToManyField('sis.EmergencyContact',
                                              verbose_name="Student Contact",
                                              blank=True,
                                              null=True)
    ethnicity = models.ForeignKey(
        EthnicityChoice,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    hs_grad_yr = models.IntegerField(blank=True, null=True, max_length=4)
    elem_grad_yr = models.IntegerField(blank=True, null=True, max_length=4)
    present_school = models.ForeignKey(
        FeederSchool,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    present_school_typed = models.CharField(
        max_length=255,
        blank=True,
        help_text=
        "This is intented for applicants apply for the school. Administrators should use the above."
    )
    present_school_type_typed = models.CharField(max_length=255, blank=True)
    religion = models.ForeignKey(
        ReligionChoice,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    place_of_worship = models.ForeignKey(
        PlaceOfWorship,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    follow_up_date = models.DateField(blank=True,
                                      null=True,
                                      validators=settings.DATE_VALIDATORS)
    open_house_attended = models.ManyToManyField(OpenHouse,
                                                 blank=True,
                                                 null=True)
    parent_guardian_first_name = models.CharField(max_length=150, blank=True)
    parent_guardian_last_name = models.CharField(max_length=150, blank=True)
    relationship_to_student = models.CharField(max_length=500, blank=True)
    heard_about_us = models.ForeignKey(
        HeardAboutUsOption,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    from_online_inquiry = models.BooleanField()
    first_contact = models.ForeignKey(
        FirstContactOption,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    borough = models.ForeignKey(
        BoroughOption,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    country_of_birth = models.ForeignKey(
        CountryOption,
        blank=True,
        null=True,
        default=get_default_country,
        on_delete=models.SET_NULL,
    )
    immigration_status = models.ForeignKey(
        ImmigrationOption,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    ready_for_export = models.BooleanField()
    sis_student = models.OneToOneField('sis.Student',
                                       blank=True,
                                       null=True,
                                       related_name="appl_student",
                                       on_delete=models.SET_NULL)

    total_income = models.DecimalField(max_digits=10,
                                       decimal_places=2,
                                       blank=True,
                                       null=True)
    adjusted_available_income = models.DecimalField(max_digits=10,
                                                    decimal_places=2,
                                                    blank=True,
                                                    null=True)
    calculated_payment = models.DecimalField(max_digits=10,
                                             decimal_places=2,
                                             blank=True,
                                             null=True)

    date_added = models.DateField(auto_now_add=True,
                                  blank=True,
                                  null=True,
                                  validators=settings.DATE_VALIDATORS)
    level = models.ForeignKey(AdmissionLevel,
                              blank=True,
                              null=True,
                              on_delete=models.SET_NULL)
    checklist = models.ManyToManyField(AdmissionCheck, blank=True, null=True)
    application_decision = models.ForeignKey(
        ApplicationDecisionOption,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    application_decision_by = models.ForeignKey(
        User,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    withdrawn = models.ForeignKey(
        WithdrawnChoices,
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
    )
    withdrawn_note = models.CharField(max_length=500, blank=True)
    first_to_college = models.BooleanField(blank=True)
    individual_education_plan = models.BooleanField(blank=True)
    lives_with = models.CharField(
        blank=True,
        max_length=50,
        choices=(
            ('Both Parents', 'Both Parents'),
            ('Mother', 'Mother'),
            ('Father', 'Father'),
            ('Guardian(s)', 'Guardian(s)'),
        ),
    )

    class Meta:
        ordering = (
            'lname',
            'fname',
        )

    def __unicode__(self):
        return "%s %s %s" % (self.fname, self.mname, self.lname)

    @property
    def parent_guardian(self):
        """ Compatibility to act like sis.student parent_guardian
        """
        return u"{} {}".format(self.parent_guardian_first_name,
                               self.parent_guardian_last_name)

    def set_cache(self, contact):
        self.parent_guardian_first_name = contact.fname
        self.parent_guardian_last_name = contact.lname
        self.street = contact.street
        self.state = contact.state
        self.zip = contact.zip
        self.city = contact.city
        self.parent_email = contact.email
        self.save()

        for contact in self.parent_guardians.exclude(id=contact.id):
            # There should only be one primary contact!
            if contact.primary_contact:
                contact.primary_contact = False
                contact.save()

    def __set_level(self):
        prev = None
        for level in AdmissionLevel.objects.all():
            checks = level.admissioncheck_set.filter(required=True)
            i = 0
            for check in checks:
                if check in self.checklist.all():
                    i += 1
            if not i >= checks.count():
                break
            prev = level
        self.level = prev

    def save(self, *args, **kwargs):
        if self.id:
            self.__set_level()
        # create contact log entry on application decision
        if self.application_decision and self.id:
            old = Applicant.objects.get(id=self.id)
            if not old.application_decision:
                contact_log = ContactLog(user=self.application_decision_by,
                                         applicant=self,
                                         note="Application Decision: %s" %
                                         (self.application_decision, ))
                contact_log.save()
        super(Applicant, self).save(*args, **kwargs)