Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature/OP-515=> QA] Intégration des FIE : partnership côdiplomation #380

Merged
merged 75 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
b420ff0
osis-9265 : partnership model
Jul 11, 2024
bcf93e1
osis-9265 : partnership model
Jul 11, 2024
18ecee3
Merge remote-tracking branch 'origin/feature/OP-515' into feature/OP-515
Jul 11, 2024
1bbdfeb
makemigrations to create migration
Jul 11, 2024
e859b50
osis-9265 : partnership model
Jul 11, 2024
2b9dd68
osis-9265 : partnership model
Jul 12, 2024
eee5b5f
osis-9265 : partnership model
Jul 12, 2024
445af6d
osis-9265 : partnership model
Jul 12, 2024
05a1897
first part of adding field to the form
Jul 12, 2024
4f9bacc
Merge remote-tracking branch 'origin/feature/OP-515' into feature/OP-515
Jul 12, 2024
1fba36a
first part of adding field to the form
Jul 12, 2024
459018d
osis-9265 : partnership form and model
Jul 15, 2024
ab98d8b
osis-9265 : partnership
Jul 16, 2024
b961cf5
osis-9265 : partnership
Jul 16, 2024
151c300
osis-9265 : delete migration
Jul 23, 2024
5777ccd
no dependencies from base
Jul 23, 2024
28fed44
osis-9265 : modification form partnership course
Aug 2, 2024
7e18ca3
osis-9265 : modification form partnership course
Aug 2, 2024
abc28c2
osis-9265 : update template partnership_detail_course
Aug 26, 2024
956c9da
osis-9265 : update template partnership_detail_course
Aug 26, 2024
fbb4b77
osis-9265 : update template partnership_detail_course and form relation
Aug 27, 2024
66b6ad0
osis-9265 : partnership form and template
Sep 5, 2024
2237c35
Merge remote-tracking branch 'origin/dev' into dev
Sep 30, 2024
0bd7f69
Merge branch 'refs/heads/dev' into feature/OP-515
Sep 30, 2024
ca3937c
osis-9265 et OP-515: common fie update
Oct 11, 2024
4caea3a
osis-9265 et OP-515: parntership complement
Oct 11, 2024
a1fff7c
osis-9265 et OP-515: parntership complement
Oct 11, 2024
ecdf2ed
osis-9265 et OP-515: parntership complement
Oct 11, 2024
83d05e8
osis-9265: partnership update forms
Oct 24, 2024
6c21f8a
osis-9265: partnership update template
Oct 25, 2024
4d9ff00
osis-9265: partnership update template and permission
Nov 4, 2024
9e679e6
osis-9265: partnership update template and permission
Nov 4, 2024
18ac3ca
osis-9265: partnership update template and permission
Nov 4, 2024
48b241c
osis-9265: partnership update template and permission
Nov 4, 2024
a39601d
OP-515: Allow SCOPE import for PartnershipEntityManager
albrugnetti Nov 7, 2024
a391809
OP-515: Add missing import Dict
albrugnetti Nov 7, 2024
54c9e45
osis-9265: partnership remove predicates
Nov 8, 2024
8db672f
osis-9265: partnership update translate en-be
Nov 14, 2024
b09cdd6
osis-9265: partnership update translate en-be
Nov 14, 2024
61ea32e
osis-9265: partnership update translate en-be
Nov 14, 2024
d134277
osis-9265: partnership update translate en-be
Nov 14, 2024
fbde9a2
osis-9265: partnership update translate en-be
Nov 26, 2024
f06ff9d
osis-9265: partnership update translate en-be
Nov 27, 2024
c3b7fae
osis-9265: partnership update translate en-be
Nov 27, 2024
a31bdb0
osis-9265: partnership update translate en-be
Nov 27, 2024
6aa3958
osis-9265: partnership update translate en-be
Nov 27, 2024
f934cb0
osis-9265: partnership update translate en-be
Nov 28, 2024
b66c5c2
osis-9265: partnership update template
Nov 28, 2024
a8df345
osis-9265: partnership update template
Nov 28, 2024
3f364d8
osis-9265: partnership update template
Dec 2, 2024
a88b684
osis-9265: partnership update template
Dec 2, 2024
19d59ea
osis-9265: partnership update template
Dec 2, 2024
bce6a57
osis-9265: partnership update template
Dec 4, 2024
ee16b01
osis-9265: partnership update template
Dec 4, 2024
bdbee56
osis-9265: partnership update template
Dec 4, 2024
64dbd31
osis-9265: partnership update template
Dec 4, 2024
de0fe24
osis-9265: partnership update template
Dec 4, 2024
54a07d9
osis-9265: partnership update template
Dec 4, 2024
d8ed0e5
osis-9265: partnership update template
Dec 4, 2024
86e1148
osis-9265: partnership update template
Dec 4, 2024
6106401
osis-9265: partnership update template
Dec 4, 2024
3b6e9fb
osis-9265: partnership review code
Jan 7, 2025
d8cf0b6
osis-9265: partnership review code
Jan 7, 2025
35e88be
osis-9265: partnership review code
Jan 7, 2025
46cd543
osis-9265: partnership review code
Jan 7, 2025
db3cd7f
osis-9265: partnership review code
Jan 9, 2025
cbc88ff
osis-9265: partnership review code
Jan 9, 2025
df17023
osis-9265: partnership review code
Jan 9, 2025
9c71d46
quality checks
Jan 9, 2025
d66464c
osis-9265: partnership review code
Jan 9, 2025
5dfb7e4
osis-9265: partnership review code
Jan 9, 2025
60ab1e4
osis-9265: partnership review code
Jan 9, 2025
10db9c8
osis-9265: partnership review code
Jan 9, 2025
29ff01b
osis-9265: partnership review code
Jan 9, 2025
ce0a99c
osis-9265: partnership review code
Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Dict

