Skip to content

Commit

Permalink
Merge pull request #76 from nens/reinout-mpc
Browse files Browse the repository at this point in the history
MPC addition
  • Loading branch information
reinout authored Dec 16, 2024
2 parents c28eab9 + 30594c7 commit e3ddb99
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 105 deletions.
15 changes: 11 additions & 4 deletions trs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@ class GroupAdmin(admin.ModelAdmin):
list_display = ["name", "description"]


class MPCAdmin(admin.ModelAdmin):
list_display = ["name", "description"]


class PersonAdmin(admin.ModelAdmin):
list_display = [
"name",
"group",
"mpc",
"archived",
"user",
"is_office_management",
"is_management",
]
list_editable = ["group", "archived", "is_office_management"]
list_filter = ["archived", "group", "is_management", "is_office_management"]
list_editable = ["group", "mpc", "archived", "is_office_management"]
list_filter = ["archived", "group", "mpc", "is_management", "is_office_management"]
search_fields = ["name"]


Expand All @@ -25,13 +30,14 @@ class ProjectAdmin(admin.ModelAdmin):
"code",
"description",
"group",
"mpc",
"wbso_project",
"wbso_percentage",
"internal",
"archived",
]
list_filter = ["internal", "archived", "group", "wbso_project"]
list_editable = ["group", "wbso_project", "wbso_percentage"]
list_filter = ["internal", "archived", "group", "mpc", "wbso_project"]
list_editable = ["group", "mpc", "wbso_project", "wbso_percentage"]
search_fields = ["code", "description"]


Expand Down Expand Up @@ -76,6 +82,7 @@ class ThirdPartyEstimateAdmin(admin.ModelAdmin):


admin.site.register(models.Group, GroupAdmin)
admin.site.register(models.MPC, MPCAdmin)
admin.site.register(models.Person, PersonAdmin)
admin.site.register(models.Project, ProjectAdmin)
admin.site.register(models.WbsoProject, WbsoProjectAdmin)
Expand Down
38 changes: 38 additions & 0 deletions trs/migrations/0010_auto_20241216_1859.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 3.2.16 on 2024-12-16 18:59

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


class Migration(migrations.Migration):

dependencies = [
('trs', '0009_auto_20220708_1535'),
]

operations = [
migrations.CreateModel(
name='MPC',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, verbose_name='naam')),
('description', models.CharField(blank=True, max_length=255, verbose_name='omschrijving')),
('target', models.DecimalField(decimal_places=2, default=0, max_digits=12, verbose_name='omzetdoelstelling')),
],
options={
'verbose_name': 'Markt-product-combinatie',
'verbose_name_plural': 'Markt-product-combinaties',
'ordering': ['name'],
},
),
migrations.AddField(
model_name='person',
name='mpc',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='persons', to='trs.mpc', verbose_name='markt-product-combinatie'),
),
migrations.AddField(
model_name='project',
name='mpc',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='projects', to='trs.mpc', verbose_name='markt-product-combinatie'),
),
]
17 changes: 17 additions & 0 deletions trs/migrations/0011_remove_project_startup_meeting_done.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.16 on 2024-12-16 19:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('trs', '0010_auto_20241216_1859'),
]

operations = [
migrations.RemoveField(
model_name='project',
name='startup_meeting_done',
),
]
17 changes: 17 additions & 0 deletions trs/migrations/0012_remove_project_is_accepted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.16 on 2024-12-16 20:01

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('trs', '0011_remove_project_startup_meeting_done'),
]

operations = [
migrations.RemoveField(
model_name='project',
name='is_accepted',
),
]
49 changes: 38 additions & 11 deletions trs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,28 @@ def __str__(self):
return self.name


class MPC(models.Model):
# The implementation is the same as for "group".
name = models.CharField(verbose_name="naam", max_length=255)
description = models.CharField(
verbose_name="omschrijving", blank=True, max_length=255
)
target = models.DecimalField(
max_digits=12,
decimal_places=DECIMAL_PLACES,
default=0,
verbose_name="omzetdoelstelling",
)

class Meta:
verbose_name = "Markt-product-combinatie"
verbose_name_plural = "Markt-product-combinaties"
ordering = ["name"]

