Skip to content

Commit

Permalink
Merge pull request #77 from nens/reinout-no-mpc-person
Browse files Browse the repository at this point in the history
No mpc on person
  • Loading branch information
reinout authored Dec 17, 2024
2 parents 9fdc0d2 + 0ebeb5a commit 375f176
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 38 deletions.
5 changes: 2 additions & 3 deletions trs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ class PersonAdmin(admin.ModelAdmin):
list_display = [
"name",
"group",
"mpc",
"archived",
"user",
"is_office_management",
"is_management",
]
list_editable = ["group", "mpc", "archived", "is_office_management"]
list_filter = ["archived", "group", "mpc", "is_management", "is_office_management"]
list_editable = ["group", "archived", "is_office_management"]
list_filter = ["archived", "group", "is_management", "is_office_management"]
search_fields = ["name"]


Expand Down
17 changes: 17 additions & 0 deletions trs/migrations/0013_remove_person_mpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.16 on 2024-12-17 13:16

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('trs', '0012_remove_project_is_accepted'),
]

operations = [
migrations.RemoveField(
model_name='person',
name='mpc',
),
]
8 changes: 0 additions & 8 deletions trs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,6 @@ class Person(models.Model):
related_name="persons",
on_delete=models.CASCADE,
)
mpc = models.ForeignKey(
MPC,
blank=True,
null=True,
verbose_name="markt-product-combinatie",
related_name="persons",
on_delete=models.CASCADE,
)
is_office_management = models.BooleanField(
verbose_name="office management",
help_text="Office management can edit and add everything",
Expand Down
6 changes: 0 additions & 6 deletions trs/templates/trs/person.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ <h1>
<td>{{ view.person.group }}</td>
</tr>
{% endif %}
{% if view.person.mpc %}
<tr>
<th>Markt-product-combinatie</th>
<td>{{ view.person.mpc }}</td>
</tr>
{% endif %}
<tr>
<th>Extra rollen</th>
<td>{{ view.extra_roles }}</td>
Expand Down
23 changes: 2 additions & 21 deletions trs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class BaseView(LoginAndPermissionsRequiredMixin, TemplateView, BaseMixin):
class PersonsView(BaseView):

title = "Medewerkers"
normally_visible_filters = ["status", "group", "mpc", "year"]
normally_visible_filters = ["status", "group", "year"]

@cached_property
def results_for_selection_pager(self):
Expand Down Expand Up @@ -402,21 +402,6 @@ def filters_and_choices(self):
]
+ [{"value": "geen", "title": "Zonder groep", "q": Q(group=None)}],
},
{
"title": "MPC",
"param": "mpc",
"default": "all",
"choices": [{"value": "all", "title": "Geen filter", "q": Q()}]
+ [
{
"value": str(mpc.id),
"title": mpc.name,
"q": Q(mpc=mpc.id),
}
for mpc in MPC.objects.all()
]
+ [{"value": "geen", "title": "Zonder MPC", "q": Q(mpc=None)}],
},
{
"title": "Jaar",
"param": "year",
Expand Down Expand Up @@ -1862,7 +1847,7 @@ def form_valid(self, form):
class PersonEditView(LoginAndPermissionsRequiredMixin, UpdateView, BaseMixin):
template_name = "trs/edit.html"
model = Person
fields = ["name", "user", "group", "mpc", "is_management", "archived"]
fields = ["name", "user", "group", "is_management", "archived"]

@cached_property
def person(self):
Expand Down Expand Up @@ -3801,8 +3786,6 @@ def projects(self):
def persons(self):
if self.group:
return Person.objects.filter(group=self.group)
if self.mpc:
return Person.objects.filter(mpc=self.mpc)
return Person.objects.all()

@cached_property
Expand All @@ -3825,8 +3808,6 @@ def _info_from_bookings(self, year):
relevant_persons = Person.objects.filter(id__in=relevant_person_ids)
if self.group:
relevant_persons = relevant_persons.filter(group=self.group)
if self.mpc:
relevant_persons = relevant_persons.filter(mpc=self.mpc)
pycs = [core.get_pyc(person=person, year=year) for person in relevant_persons]
return {
"turnover": sum([pyc.turnover for pyc in pycs]),
Expand Down

0 comments on commit 375f176

Please sign in to comment.