Skip to content

✨ [#127] add temporal m2m#140

Open
TimdeBeer1 wants to merge 9 commits into
mainfrom
feature/127-temporal-m2m
Open

✨ [#127] add temporal m2m#140
TimdeBeer1 wants to merge 9 commits into
mainfrom
feature/127-temporal-m2m

Conversation

@TimdeBeer1
Copy link
Copy Markdown
Contributor

Fixes #127

Changes

[Describe the changes here]

@TimdeBeer1 TimdeBeer1 force-pushed the feature/127-temporal-m2m branch 3 times, most recently from 5857381 to e8bce2c Compare April 29, 2026 09:37
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 92.83276% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.22%. Comparing base (f7005ef) to head (6333979).

Files with missing lines Patch % Lines
src/openorganisatie/organisatie/api/validators.py 79.48% 4 Missing and 4 partials ⚠️
src/openorganisatie/organisatie/admin/functie.py 62.50% 6 Missing ⚠️
...rganisatie/organisatie/models/factories/functie.py 87.87% 2 Missing and 2 partials ⚠️
...atie/organisatie/admin/organisatorische_eenheid.py 50.00% 1 Missing ⚠️
src/openorganisatie/organisatie/admin/team.py 75.00% 1 Missing ⚠️
...organisatie/organisatie/api/serializers/functie.py 99.13% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TimdeBeer1 TimdeBeer1 force-pushed the feature/127-temporal-m2m branch 7 times, most recently from d03acc2 to 017449e Compare May 4, 2026 12:48
@TimdeBeer1 TimdeBeer1 marked this pull request as ready for review May 4, 2026 12:54
@TimdeBeer1 TimdeBeer1 force-pushed the feature/127-temporal-m2m branch from 017449e to 763a316 Compare May 4, 2026 13:16
@danielmursa-dev
Copy link
Copy Markdown
Contributor

@TimdeBeer1 Can you resolve the conflicts and also fix the code coverage?

@TimdeBeer1 TimdeBeer1 force-pushed the feature/127-temporal-m2m branch 2 times, most recently from b52f580 to aa3387d Compare May 8, 2026 13:32
@TimdeBeer1 TimdeBeer1 force-pushed the feature/127-temporal-m2m branch from aa3387d to 55e004e Compare May 8, 2026 13:42
@TimdeBeer1 TimdeBeer1 force-pushed the feature/127-temporal-m2m branch from 6bf8452 to 7d59a77 Compare May 8, 2026 14:00
Copy link
Copy Markdown
Contributor

@danielmursa-dev danielmursa-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, some small things!

widgets = (
AdminDateWidget(
attrs={
"placeholder": "Startdatum",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"placeholder": "Startdatum",
"placeholder": _("Startdatum"),

),
AdminDateWidget(
attrs={
"placeholder": "Einddatum",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"placeholder": "Einddatum",
"placeholder": _("Einddatum"),

class FunctieTeamInlineForm(forms.ModelForm):
periode = FormDateRangeField(
widget=DateRangeWidget(),
label="Periode",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label="Periode",
label=_("Periode"),

class FunctieOrganisatorischeEenheidInlineForm(forms.ModelForm):
periode = FormDateRangeField(
widget=DateRangeWidget(),
label="Periode",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label="Periode",
label=_("Periode"),

extra = 1

def get_formset(self, request, obj=None, **kwargs):
from openorganisatie.organisatie.admin.forms import FunctieTeamInlineForm
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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."}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{"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):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add this in the PeriodField as a validator and make it more generic, I mean the ValidationError message

Comment on lines +42 to +46
if not self.periode:
raise ValidationError({"periode": "Periode is verplicht."})

if not self.periode.lower:
raise ValidationError({"periode": "Startdatum is verplicht."})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can just remove blank=True, null=True from DateRangeField to require period

Comment on lines +48 to +56
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."}
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to replace this with a constraint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Temporale ManyToMany fields

3 participants