def __str__(self):
return self.name


class Person(models.Model):
name = models.CharField(verbose_name="naam", max_length=255)
user = models.OneToOneField(
Expand Down Expand Up @@ -155,6 +177,14 @@ 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 Expand Up @@ -498,6 +528,14 @@ class Project(models.Model):
related_name="projects",
on_delete=models.CASCADE,
)
mpc = models.ForeignKey(
MPC,
blank=True,
null=True,
verbose_name="markt-product-combinatie",
related_name="projects",
on_delete=models.CASCADE,
)
wbso_project = models.ForeignKey(
"WbsoProject",
blank=True,
Expand All @@ -512,17 +550,6 @@ class Project(models.Model):
verbose_name="WBSO percentage",
help_text="Percentage dat meetelt voor de WBSO (0-100)",
)
is_accepted = models.BooleanField(
verbose_name="goedgekeurd",
help_text=(
"Project is goedgekeurd door de PM en kan qua begroting "
+ "niet meer gewijzigd worden."
),
default=False,
)
startup_meeting_done = models.BooleanField(
verbose_name="startoverleg heeft plaatsgevonden", default=False
)
is_subsidized = models.BooleanField(
verbose_name="subsidieproject",
help_text=(
Expand Down
5 changes: 5 additions & 0 deletions trs/templates/trs/person.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ <h1>
<th>Groep</th>
<td>{{ view.person.group }}</td>
</tr>
{% if view.person.mpc %}
<tr>
<th>Markt-product-combinatie</th>
<td>{{ view.person.mpc }}</td>
</tr>
{% endif %}
<tr>
<th>Extra rollen</th>
Expand Down
41 changes: 6 additions & 35 deletions trs/templates/trs/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ <h1>
<td>{{ view.project.group }}</td>
</tr>
{% endif %}
{% if view.project.mpc %}
<tr>
<th>Markt-product-combinatie</th>
<td>{{ view.project.mpc }}</td>
</tr>
{% endif %}
<tr>
<th>Startweek</th>
<td>{{ view.project.start.friendly|default:"Niet ingevuld" }}</td>
Expand All @@ -112,28 +118,6 @@ <h1>
<th>Laatste week</th>
<td>{{ view.project.end.friendly|default:"Niet ingevuld" }}</td>
</tr>
<tr>
<th>Startoverleg</th>
<td>
{% if view.project.startup_meeting_done %}
<span class="glyphicon glyphicon-ok"></span>
Het startoverleg heeft plaatsgevonden
{% else %}
<span class="glyphicon glyphicon-remove"></span>
{% endif %}
</td>
</tr>
<tr>
<th>Goedgekeurd</th>
<td>
{% if view.project.is_accepted %}
<span class="text-success glyphicon glyphicon-ok"></span>
Het project is goedgekeurd door de PM.
{% else %}
<span class="glyphicon glyphicon-remove"></span>
{% endif %}
</td>
</tr>

{% if view.project.rating_projectteam %}
<tr>
Expand Down Expand Up @@ -271,19 +255,6 @@ <h2 id="budget">
{% endif %}
</h2>

{% if view.can_edit_project and view.project.is_accepted %}
<p>
Het project is goedgekeurd, dus de begroting kan niet meer worden
aangepast.
De PM zal het
<a href="{% url 'trs.project.edit' pk=view.project.pk %}#id_is_accepted">
goedkeurings-vinkje
</a>
eerst uit moeten zetten.
</p>
{% endif %}


<div class="table-responsive">
<table class="table table-hover">
<thead>
Expand Down
8 changes: 7 additions & 1 deletion trs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@
views.FinancialExcelView.as_view(),
name="trs.financial.excel",
),
# The next two differentiate in their pk.
re_path(
r"^overviews/financial_excel/(?P<pk>\d+)/$",
r"^overviews/financial_excel/group/(?P<group_pk>\d+)/$",
views.FinancialExcelView.as_view(),
name="trs.financial.excel",
),
re_path(
r"^overviews/financial_excel/mpc/(?P<mpc_pk>\d+)/$",
views.FinancialExcelView.as_view(),
name="trs.financial.excel",
),
Expand Down
Loading

0 comments on commit e3ddb99

Please sign in to comment.