diff --git a/djangoldp_tzcld/__init__.py b/djangoldp_tzcld/__init__.py index 8fcc0433c12b050c0d1a8aa57351e7aef61c4b46..52d00ad37e6a8bb397a26a2a070ba8691c4e6995 100644 --- a/djangoldp_tzcld/__init__.py +++ b/djangoldp_tzcld/__init__.py @@ -1,2 +1,6 @@ +from django.db.models import options + __version__ = '0.0.0' name = "djangoldp_tzcld" + +options.DEFAULT_NAMES += ('community_path',) \ No newline at end of file diff --git a/djangoldp_tzcld/locale/fr/LC_MESSAGES/django.po b/djangoldp_tzcld/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 0000000000000000000000000000000000000000..11792bd3ba8d9f8d98ffdfdcbdf7b90db59f7dc0 --- /dev/null +++ b/djangoldp_tzcld/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,53 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-04-19 21:34+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: models.py:206 +msgid "Auteur inconnu" +msgstr "Auteur inconnu" + +#: models.py:263 +msgid "Quelqu'un" +msgstr "Quelqu'un" + +#: models.py:275 +msgid "le chat" +msgstr "le chat" + +#: models.py:278 +msgid "t'a envoyé un message privé" +msgstr "vous a envoyé un message privé" + +#: models.py:280 +msgid "t'a mentionné sur " +msgstr "vous a mentionné sur " + +#: models.py:295 +#, fuzzy +#| msgid "t'a mentionné sur " +msgid "Notification sur " +msgstr "vous a mentionné sur " + +#: templates/email.html:8 +msgid "de" +msgstr "de" + +#: templates/email.html:15 +msgid "Ne réponds pas directement à cet e-mail, à la place rends-toi sur" +msgstr "Ne répondez pas directement à cet e-mail, à la place rends-toi sur" diff --git a/djangoldp_tzcld/migrations/0069_alter_tzcldcommunity_membership_and_more.py b/djangoldp_tzcld/migrations/0069_alter_tzcldcommunity_membership_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..e0af1a68cdfc5b6c17b66a0e17463982e145d4a2 --- /dev/null +++ b/djangoldp_tzcld/migrations/0069_alter_tzcldcommunity_membership_and_more.py @@ -0,0 +1,31 @@ +# Generated by Django 4.2.8 on 2024-01-31 17:13 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('djangoldp_tzcld', '0068_tzcldcommunity_primary_contact'), + ] + + operations = [ + migrations.AlterField( + model_name='tzcldcommunity', + name='membership', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='community', to='djangoldp_tzcld.tzcldprofilesmembership'), + ), + migrations.AlterField( + model_name='tzcldterritoryprojectteammember', + name='community_identity', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='territories_project_team_members', to='djangoldp_tzcld.tzcldcommunityidentity'), + ), + migrations.AlterField( + model_name='tzcldterritoryregion', + name='referents', + field=models.ManyToManyField(blank=True, related_name='regions', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/djangoldp_tzcld/models.py b/djangoldp_tzcld/models.py index a8b1d3d04d5c272a1c4f49a52e6846efc385f796..c5a43318708d87ee3bc6b168734292540369baf6 100644 --- a/djangoldp_tzcld/models.py +++ b/djangoldp_tzcld/models.py @@ -8,13 +8,14 @@ from django.utils.translation import gettext_lazy as _ from djangoldp.models import Model from djangoldp_conversation.models import Conversation, Message from djangoldp_community.models import Community, CommunityMember -from djangoldp.permissions import LDPBasePermission - +from djangoldp.permissions import LDPBasePermission, ReadOnly, ReadAndCreate, OwnerPermissions, InheritPermissions +from djangoldp_tzcld.permissions import RegionalReferentPermissions Community._meta.nested_fields += ['tzcld_community_requests', 'community_answer', 'tzcld_community_followed_answer'] +Community._meta.permission_classes = [AnonymousReadOnly, ReadAndCreate|ACLPermissions|RegionalReferentPermissions] ############################# -# Extend user model +# Page Etat d'avancement => Carte d’identité du territoire => Députés => Circonscription ############################# class TzcldTerritoryCirconscription(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -29,18 +30,22 @@ class TzcldTerritoryCirconscription(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Circonscription') verbose_name_plural = _("TZCLD Options Circonscriptions") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit', 'add', 'change', 'delete'] - # superuser_perms = ['inherit', 'change', 'delete'] + container_path = "tzcld-circonscriptions/" serializer_fields = ['@id', 'name', 'order'] ordering = ['order'] nested_fields = [] rdf_type = "tzcld:circonscriptions" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|InheritPermissions] + inherit_permissions = ['territories_deputies_circonscriptions'] +############################# +# Page d'edition du territoire => Départements +# Page Etat d'avancement => Carte d’identité du territoire => Sénateurs => Département +# Page d'edition de l'utilisateur => Départements +# Page d'edition de l'utilisateur => Postes => Département +############################# class TzcldTerritoryDepartment(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -53,20 +58,23 @@ class TzcldTerritoryDepartment(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Department') verbose_name_plural = _("TZCLD Options Departments") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit', 'add', 'change', 'delete'] - # superuser_perms = ['inherit', 'change', 'delete'] + container_path = "tzcld-departments/" serializer_fields = ['@id', 'name', 'job_department'] ordering = ['name'] nested_fields = [] rdf_type = "tzcld:departments" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|InheritPermissions] + inherit_permissions = ['territories_senators_departments', 'community_departments', 'job_department', 'profile_department'] + +############################# +# Page d'edition du territoire => Régions +# Page d'edition de l'utilisateur => Régions +############################# class TzcldTerritoryRegion(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') - referents = models.ManyToManyField(get_user_model(), related_name='regional_referents', blank=True) + referents = models.ManyToManyField(get_user_model(), related_name='regions', blank=True) def __str__(self): try: @@ -77,17 +85,18 @@ class TzcldTerritoryRegion(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Région') verbose_name_plural = _("TZCLD Régions") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit', 'add', 'change', 'delete'] - # superuser_perms = ['inherit', 'change', 'delete'] + container_path = "tzcld-regions/" serializer_fields = ['@id', 'name', 'referents'] ordering = ['name'] nested_fields = ['referents'] rdf_type = "tzcld:regions" - permission_classes=[LDPBasePermission] + permission_classes=[ReadAndCreate|InheritPermissions] + inherit_permissions = ['community_regions', 'profile_regions'] +############################# +# Page d'edition du territoire => Type d'organisation +############################# class TzcldProfilesMembership(Model): name = models.CharField(max_length=255, blank=False, null=True, default='') @@ -100,25 +109,20 @@ class TzcldProfilesMembership(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Membership type') verbose_name_plural = _("TZCLD Options Membership types") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit', 'change', 'delete'] + container_path = "tzcld-profile-membership/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:profileMembership" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions] + inherit_permissions = ['community'] -# DjangoLDP User Extension +############################# +# Page d'edition de l'utilisateur => Etant le modèle User +############################# class TzcldProfile(Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="tzcld_profile") - #description = models.CharField(max_length=255, blank=True, null=True, default='') - #postal_code = models.CharField(max_length=255, blank=True, null=True, default='') - #address = models.CharField(max_length=255, blank=True, null=True, default='') - #phone = models.CharField(max_length=255, blank=True, null=True, default='') - #position = models.CharField(max_length=255, blank=True, null=True, default='') last_contribution_year = models.CharField(max_length=255, blank=True, null=True, default='') regions = models.ManyToManyField(TzcldTerritoryRegion, related_name='profile_regions', blank=True) departments = models.ManyToManyField(TzcldTerritoryDepartment, related_name='profile_department', blank=True) @@ -134,18 +138,20 @@ class TzcldProfile(Model): class Meta(Model.Meta): verbose_name = _('TZCLD User Profile') verbose_name_plural = _("TZCLD Users Profiles") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit', 'change', 'delete'] + ordering = ['user'] serializer_fields = ['@id', 'last_contribution_year', 'jobs', 'regions', 'departments', 'is_member', 'is_national_referent'] rdf_type = "tzcld:profile" auto_author = 'user' depth = 1 nested_fields = ['jobs', 'regions', 'departments'] - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|InheritPermissions] + inherit_permissions = ['user'] + +############################# +# Page d'edition de l'utilisateur => Postes +############################# class TzcldProfileJob(Model): position = models.CharField(max_length=255, blank=True, null=True, default='') organisation = models.CharField(max_length=255, blank=True, null=True, default='') @@ -156,7 +162,7 @@ class TzcldProfileJob(Model): #address_public = models.BooleanField(default=False) profile = models.ForeignKey(TzcldProfile, on_delete=models.CASCADE,related_name='jobs', blank=True, null=True) link = models.CharField(max_length=255, blank=True, null=True, default='') - + phone = models.CharField(max_length=255, blank=True, null=True, default='') phone_public = models.BooleanField(default=False) mobile_phone = models.CharField(max_length=255, blank=True, null=True, default='') @@ -173,82 +179,17 @@ class TzcldProfileJob(Model): class Meta(Model.Meta): verbose_name = _('TZCLD User profile job') verbose_name_plural = _("TZCLD Users profiles jobs") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit', 'change', 'delete'] + container_path = "tzcld-profile-job/" serializer_fields = ['@id', 'position', 'organisation', 'address', 'postal_code', 'city', 'department','profile', 'link','phone' ,'phone_public' ,'mobile_phone' ,'mobile_phone_public' ,'email' ,'email_public' ] nested_fields = [] rdf_type = "tzcld:profileJob" - permission_classes=[LDPBasePermission] - -############################# -# Old models version -############################# -""" - -class TzcldProfileEvent(Model): - name = models.CharField(max_length=254, blank=True, null=True, default='') - tzcldprofile = models.ManyToManyField(TzcldProfile, related_name='events', blank=True) - - def __str__(self): - try: - return '{} ({})'.format(self.name, self.urlid) - except: - return self.urlid - - class Meta(Model.Meta): - verbose_name = _('TZCLD Event') - verbose_name_plural = _("TZCLD Events") - container_path = "tzcld-events/" - serializer_fields = ['@id', 'name'] - nested_fields = [] - rdf_type = "tzcld:event" - - -class TzcldProfileOrganisation(Model): - name = models.CharField(max_length=254, blank=True, null=True, default='') - tzcldprofile = models.ManyToManyField(TzcldProfile, related_name='orgs', blank=True) - - def __str__(self): - try: - return '{} ({})'.format(self.name, self.urlid) - except: - return self.urlid - - class Meta(Model.Meta): - verbose_name = _('TZCLD Organisation or Territory') - verbose_name_plural = _("TZCLD Organisations or Territories") - container_path = "tzcld-orgs/" - serializer_fields = ['@id', 'name'] - nested_fields = [] - rdf_type = "tzcld:org" + permission_classes=[ReadOnly|OwnerPermissions] -class TzcldProfileRegion(Model): - name = models.CharField(max_length=254, blank=True, null=True, default='') - tzcldprofile = models.ManyToManyField(TzcldProfile, related_name='regions', blank=True) - - def __str__(self): - try: - return '{} ({})'.format(self.name, self.urlid) - except: - return self.urlid - - class Meta(Model.Meta): - verbose_name = _('TZCLD Region or departement') - verbose_name_plural = _("TZCLD Regions or departements") - container_path = "tzcld-regions/" - serializer_fields = ['@id', 'name'] - nested_fields = [] - rdf_type = "tzcld:regions" -""" - ############################# -# DjangoLDP Community Extension +# Page d'edition du territoire => Etat d'avancement ############################# - class TzcldTerritoriesStepState(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -261,16 +202,17 @@ class TzcldTerritoriesStepState(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory step state') verbose_name_plural = _("TZCLD Options Territories step states") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit'] - # superuser_perms = ['inherit'] + container_path = "tzcld-territories-step-states/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:territoryStepState" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|InheritPermissions] + inherit_permissions = ['step_state'] +############################# +# Page d'edition du territoire => Type de territoire +############################# class TzcldTerritoriesKind(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -283,16 +225,17 @@ class TzcldTerritoriesKind(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory Kind') verbose_name_plural = _("TZCLD Options Territories Kind") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit'] - # superuser_perms = ['inherit'] + container_path = "tzcld-kinds/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:territoryKind" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|InheritPermissions] + inherit_permissions = ['kind'] +############################# +# Page Etat d'avancement => Carte d’identité du territoire => Origine de la mobilisation +############################# class TzcldTerritoriesOriginMobilization(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -305,17 +248,17 @@ class TzcldTerritoriesOriginMobilization(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Origin Mobilization') verbose_name_plural = _("TZCLD Options Origins Mobilization") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit'] - # superuser_perms = ['inherit'] + container_path = "tzcld-origins-mobilization/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:territoryOriginMobilization" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly] +############################# +# Page Etat d'avancement => Carte d’identité du territoire => Participation aux formations TZCLD => Formation suivie +############################# class TzcldTerritoriesTrainingCourse(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -328,16 +271,17 @@ class TzcldTerritoriesTrainingCourse(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Training Course') verbose_name_plural = _("TZCLD Options Training Courses") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit'] - # superuser_perms = ['inherit'] + container_path = "tzcld-training-courses/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:territoryTrainingCourse" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|InheritPermissions] + inherit_permissions = ['territory_training_course'] +############################# +# Page Etat d'avancement => Carte d’identité du territoire => Participation aux formations TZCLD => Numéro de promotion +############################# class TzcldTerritoriesTrainingPromotion(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -350,16 +294,17 @@ class TzcldTerritoriesTrainingPromotion(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Training Promotion') verbose_name_plural = _("TZCLD Options Training Promotions") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit'] - # superuser_perms = ['inherit'] + container_path = "tzcld-training-promotions/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:territoryTrainingPromotion" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|InheritPermissions] + inherit_permissions = ['territory_training_promotion'] +############################# +# Page Etat d'avancement => Carte d’identité du territoire => Equipe projet => Statut de la personne +############################# class TzcldTerritoriesTeamUserState(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') order = models.IntegerField(blank=True, null=True, default=1) @@ -373,25 +318,26 @@ class TzcldTerritoriesTeamUserState(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Team User State') verbose_name_plural = _("TZCLD Options Team User States") - - # authenticated_perms = ['view'] - # owner_perms = ['inherit'] - # superuser_perms = ['inherit'] + ordering = ['order'] container_path = "tzcld-team-user-states/" serializer_fields = ['@id', 'name', 'order'] - permission_classes=[LDPBasePermission] nested_fields = [] rdf_type = "tzcld:territoryTeamUserState" + permission_classes=[ReadOnly|InheritPermissions] + inherit_permissions = ['team_member_state'] +############################# +# Page d'edition du territoire => Etant le modèle Community +############################# class TzcldCommunity(Model): community = models.OneToOneField(Community, on_delete=models.CASCADE, related_name='tzcld_profile', null=True, blank=True) kind = models.ForeignKey(TzcldTerritoriesKind, on_delete=models.DO_NOTHING,related_name='kind', blank=True, null=True) step_state = models.ForeignKey(TzcldTerritoriesStepState, on_delete=models.DO_NOTHING,related_name='step_state', blank=False, null=True) regions = models.ManyToManyField(TzcldTerritoryRegion, related_name='community_regions', blank=True) departments = models.ManyToManyField(TzcldTerritoryDepartment, related_name='community_departments', blank=True) - membership = models.ForeignKey(TzcldProfilesMembership, on_delete=models.DO_NOTHING,related_name='membership', blank=False, null=True) + membership = models.ForeignKey(TzcldProfilesMembership, on_delete=models.DO_NOTHING,related_name='community', blank=False, null=True) membership_organisation_name = models.CharField(max_length=254, blank=True, null=True, default='') visible = models.BooleanField(default=True) primary_contact = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='primary_contact', blank=True, null=True, on_delete=models.SET_NULL) @@ -406,18 +352,20 @@ class TzcldCommunity(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory Profile') verbose_name_plural = _("TZCLD Territories Profiles") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + ordering = ['community'] container_path = "tzcld-communities/" serializer_fields = ['@id', 'community', 'kind', 'step_state', 'kind', 'departments', 'regions', 'locations', 'primary_contact', 'membership', 'membership_organisation_name', 'visible', 'information'] rdf_type = "tzcld:communityProfile" nested_fields = ['regions', 'departments', 'locations'] - permission_classes=[LDPBasePermission] - depth = 0 + permission_classes=[InheritPermissions] + inherit_permissions = ['community'] + community_path = 'community' + depth = 1 +############################# +# Page Etat d'avancement => Carte d’identité du territoire +############################# class TzcldCommunityIdentity(Model): community = models.OneToOneField(Community, on_delete=models.CASCADE, related_name='tzcld_profile_identity', null=True, blank=True) origin_mobilization = models.ForeignKey(TzcldTerritoriesOriginMobilization, on_delete=models.DO_NOTHING,related_name='territory_origin_mobilization', blank=True, null=True) @@ -443,22 +391,23 @@ class TzcldCommunityIdentity(Model): verbose_name_plural = _("TZCLD Territories Identities") ordering = ['community'] container_path = "tzcld-communities-identity/" - serializer_fields = ['@id', 'community', 'emergence_date', 'habilitation_date', 'origin_mobilization', 'application_date', 'signatory_structure', 'birth_date', 'last_contribution_date', 'territories_project_team_memebers', 'territories_trainings', 'conversations', 'tzcld_admins_community_shared_notes', 'tzcld_admins_community_shared_files', 'date', 'author', 'territories_political_landscape_deputies', 'territories_political_landscape_senators'] - nested_fields = ['community', 'conversations', 'tzcld_admins_community_shared_notes', 'tzcld_admins_community_shared_files', 'territories_project_team_memebers', 'territories_trainings', 'territories_political_landscape_deputies', 'territories_political_landscape_senators'] + serializer_fields = ['@id', 'community', 'emergence_date', 'habilitation_date', 'origin_mobilization', 'application_date', 'signatory_structure', 'birth_date', 'last_contribution_date', 'territories_project_team_members', 'territories_trainings', 'conversations', 'tzcld_admins_community_shared_notes', 'tzcld_admins_community_shared_files', 'date', 'author', 'territories_political_landscape_deputies', 'territories_political_landscape_senators'] + nested_fields = ['community', 'conversations', 'tzcld_admins_community_shared_notes', 'tzcld_admins_community_shared_files', 'territories_project_team_members', 'territories_trainings', 'territories_political_landscape_deputies', 'territories_political_landscape_senators'] rdf_type = "tzcld:communityIdentity" - permission_classes=[LDPBasePermission] - depth = 0 + permission_classes=[InheritPermissions|RegionalReferentPermissions] + inherit_permissions = ['community'] + community_path = 'community' + depth = 1 +############################# +# Page d'edition du territoire => Coordonnées et lieux (alias EBE) +############################# class TzcldTerritoryLocation(Model): name = models.CharField(max_length=255, blank=True, null=True, default='') address = models.CharField(max_length=255, blank=True, null=True, default='') postal_code = models.CharField(max_length=255, blank=True, null=True, default='') city = models.CharField(max_length=255, blank=True, null=True, default='') - #department = models.ForeignKey(TzcldTerritoryDepartment, on_delete=models.DO_NOTHING,related_name='location_department', blank=True, null=True) - #link = models.CharField(max_length=255, blank=True, null=True, default='') - #twitter_link = models.CharField(max_length=255, blank=True, null=True, default='') - #linkedin_link = models.CharField(max_length=255, blank=True, null=True, default='') community = models.ForeignKey(TzcldCommunity, on_delete=models.CASCADE,related_name='locations', blank=True, null=True) def __str__(self): @@ -470,25 +419,23 @@ class TzcldTerritoryLocation(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory location') verbose_name_plural = _("TZCLD Territories locations") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-territories-location/" serializer_fields = ['@id', 'name', 'address', 'postal_code', 'city', 'phones', 'emails', 'community'] nested_fields = ['emails', 'phones'] rdf_type = "tzcld:territoryLocation" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions] + inherit_permissions = ['community'] +############################# +# Page Etat d'avancement => Carte d’identité du territoire => Equipe projet +############################# class TzcldTerritoryProjectTeamMember(Model): - #firstname = models.CharField(max_length=255, blank=True, null=True, default='') - #name = models.CharField(max_length=255, blank=True, null=True, default='') - user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) user_state = models.ForeignKey(TzcldTerritoriesTeamUserState, on_delete=models.DO_NOTHING,related_name='team_member_state', blank=True, null=True) etp = models.CharField(max_length=255, blank=True, null=True, default='') attachment_structure = models.CharField(max_length=255, blank=True, null=True, default='') - community_identity = models.ForeignKey(TzcldCommunityIdentity, on_delete=models.CASCADE,related_name='territories_project_team_memebers', blank=True, null=True) + community_identity = models.ForeignKey(TzcldCommunityIdentity, on_delete=models.CASCADE,related_name='territories_project_team_members', blank=True, null=True) def __str__(self): try: @@ -499,18 +446,19 @@ class TzcldTerritoryProjectTeamMember(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory Project Team Member') verbose_name_plural = _("TZCLD Territories Project Team Members") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] - container_path = "tzcld-territories-project-team-memeber/" + + container_path = "tzcld-territories-project-team-member/" serializer_fields = ['@id', 'user', 'user_state', 'etp', 'attachment_structure', 'community_identity'] nested_fields = ['community_identity'] rdf_type = "tzcld:territoryProjectTeamMember" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions|RegionalReferentPermissions] + inherit_permissions = ['community_identity'] + community_path = 'community_identity.community' +############################# +# Page Etat d'avancement => Carte d’identité du territoire => Paysage politique / institutionnel : Député-e +############################# class TzcldTerritoryPoliticalLandscapeDeputy(Model): - deputy = models.CharField(max_length=254, blank=True, null=True, default='') circonscription = models.ForeignKey(TzcldTerritoryCirconscription, on_delete=models.DO_NOTHING,related_name='territories_deputies_circonscriptions', blank=True, null=True) community_identity = models.ForeignKey(TzcldCommunityIdentity, on_delete=models.CASCADE,related_name='territories_political_landscape_deputies', blank=True, null=True) @@ -524,18 +472,18 @@ class TzcldTerritoryPoliticalLandscapeDeputy(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory Political Landscape Deputy') verbose_name_plural = _("TZCLD Territories Political Landscape Deputies") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-territories-political-landscape-deputy/" serializer_fields = ['@id', 'deputy', 'circonscription', 'community_identity'] nested_fields = ['community_identity'] rdf_type = "tzcld:territoryPoliticalLandscapeDeputy" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions] + inherit_permissions = ['community_identity'] +############################# +# Page Etat d'avancement => Carte d’identité du territoire => Paysage politique / institutionnel : Sénateur-ice +############################# class TzcldTerritoryPoliticalLandscapeSenator(Model): - senator = models.CharField(max_length=254, blank=True, null=True, default='') circonscription = models.ForeignKey(TzcldTerritoryDepartment, on_delete=models.DO_NOTHING,related_name='territories_senators_departments', blank=True, null=True) community_identity = models.ForeignKey(TzcldCommunityIdentity, on_delete=models.CASCADE,related_name='territories_political_landscape_senators', blank=True, null=True) @@ -549,16 +497,17 @@ class TzcldTerritoryPoliticalLandscapeSenator(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory Political Landscape Senator') verbose_name_plural = _("TZCLD Territories Political Landscape Senators") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-territories-political-landscape-senator/" serializer_fields = ['@id', 'senator', 'circonscription', 'community_identity'] nested_fields = ['community_identity'] rdf_type = "tzcld:territoryPoliticalLandscapeSenator" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions] + inherit_permissions = ['community_identity'] +############################# +# Page Etat d'avancement => Carte d’identité du territoire => Participation aux formations TZCLD +############################# class TzcldTerritoryTraining(Model): training_course = models.ForeignKey(TzcldTerritoriesTrainingCourse, on_delete=models.DO_NOTHING,related_name='territory_training_course', blank=True, null=True) training_promotion = models.ForeignKey(TzcldTerritoriesTrainingPromotion, on_delete=models.DO_NOTHING,related_name='territory_training_promotion', blank=True, null=True) @@ -574,18 +523,18 @@ class TzcldTerritoryTraining(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory Training') verbose_name_plural = _("TZCLD Territories Trainings") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-territories-training/" serializer_fields = ['@id', 'training_course', 'training_promotion', 'training_person', 'community_identity'] nested_fields = ['community_identity'] rdf_type = "tzcld:territoryTraining" - permission_classes=[LDPBasePermission] - + permission_classes=[InheritPermissions] + inherit_permissions = ['community_identity'] +############################# +# Page Etat d'avancement => Auto-evaluation => Parties (pointsParts) => Points => Réponses => valeur de la réponse +############################# class TzcldCommunityDeliberation(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -598,16 +547,16 @@ class TzcldCommunityDeliberation(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory deliberation') verbose_name_plural = _("TZCLD Options Territories deliberations") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-communities-deliberations/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:communityDeliberation" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|OwnerPermissions] +############################# +# Page Etat d'avancement => Auto-evaluation => Parties (pointsParts) => Points => Réponses => valeur de la réponse +############################# class TzcldOtherCommunityDeliberation(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -620,17 +569,17 @@ class TzcldOtherCommunityDeliberation(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Other Territory deliberation') verbose_name_plural = _("TZCLD Options Other Community deliberations") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-others-communities-deliberations/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:otherCommunityDeliberation" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|OwnerPermissions] +############################# +# Page Etat d'avancement => Auto-evaluation => Parties (pointsParts) => Points => Réponses => valeur de la réponse +############################# class TzcldCouncilDepartmentDeliberation(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') @@ -643,16 +592,16 @@ class TzcldCouncilDepartmentDeliberation(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Council department deliberation') verbose_name_plural = _("TZCLD Options Council department deliberations") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-councils-departments-deliberations/" serializer_fields = ['@id', 'name'] nested_fields = [] rdf_type = "tzcld:councilDepartmentDeliberation" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|OwnerPermissions] +############################# +# Page Etat d'avancement => Auto-evaluation => Partie +############################# class TzcldCommunityEvaluationPointPart(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') title = models.CharField(max_length=254, blank=True, null=True, default='') @@ -668,20 +617,19 @@ class TzcldCommunityEvaluationPointPart(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory Evaluation Point Part') verbose_name_plural = _("TZCLD Territories Evaluation Point Parts") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-evaluation-point-parts/" serializer_fields = ['@id', 'name', 'title', 'subtitle', 'order', 'part_points'] ordering = ['order'] nested_fields = ['part_points'] rdf_type = "tzcld:evaluationPointPart" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|OwnerPermissions] depth = 0 +############################# +# Page Etat d'avancement => Auto-evaluation => Parties (pointsParts) => Point +############################# class TzcldCommunityEvaluationPoint(Model): - TYPE_FALSE = 'checkboxe' TYPE_DELIBERATION = 'tzcld-communities-deliberations' TYPE_OTHER_DELIBERATION = 'tzcld-others-communities-deliberations' @@ -713,27 +661,26 @@ class TzcldCommunityEvaluationPoint(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Territory Evaluation Point') verbose_name_plural = _("TZCLD Territories Evaluation Points") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + ordering = ['order'] container_path = "tzcld-communities-evaluation-points/" serializer_fields = ['@id', 'name', 'description', 'order', 'part', 'points', 'fieldType', 'evaluation_point_answer'] rdf_type = "tzcld:communityEvaluationPoint" - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly|OwnerPermissions] depth = 0 +############################# +# Page Etat d'avancement => Auto-evaluation => Parties (pointsParts) => Points => Réponse +############################# class TzcldCommunityEvaluationPointAnswer(Model): - - answer = answer = models.BooleanField(default=False) + answer = models.BooleanField(default=False) answer_community_deliberation = models.ForeignKey(TzcldCommunityDeliberation, on_delete=models.DO_NOTHING,related_name='community_answer', blank=True, null=True) answer_other_community_deliberation = models.ForeignKey(TzcldOtherCommunityDeliberation, on_delete=models.DO_NOTHING,related_name='community_answer', blank=True, null=True) answer_concil_department_deliberation = models.ForeignKey(TzcldCouncilDepartmentDeliberation, on_delete=models.DO_NOTHING,related_name='community_answer', blank=True, null=True) comment = models.TextField(blank=True, null=True) - evaluation_point = models.ForeignKey(TzcldCommunityEvaluationPoint, on_delete=models.CASCADE,related_name='evaluation_point_answer', blank=False, null=True) - community = models.ForeignKey(Community, on_delete=models.DO_NOTHING,related_name='community_answer', blank=False, null=True) + evaluation_point = models.ForeignKey(TzcldCommunityEvaluationPoint, on_delete=models.CASCADE,related_name='evaluation_point_answer', blank=True, null=True) + community = models.ForeignKey(Community, on_delete=models.CASCADE, related_name='community_answer', blank=True, null=True) date = models.DateField(verbose_name="Date", auto_now=True) author = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) @@ -750,8 +697,9 @@ class TzcldCommunityEvaluationPointAnswer(Model): container_path = "tzcld-communities-evaluation-point-answers/" serializer_fields = ['@id', 'answer', 'answer_community_deliberation', 'answer_other_community_deliberation', 'answer_concil_department_deliberation', 'comment', 'evaluation_point', 'community', 'date', 'author'] rdf_type = "tzcld:communityEvaluationPointAnswer" - permission_classes=[LDPBasePermission] - + permission_classes=[InheritPermissions|RegionalReferentPermissions] + inherit_permissions = ['community'] + community_path = 'community' depth = 0 @@ -759,6 +707,9 @@ class TzcldCommunityEvaluationPointAnswer(Model): # Shared models for user and community ############################# +############################# +# Page d'edition du territoire => Coordonnées et lieux => Téléphones +############################# class TzcldContactPhone(Model): phone = models.CharField(max_length=255, blank=True, null=True, default='') phone_type = models.CharField(max_length=255, blank=True, null=True, default='') @@ -776,16 +727,16 @@ class TzcldContactPhone(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Phone') verbose_name_plural = _("TZCLD Phones") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] container_path = "tzcld-contact-phone/" serializer_fields = ['@id', 'phone', 'phone_type', 'phone_public', 'job', 'location'] nested_fields = [] rdf_type = "tzcld:phone" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions] + inherit_permissions = ['job'] +############################# +# Page d'edition du territoire => Coordonnées et lieux => Emails +############################# class TzcldContactEmail(Model): email = models.CharField(max_length=255, blank=True, null=True, default='') email_type = models.CharField(max_length=255, blank=True, null=True, default='') @@ -802,23 +753,24 @@ class TzcldContactEmail(Model): class Meta(Model.Meta): verbose_name = _('TZCLD Email') verbose_name_plural = _("TZCLD Emails") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-contact-email/" serializer_fields = ['@id', 'email', 'email_type', 'email_public', 'job', 'location'] nested_fields = [] rdf_type = "tzcld:email" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions] + inherit_permissions = ['job'] +############################# +# Page Suivi du territoire => Historique des échanges +############################# class TzcldTerritoryRequest(Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL,verbose_name="Interlocuteur") date = models.DateField(verbose_name="Date") contactType = models.CharField(max_length=1024, blank=True, null=True, default='',verbose_name="Type of contact") subject = models.TextField(blank=True, null=True, verbose_name="Sujet/Demande") - community = models.ForeignKey(Community, on_delete=models.DO_NOTHING,related_name='tzcld_community_requests', blank=False, null=True) + community = models.ForeignKey(Community, on_delete=models.CASCADE,related_name='tzcld_community_requests', blank=False, null=True) author = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL,related_name='territory_request_author') def __str__(self): @@ -831,25 +783,23 @@ class TzcldTerritoryRequest(Model): auto_author = 'author' verbose_name = _('TZCLD Territory Request') verbose_name_plural = _("TZCLD Territories Requests") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-territory-request/" serializer_fields = ['@id', 'user', 'date', 'contactType', 'subject', 'community', 'author'] nested_fields = ['user', 'community'] rdf_type = "tzcld:territoryRequest" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions] + inherit_permissions = ['community'] +############################# +# Page Suivi du territoire => Synthèse +############################# class TzcldTerritorySynthesisFollowed(Model): - - # context = models.TextField(blank=True, null=True, verbose_name="Context") - # strongPoints = models.TextField(blank=True, null=True, verbose_name="Strong Points") questions = models.TextField(blank=True, null=True, verbose_name="Questions") needs = models.TextField(blank=True, null=True, verbose_name="Needs, Actions") targetdate = models.DateField(verbose_name="Target date", blank=True, null=True) - community = models.OneToOneField(Community, on_delete=models.DO_NOTHING,related_name='tzcld_community_synthesis_followed', blank=False, null=True) + community = models.OneToOneField(Community, on_delete=models.CASCADE,related_name='tzcld_community_synthesis_followed', blank=True, null=True) date = models.DateField(verbose_name="Date", auto_now=True) author = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) @@ -863,17 +813,17 @@ class TzcldTerritorySynthesisFollowed(Model): auto_author = 'author' verbose_name = _('TZCLD Territory Synthesis Followed') verbose_name_plural = _("TZCLD Territories Synthesis Followed") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-territory-synthesis-followed/" serializer_fields = ['@id', 'questions', 'needs', 'targetdate', 'community', 'tzcld_referents_community_shared_notes', 'date', 'author', 'tzcld_referents_community_shared_files'] nested_fields = ['community', 'tzcld_referents_community_shared_notes', 'tzcld_referents_community_shared_files'] rdf_type = "tzcld:territorySynthesisFollowed" - permission_classes=[LDPBasePermission] - + permission_classes=[RegionalReferentPermissions] + community_path = 'community' +############################# +# Page Suivi du territoire => Critères de suiv => Partie +############################# class TzcldCommunityFollowedPointPart(Model): name = models.CharField(max_length=254, blank=True, null=True, default='') title = models.CharField(max_length=254, blank=True, null=True, default='') @@ -898,8 +848,11 @@ class TzcldCommunityFollowedPointPart(Model): nested_fields = ['followed_part_points'] rdf_type = "tzcld:followedPointPart" depth = 0 - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly] +############################# +# Page Suivi du territoire => Critères de suiv => Parties (pointsParts) => Point +############################# class TzcldCommunityFollowedPoint(Model): TYPE_TEXT = 'text' @@ -933,14 +886,16 @@ class TzcldCommunityFollowedPoint(Model): serializer_fields = ['@id', 'name', 'order', 'part', 'fieldType', 'helpComment'] rdf_type = "tzcld:communityFollowedPoint" depth = 0 - permission_classes=[LDPBasePermission] + permission_classes=[ReadOnly] +############################# +# Page Suivi du territoire => Critères de suiv => Parties (pointsParts) => Points => Répnse +############################# class TzcldCommunityFollowedPointAnswer(Model): - answer = models.TextField(blank=False, null=True) followed_point = models.ForeignKey(TzcldCommunityFollowedPoint, on_delete=models.CASCADE,related_name='followed_point_answer', blank=False, null=True) - community = models.ForeignKey(Community, on_delete=models.DO_NOTHING,related_name='tzcld_community_followed_answer', blank=False, null=True) + community = models.ForeignKey(Community, on_delete=models.CASCADE,related_name='tzcld_community_followed_answer', blank=False, null=True) date = models.DateField(verbose_name="Date", auto_now=True) author = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) @@ -958,11 +913,14 @@ class TzcldCommunityFollowedPointAnswer(Model): serializer_fields = ['@id', 'answer', 'followed_point','community', 'date', 'author'] rdf_type = "tzcld:communityFollowedPointAnswer" depth = 0 - permission_classes=[LDPBasePermission] - + permission_classes=[RegionalReferentPermissions] + community_path = 'community' +############################# +# Page Échanges avec mes référent-es => Notes partagées (via relation community_admins) +# Page Suivi du territoire => Notes partagées (via relation community_referents) +############################# class TzcldTerritorySharedNote(Model): - author = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) longdesc = models.TextField(blank=True, null=True) community_admins = models.ForeignKey(TzcldCommunityIdentity, on_delete=models.DO_NOTHING,related_name='tzcld_admins_community_shared_notes', blank=True, null=True) @@ -985,9 +943,15 @@ class TzcldTerritorySharedNote(Model): serializer_fields = ['@id', 'author', 'longdesc', 'community_admins', 'community_referents', 'conversations', 'date'] nested_fields = ['author', 'community_admins', 'community_referents', 'conversations'] rdf_type = "tzcld:territorySharedNote" - permission_classes=[LDPBasePermission] - + permission_classes=[InheritPermissions|RegionalReferentPermissions] + inherit_permissions = ['community_admins', 'community_referents'] + community_path = 'community_admins.community' + +############################# +# Page Échanges avec mes référent-es => Fichiers de suivi (via relation community_admins) +# Page Échanges avec mes référent-es => Partagés avec la grappe (via relation community_referents) +############################# class TzcldTerritorySharedFile(Model): author = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL,verbose_name="Interlocuteur") name = models.CharField(max_length=1024, blank=True, null=True, default='') @@ -1006,15 +970,14 @@ class TzcldTerritorySharedFile(Model): auto_author = 'author' verbose_name = _('TZCLD Territory Shared File') verbose_name_plural = _("TZCLD Territories Shared Files") - - # authenticated_perms = ['view', 'add'] - # owner_perms = ['inherit', 'change', 'delete'] - # superuser_perms = ['inherit'] + container_path = "tzcld-territory-shared-files/" serializer_fields = ['@id', 'author', 'name', 'date', 'document', 'community_admins', 'community_referents'] nested_fields = ['author', 'community_admins', 'community_referents'] rdf_type = "tzcld:territorySharedFile" - permission_classes=[LDPBasePermission] + permission_classes=[InheritPermissions|RegionalReferentPermissions] + inherit_permissions = ['community_admins', 'community_referents'] + community_path = 'community_admins.community' ############################# diff --git a/djangoldp_tzcld/permissions.py b/djangoldp_tzcld/permissions.py new file mode 100644 index 0000000000000000000000000000000000000000..e9fa97f5e4ea2ab23207c2fb365b4f7db0d5404c --- /dev/null +++ b/djangoldp_tzcld/permissions.py @@ -0,0 +1,25 @@ +from djangoldp.permissions import LDPBasePermission +import logging + +logger = logging.getLogger(__name__) + +class RegionalReferentPermissions(LDPBasePermission): + permissions = {'view', 'add', 'change', 'control'} + """Gives write permissions to regional referents and read permissions to everyone""" + def check_permission(self, user, model, obj): + assert getattr(model.meta, 'community_path', False), f'Community path not defined for model {model.name_}' + + # We need to loop through the object class meta path provided + for field in model._meta.community_path.split('.'): + obj = getattr(obj, field) + + regions = set(getattr(user, regions, TzcldTerritoryRegion.objects.none()).all()) + return bool(regions.intersection(set(obj.tzcld_profile.regions.all()))) + + def has_object_permission(self, request, view, obj=None): + return self.check_permission(request.user, view.model, obj) + + def get_permissions(self, user, model, obj=None): + if not obj or self.check_permission(user, model, obj): + return self.permissions + return set() diff --git a/djangoldp_tzcld/templates/base_email.html b/djangoldp_tzcld/templates/base_email.html new file mode 100644 index 0000000000000000000000000000000000000000..d94e314e87d53ee261fa56f64fc1cd89fd972ea7 --- /dev/null +++ b/djangoldp_tzcld/templates/base_email.html @@ -0,0 +1,114 @@ +{% load i18n %} +{% load orbit %} +{% load static %} +{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} +<!DOCTYPE html> +<html lang="{{ LANGUAGE_CODE|default:"en-us" }}"{% if LANGUAGE_BIDI %} dir="rtl"{% endif %}> + <head> + <meta charset="UTF-8" /> + <title>{% orbit 'client.name' %} - {% block title %}{% endblock %}</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta http-equiv="X-UA-Compatible" content="ie=edge" /> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <style> + @media only screen and (max-width: 620px) { + table.body h1 { + font-size: 28px !important; + margin-bottom: 10px !important; + } + table.body p, + table.body ul, + table.body ol, + table.body td, + table.body span, + table.body a { + font-size: 16px !important; + } + table.body .wrapper { + padding: 10px !important; + } + table.body .content { + padding: 0 !important; + } + table.body .container { + padding: 0 !important; + width: 100% !important; + } + table.body .main { + border-left-width: 0 !important; + border-radius: 0 !important; + border-right-width: 0 !important; + } + table.body .btn table { + width: 100% !important; + } + table.body .btn a { + width: 100% !important; + } + table.body .img-responsive { + height: auto !important; + max-width: 100% !important; + width: auto !important; + } + } + @media all { + .btn-primary table td:hover { + background-color: #34495e !important; + } + .btn-primary a:hover { + background-color: #34495e !important; + border-color: #34495e !important; + } + } + </style> + </head> + <body style="background-color: #f6f6f6; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;"> + <table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f6f6f6; width: 100%;" width="100%" bgcolor="#f6f6f6"> + <tr> + <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"> </td> + <td class="container" style="font-family: sans-serif; font-size: 14px; vertical-align: top; display: block; max-width: 580px; padding: 10px; width: 580px; margin: 0 auto;" width="580" valign="top"> + <div class="content" style="box-sizing: border-box; display: block; margin: 0 auto; max-width: 580px; padding: 10px;"> + <table role="presentation" class="main" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background: #ffffff; border-radius: 3px; width: 100%;" width="100%"> + <tr> + <td class="wrapper" style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;" valign="top"> + <table role="presentation" border="0" cellpadding="20" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%"> + <tr> + <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"> + <img class="img-responsive" src="https://cdn.startinblox.com/logos/tzcld-logo.png" alt="{% orbit 'client.name' %}" width="200" border="0" bgcolor="#f6f6f6"> + </td> + </tr> + <tr> + <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"> + {% block content %}{% endblock %} + </td> + </tr> + </table> + </td> + </tr> + </table> + <div class="footer" style="clear: both; margin-top: 10px; text-align: center; width: 100%;"> + <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%"> + <tr> + <td class="content-block" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center"> + <span style="color: #999999; font-size: 12px; text-align: center;">{% orbit "client.name" %}</span> + </td> + </tr> + <tr> + <td class="content-block" style="font-family: sans-serif; vertical-align: top; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center"> + <span style="color: #999999; font-size: 12px; text-align: center;"></span>{% trans "Ne réponds pas directement à cet e-mail, à la place rends-toi sur" %}</span><br><a href='{% orbit "default_client" %}' target='_blank' style="text-decoration: underline; color: #999999; font-size: 12px; text-align: center;">{% orbit "default_client" %}</a>. + </td> + </tr> + <tr> + <td class="content-block" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center"> + {% block unsubscribe %}{% endblock %} + </td> + </tr> + </table> + </div> + </div> + </td> + <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"> </td> + </tr> + </table> + </body> +</html> diff --git a/djangoldp_tzcld/views.py b/djangoldp_tzcld/views.py index 4fa78d73db7277767bb3717d5af96a5a00751ee3..e5a0a654d0f59eefef8078700cf2773fba224145 100644 --- a/djangoldp_tzcld/views.py +++ b/djangoldp_tzcld/views.py @@ -7,7 +7,16 @@ class MyTerritoriesView(LDPViewSet): parent_model = Community def get_queryset(self): user = self.request.user - return super().get_queryset().filter(Q(tzcld_profile__regions__referents=user) | Q(admins__user=user)).distinct() + + if user.is_superuser: + return super().get_queryset() + + return super().get_queryset().filter( + Q(tzcld_profile__regions__referents=user) | + Q(admins__user=user) | + Q(members__user=user) | + Q(tzcld_profile__primary_contact=user) + ).distinct() class MemberOfCommunitiesView(LDPViewSet): model = Community