from django import forms
from django.contrib import admin
from django.contrib.postgres.fields import ArrayField
Expand Down Expand Up @@ -25,6 +27,11 @@ class PartnershipEntityManagerAdmin(EntityRoleModelAdmin):
ArrayField: {'widget': TypeField(choices=PartnershipType.choices())}
}

def _build_model_from_csv_row(self, csv_row: Dict):
partnership_manager = super()._build_model_from_csv_row(csv_row)
partnership_manager.scopes = csv_row.get('SCOPES', 'ALL').split("|")
return partnership_manager


class PartnershipViewerAdmin(RoleModelAdmin):
raw_id_fields = ('person',)
Expand Down
6 changes: 6 additions & 0 deletions auth/predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def has_mobility_scope(self, user):
for role_row in self.context['role_qs'])


@rules.predicate(bind=True)
def has_course_scope(self, user):
return any(PartnershipType.COURSE.name in role_row.scopes
for role_row in self.context['role_qs'])


@rules.predicate
def partnership_has_agreement(user, partnership):
return partnership.agreements.exists()
6 changes: 3 additions & 3 deletions auth/roles/partnership_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def rule_set(cls):

# UCLManagementEntity
'partnership.view_uclmanagemententity':
(is_linked_to_adri_entity | is_faculty_manager) & has_mobility_scope,
(is_linked_to_adri_entity | is_faculty_manager) & (has_mobility_scope | has_course_scope),
'partnership.add_uclmanagemententity':
is_linked_to_adri_entity & has_mobility_scope,
(is_linked_to_adri_entity) & (has_mobility_scope | has_course_scope),
'partnership.change_uclmanagemententity':
(is_linked_to_adri_entity | is_faculty_manager_for_ume) & has_mobility_scope,
(is_linked_to_adri_entity | is_faculty_manager_for_ume) & (has_mobility_scope | has_course_scope),
'partnership.delete_uclmanagemententity':
(is_linked_to_adri_entity & ~ume_has_partnerships) & has_mobility_scope,

Expand Down
2 changes: 0 additions & 2 deletions forms/partner/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _, pgettext_lazy

from base.forms.utils.datefield import DATE_FORMAT, DatePickerInput
from base.models.enums.organization_type import MAIN
from base.models.organization import Organization
Expand All @@ -12,7 +11,6 @@

__all__ = ['PartnerForm', 'OrganizationForm']


