Skip to content

Commit

Permalink
Merge pull request #154 from open-austin/add-job-type
Browse files Browse the repository at this point in the history
Add job type
  • Loading branch information
lazarus1331 authored Sep 9, 2020
2 parents b3ffb01 + 48f1454 commit 79c0ecf
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 3 deletions.
33 changes: 32 additions & 1 deletion src/influencetx/finances/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
from django.contrib import admin
from . import models

# Register your models here.

class JobAdmin(admin.ModelAdmin):
list_display = ('employer', 'position', 'held_by', 'financial_disclosure')
readonly_fields = ('legislator', )


admin.site.register(models.Job, JobAdmin)


class JobTypeAdmin(admin.ModelAdmin):
list_display = ('name', "view_jobs_count")

def view_jobs_count(self, obj):
return obj.jobs.count()
view_jobs_count.short_description = "Jobs"


admin.site.register(models.JobType, JobTypeAdmin)


class FinancialDisclosureAdmin(admin.ModelAdmin):
list_display = ("legislator", "year", "elected_officer", "candidate")
readonly_fields = ('legislator', )


admin.site.register(models.FinancialDisclosure, FinancialDisclosureAdmin)


admin.site.register(models.Gift)
admin.site.register(models.Board)
admin.site.register(models.Stock)
26 changes: 26 additions & 0 deletions src/influencetx/finances/migrations/0002_auto_20200829_1856.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 2.2.14 on 2020-08-29 18:56

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('finances', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='JobType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
],
),
migrations.AddField(
model_name='job',
name='job_type',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='finances.JobType'),
),
]
19 changes: 19 additions & 0 deletions src/influencetx/finances/migrations/0003_auto_20200829_2102.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.14 on 2020-08-29 21:02

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('finances', '0002_auto_20200829_1856'),
]

operations = [
migrations.AlterField(
model_name='job',
name='job_type',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='jobs', to='finances.JobType'),
),
]
22 changes: 20 additions & 2 deletions src/influencetx/finances/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FinancialDisclosure(models.Model):
related_name='financial_disclosures')

def __str__(self):
return self.year + " - " + self.elected_officer
return f"{self.elected_officer} - {self.year} - legID:{self.legislator_id}"


class Stock(models.Model):
Expand All @@ -24,6 +24,13 @@ class Stock(models.Model):
on_delete=models.CASCADE,
related_name='stocks')

def __str__(self):
return f"{self.name} - finID:{self.financial_disclosure_id}"


class JobType(models.Model):
name = models.CharField(max_length=100)

def __str__(self):
return self.name

Expand All @@ -36,6 +43,14 @@ class Job(models.Model):
financial_disclosure = models.ForeignKey(FinancialDisclosure,
on_delete=models.CASCADE,
related_name='jobs')
job_type = models.ForeignKey(JobType, on_delete=models.SET_NULL,
blank=True, null=True, related_name='jobs')

def legislator(self):
return self.financial_disclosure.legislator.name

def __str__(self):
return f"{self.employer} - {self.position} - finID:{self.financial_disclosure_id}"


class Board(models.Model):
Expand All @@ -47,6 +62,9 @@ class Board(models.Model):
on_delete=models.CASCADE,
related_name='boards')

def __str__(self):
return f"{self.name} - {self.position} - finID:{self.financial_disclosure_id}"


class Gift(models.Model):
donor = models.CharField(max_length=100)
Expand All @@ -58,4 +76,4 @@ class Gift(models.Model):
related_name='gifts')

def __str__(self):
return self.name
return f"{self.donor} - {self.description} - finID:{self.financial_disclosure_id}"
18 changes: 18 additions & 0 deletions src/influencetx/users/migrations/0004_auto_20200829_1856.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.14 on 2020-08-29 18:56

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('users', '0003_auto_20200826_0033'),
]

operations = [
migrations.AlterField(
model_name='user',
name='last_name',
field=models.CharField(blank=True, max_length=150, verbose_name='last name'),
),
]

0 comments on commit 79c0ecf

Please sign in to comment.