✨ [#127] add temporal m2m#140
Conversation
5857381 to
e8bce2c
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #140 +/- ##
==========================================
+ Coverage 89.49% 90.22% +0.73%
==========================================
Files 102 105 +3
Lines 1780 2006 +226
Branches 73 98 +25
==========================================
+ Hits 1593 1810 +217
- Misses 155 161 +6
- Partials 32 35 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d03acc2 to
017449e
Compare
017449e to
763a316
Compare
|
@TimdeBeer1 Can you resolve the conflicts and also fix the code coverage? |
b52f580 to
aa3387d
Compare
aa3387d to
55e004e
Compare
6bf8452 to
7d59a77
Compare
danielmursa-dev
left a comment
There was a problem hiding this comment.
Good, some small things!
| widgets = ( | ||
| AdminDateWidget( | ||
| attrs={ | ||
| "placeholder": "Startdatum", |
There was a problem hiding this comment.
| "placeholder": "Startdatum", | |
| "placeholder": _("Startdatum"), |
| ), | ||
| AdminDateWidget( | ||
| attrs={ | ||
| "placeholder": "Einddatum", |
There was a problem hiding this comment.
| "placeholder": "Einddatum", | |
| "placeholder": _("Einddatum"), |
| class FunctieTeamInlineForm(forms.ModelForm): | ||
| periode = FormDateRangeField( | ||
| widget=DateRangeWidget(), | ||
| label="Periode", |
There was a problem hiding this comment.
| label="Periode", | |
| label=_("Periode"), |
| class FunctieOrganisatorischeEenheidInlineForm(forms.ModelForm): | ||
| periode = FormDateRangeField( | ||
| widget=DateRangeWidget(), | ||
| label="Periode", |
There was a problem hiding this comment.
| label="Periode", | |
| label=_("Periode"), |
| extra = 1 | ||
|
|
||
| def get_formset(self, request, obj=None, **kwargs): | ||
| from openorganisatie.organisatie.admin.forms import FunctieTeamInlineForm |
There was a problem hiding this comment.
I don't know how, but I think is better to not include imports inside the functions, you can move the functie admin stuff here in this file, and keep there only the widget.
If is possible, or try other solutions
| end = period.get("einddatum") | ||
|
|
||
| if not start: | ||
| raise serializers.ValidationError({"teams_input": "Startdatum is verplicht."}) |
There was a problem hiding this comment.
| raise serializers.ValidationError({"teams_input": "Startdatum is verplicht."}) | |
| raise serializers.ValidationError({"teams_input": _("Startdatum is verplicht.")}) |
|
|
||
| if end and start > end: | ||
| raise serializers.ValidationError( | ||
| {"teams_input": "Einddatum moet na startdatum liggen."} |
There was a problem hiding this comment.
| {"teams_input": "Einddatum moet na startdatum liggen."} | |
| {"teams_input": _("Einddatum moet na startdatum liggen.")} |
| from ..models.relaties import FunctieTeam, OrganisatorischeEenheidFunctie | ||
|
|
||
|
|
||
| def build_period_range(period): |
There was a problem hiding this comment.
You can add this in the PeriodField as a validator and make it more generic, I mean the ValidationError message
| if not self.periode: | ||
| raise ValidationError({"periode": "Periode is verplicht."}) | ||
|
|
||
| if not self.periode.lower: | ||
| raise ValidationError({"periode": "Startdatum is verplicht."}) |
There was a problem hiding this comment.
Here you can just remove blank=True, null=True from DateRangeField to require period
| qs = FunctieTeam.objects.filter( | ||
| functie_id=self.functie_id, | ||
| team_id=self.team_id, | ||
| ).exclude(pk=self.pk) | ||
|
|
||
| if qs.filter(periode__overlap=self.periode).exists(): | ||
| raise ValidationError( | ||
| {"periode": "Deze periode overlapt met een bestaande toewijzing."} | ||
| ) |
There was a problem hiding this comment.
Is there a way to replace this with a constraint?
Fixes #127
Changes
[Describe the changes here]