class PartnerForm(forms.ModelForm):
is_nonprofit = forms.NullBooleanField(
label=_('is_nonprofit'),
Expand Down
89 changes: 88 additions & 1 deletion forms/partnership/partnership.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from dal import autocomplete
from dal_select2.widgets import Select2Multiple, Select2, ModelSelect2
from django import forms
from django.core.exceptions import ValidationError
from django.db.models import Func, OuterRef, Q
from django.forms import modelformset_factory
from django.forms.utils import ErrorList
from django.utils.translation import gettext_lazy as _

from base.forms.utils.datefield import DATE_FORMAT, DatePickerInput
Expand All @@ -10,7 +13,8 @@
from base.utils.cte import CTESubquery
from partnership.auth.predicates import is_linked_to_adri_entity
from partnership.auth.roles.partnership_manager import PartnershipEntityManager
from partnership.models import Partnership, EntityProxy
from partnership.models import Partnership, EntityProxy, PartnershipDiplomaWithUCL, PartnershipProductionSupplement, \
PartnershipPartnerRelation
from partnership.utils import format_partner_entity
from ..fields import EntityChoiceField, PersonChoiceField

Expand Down Expand Up @@ -258,11 +262,56 @@ def clean_partner_entities(self):


class PartnershipCourseForm(PartnershipBaseForm):
ucl_reference = forms.ChoiceField(
label=_('ucl_reference'),
required=True,
choices=[(True, _('Oui')), (False, _('Non'))],
)

partner_referent = forms.ModelChoiceField(
label=_('partner_referent'),
required=False,
queryset=EntityProxy.objects.partner_entities(),
widget=autocomplete.ModelSelect2(
url='partnerships:autocomplete:reference_partner_entity',
forward=['partner_entities', 'ucl_reference'],
attrs={"disabled": "disabled"}
),
)

all_student = forms.BooleanField(
label=_('all_student'),
required=False,
initial=True
)

diploma_prod_by_ucl = forms.BooleanField(
label=_('diploma_prod_by_ucl'),
required=False,
initial=True
)

diploma_by_ucl = forms.ChoiceField(
label=_('type_diploma_by_ucl'),
choices=PartnershipDiplomaWithUCL.choices,
)

supplement_prod_by_ucl = forms.ChoiceField(
label=_('supplement_prod_by_ucl'),
choices=PartnershipProductionSupplement.choices(),
)

class Meta(PartnershipBaseForm.Meta):
fields = PartnershipBaseForm.Meta.fields + (
'subtype',
'description',
'project_acronym',
'ucl_reference',
'partner_referent',
'all_student',
'diploma_prod_by_ucl',
'diploma_by_ucl',
'supplement_prod_by_ucl'
)
widgets = {
**PartnershipBaseForm.Meta.widgets,
Expand All @@ -273,6 +322,8 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['subtype'].label = _('partnership_subtype_course')
self.fields['subtype'].label_from_instance = lambda o: o.label
self.fields['supervisor'].required = False
self.fields['diploma_prod_by_ucl'].initial = True


class PartnershipDoctorateForm(PartnershipBaseForm):
Expand Down Expand Up @@ -302,3 +353,39 @@ class Meta(PartnershipWithDatesMixin.Meta):
'project_title',
'ucl_status',
)


class PartnershipPartnerRelationForm(forms.ModelForm):
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList,
label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None):
super().__init__(data, files, auto_id, prefix, initial, error_class, label_suffix, empty_permitted, instance,
use_required_attribute, renderer)

class Meta:
model = PartnershipPartnerRelation
fields = [
'diploma_prod_by_partner',
'diploma_with_ucl_by_partner',
'supplement_prod_by_partner',
'partnership'
]

widgets = {
'supplement_prod_by_partner': ModelSelect2(),
'diploma_with_ucl_by_partner': ModelSelect2(),
'partnership': forms.HiddenInput,
}

labels = {
'diploma_prod_by_partner': _('diploma_prod_by_partner'),
'diploma_with_ucl_by_partner': _('diploma_with_ucl_by_partner'),
'supplement_prod_by_partner': _('supplement_prod_by_partner'),
'partnership': _('partnership'),
}


PartnershipPartnerRelationFormSet = modelformset_factory(
PartnershipPartnerRelation,
form=PartnershipPartnerRelationForm,
extra=0
)
Loading