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) 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, related_name="+") 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 intended for applicants to 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(default=False, ) 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(default=False, ) 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(default=False, blank=True) individual_education_plan = models.BooleanField(default=False, 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)
class Migration(migrations.Migration): initial = True dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)] operations = [ migrations.CreateModel( name="Unit", fields=[ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("created_at", models.DateTimeField(auto_now_add=True)), ("modified_at", models.DateTimeField(auto_now=True)), ("deleted_at", models.DateTimeField(default=None, null=True)), ("unit_address_1", models.CharField(max_length=100)), ("unit_address_2", models.CharField(blank=True, max_length=100)), ("unit_city", models.CharField(blank=True, max_length=100)), ("unit_state", localflavor.us.models.USStateField(blank=True, max_length=2)), ("unit_zip_code", localflavor.us.models.USZipCodeField(blank=True, max_length=10)), ("landlord_address_1", models.CharField(blank=True, max_length=100)), ("landlord_address_2", models.CharField(blank=True, max_length=100)), ("landlord_city", models.CharField(blank=True, max_length=100)), ("landlord_state", localflavor.us.models.USStateField(blank=True, max_length=2)), ("landlord_zip_code", localflavor.us.models.USZipCodeField(blank=True, max_length=10)), ( "landlord_phone_number", phonenumber_field.modelfields.PhoneNumberField( blank=True, max_length=128, region=None), ), ("lease_start_date", models.DateField(null=True)), ("lease_end_date", models.DateField(null=True)), ("rent_due_date", models.PositiveIntegerField(null=True)), ("owner", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={"abstract": False}, ), migrations.CreateModel( name="UnitImage", fields=[ ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("created_at", models.DateTimeField(auto_now_add=True)), ("modified_at", models.DateTimeField(auto_now=True)), ("image", models.ImageField(upload_to=units.models.generate_file_path)), ("full_size_height", models.PositiveIntegerField(default=0)), ("full_size_width", models.PositiveIntegerField(default=0)), ( "thumbnail_sizes", django.contrib.postgres.fields.ArrayField( base_field=models.SmallIntegerField(), blank=True, null=True, size=None), ), ("image_type", models.CharField(choices=[("D", "Document"), ("P", "Picture")], default="P", max_length=1)), ("unit", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="units.Unit")), ], options={"abstract": False}, ), ]
class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='BarMembership', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('barMembership', localflavor.us.models.USStateField( max_length=2, verbose_name= 'the two letter state abbreviation of a bar membership', choices=[ ('AL', 'Alabama'), ('AK', 'Alaska'), ('AS', 'American Samoa'), ('AZ', 'Arizona'), ('AR', 'Arkansas'), ('AA', 'Armed Forces Americas'), ('AE', 'Armed Forces Europe'), ('AP', 'Armed Forces Pacific'), ('CA', 'California'), ('CO', 'Colorado'), ('CT', 'Connecticut'), ('DE', 'Delaware'), ('DC', 'District of Columbia'), ('FL', 'Florida'), ('GA', 'Georgia'), ('GU', 'Guam'), ('HI', 'Hawaii'), ('ID', 'Idaho'), ('IL', 'Illinois'), ('IN', 'Indiana'), ('IA', 'Iowa'), ('KS', 'Kansas'), ('KY', 'Kentucky'), ('LA', 'Louisiana'), ('ME', 'Maine'), ('MD', 'Maryland'), ('MA', 'Massachusetts'), ('MI', 'Michigan'), ('MN', 'Minnesota'), ('MS', 'Mississippi'), ('MO', 'Missouri'), ('MT', 'Montana'), ('NE', 'Nebraska'), ('NV', 'Nevada'), ('NH', 'New Hampshire'), ('NJ', 'New Jersey'), ('NM', 'New Mexico'), ('NY', 'New York'), ('NC', 'North Carolina'), ('ND', 'North Dakota'), ('MP', 'Northern Mariana Islands'), ('OH', 'Ohio'), ('OK', 'Oklahoma'), ('OR', 'Oregon'), ('PA', 'Pennsylvania'), ('PR', 'Puerto Rico'), ('RI', 'Rhode Island'), ('SC', 'South Carolina'), ('SD', 'South Dakota'), ('TN', 'Tennessee'), ('TX', 'Texas'), ('UT', 'Utah'), ('VT', 'Vermont'), ('VI', 'Virgin Islands'), ('VA', 'Virginia'), ('WA', 'Washington'), ('WV', 'West Virginia'), ('WI', 'Wisconsin'), ('WY', 'Wyoming') ])), ], options={ 'ordering': ['barMembership'], 'verbose_name': 'bar membership', }, ), migrations.CreateModel( name='UserProfile', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('stub_account', models.BooleanField(default=False)), ('employer', models.CharField(max_length=100, null=True, verbose_name="the user's employer", blank=True)), ('address1', models.CharField(max_length=100, null=True, blank=True)), ('address2', models.CharField(max_length=100, null=True, blank=True)), ('city', models.CharField(max_length=50, null=True, blank=True)), ('state', models.CharField(max_length=2, null=True, blank=True)), ('zip_code', models.CharField(max_length=10, null=True, blank=True)), ('avatar', models.ImageField(upload_to='avatars/%Y/%m/%d', verbose_name="the user's avatar", blank=True)), ('wants_newsletter', models.BooleanField( default=False, verbose_name='This user wants newsletters')), ('plaintext_preferred', models.BooleanField( default=False, verbose_name='should the alert should be sent in plaintext' )), ('activation_key', models.CharField(max_length=40)), ('key_expires', models.DateTimeField( null=True, verbose_name= "The time and date when the user's activation_key expires", blank=True)), ('email_confirmed', models.BooleanField( default=False, verbose_name='The user has confirmed their email address') ), ('barmembership', models.ManyToManyField( to='users.BarMembership', verbose_name='the bar memberships held by the user', blank=True)), ('user', models.OneToOneField( related_name='profile', verbose_name='the user this model extends', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ 'verbose_name': 'user profile', 'verbose_name_plural': 'user profiles', }, ), ]
class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='BarMembership', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('barMembership', localflavor.us.models.USStateField( max_length=2, verbose_name= 'the two letter state abbreviation of a bar membership')), ], options={ 'verbose_name': 'bar membership', 'ordering': ['barMembership'], }, ), migrations.CreateModel( name='UserProfile', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('stub_account', models.BooleanField(default=False)), ('employer', models.CharField(blank=True, help_text="the user's employer", max_length=100, null=True)), ('address1', models.CharField(blank=True, max_length=100, null=True)), ('address2', models.CharField(blank=True, max_length=100, null=True)), ('city', models.CharField(blank=True, max_length=50, null=True)), ('state', models.CharField(blank=True, max_length=2, null=True)), ('zip_code', models.CharField(blank=True, max_length=10, null=True)), ('avatar', models.ImageField(blank=True, help_text="the user's avatar", upload_to='avatars/%Y/%m/%d')), ('wants_newsletter', models.BooleanField(default=False, help_text='This user wants newsletters')), ('unlimited_docket_alerts', models.BooleanField( default=False, help_text='Should the user get unlimited docket alerts?') ), ('plaintext_preferred', models.BooleanField( default=False, help_text='should the alert should be sent in plaintext') ), ('activation_key', models.CharField(max_length=40)), ('key_expires', models.DateTimeField( blank=True, help_text= "The time and date when the user's activation_key expires", null=True)), ('email_confirmed', models.BooleanField( default=False, help_text='The user has confirmed their email address')), ('notes', models.TextField(blank=True, help_text='Any notes about the user.')), ('is_tester', models.BooleanField( default=False, help_text= 'The user tests new features before they are finished')), ('barmembership', models.ManyToManyField( blank=True, to='users.BarMembership', verbose_name='the bar memberships held by the user')), ('user', models.OneToOneField( on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL, verbose_name='the user this model extends')), ], options={ 'verbose_name': 'user profile', 'verbose_name_plural': 'user profiles', }, ), ]