mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 01:12:08 +01:00 
			
		
		
		
	Merge branch 'beta' into 'master'
Ajustement de permissions See merge request bde/nk20!137
This commit is contained in:
		@@ -5,7 +5,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
 | 
				
			|||||||
{% load i18n perms %}
 | 
					{% load i18n perms %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% block content %}
 | 
					{% block content %}
 | 
				
			||||||
{% if "member.change_profile_registration_valid"|has_perm:user %}
 | 
					{% if can_manage_registrations %}
 | 
				
			||||||
<a class="btn btn-block btn-secondary mb-3" href="{% url 'registration:future_user_list' %}">
 | 
					<a class="btn btn-block btn-secondary mb-3" href="{% url 'registration:future_user_list' %}">
 | 
				
			||||||
    <i class="fa fa-user-plus"></i> {% trans "Registrations" %}
 | 
					    <i class="fa fa-user-plus"></i> {% trans "Registrations" %}
 | 
				
			||||||
</a>
 | 
					</a>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -234,6 +234,13 @@ class UserListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return qs
 | 
					        return qs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_context_data(self, **kwargs):
 | 
				
			||||||
 | 
					        context = super().get_context_data(**kwargs)
 | 
				
			||||||
 | 
					        pre_registered_users = User.objects.filter(PermissionBackend.filter_queryset(self.request.user, User, "view"))\
 | 
				
			||||||
 | 
					            .filter(profile__registration_valid=False)
 | 
				
			||||||
 | 
					        context["can_manage_registrations"] = pre_registered_users.exists()
 | 
				
			||||||
 | 
					        return context
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
 | 
					class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
@@ -247,8 +254,8 @@ class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
 | 
				
			|||||||
    def get_context_data(self, **kwargs):
 | 
					    def get_context_data(self, **kwargs):
 | 
				
			||||||
        context = super().get_context_data(**kwargs)
 | 
					        context = super().get_context_data(**kwargs)
 | 
				
			||||||
        note = context['object'].note
 | 
					        note = context['object'].note
 | 
				
			||||||
        context["aliases"] = AliasTable(note.alias_set.filter(PermissionBackend
 | 
					        context["aliases"] = AliasTable(
 | 
				
			||||||
                                                              .filter_queryset(self.request.user, Alias, "view")).all())
 | 
					            note.alias_set.filter(PermissionBackend.filter_queryset(self.request.user, Alias, "view")).distinct().all())
 | 
				
			||||||
        context["can_create"] = PermissionBackend.check_perm(self.request.user, "note.add_alias", Alias(
 | 
					        context["can_create"] = PermissionBackend.check_perm(self.request.user, "note.add_alias", Alias(
 | 
				
			||||||
            note=context["object"].note,
 | 
					            note=context["object"].note,
 | 
				
			||||||
            name="",
 | 
					            name="",
 | 
				
			||||||
@@ -450,8 +457,8 @@ class ClubAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
 | 
				
			|||||||
    def get_context_data(self, **kwargs):
 | 
					    def get_context_data(self, **kwargs):
 | 
				
			||||||
        context = super().get_context_data(**kwargs)
 | 
					        context = super().get_context_data(**kwargs)
 | 
				
			||||||
        note = context['object'].note
 | 
					        note = context['object'].note
 | 
				
			||||||
        context["aliases"] = AliasTable(note.alias_set.filter(PermissionBackend
 | 
					        context["aliases"] = AliasTable(note.alias_set.filter(
 | 
				
			||||||
                                                              .filter_queryset(self.request.user, Alias, "view")).all())
 | 
					            PermissionBackend.filter_queryset(self.request.user, Alias, "view")).distinct().all())
 | 
				
			||||||
        context["can_create"] = PermissionBackend.check_perm(self.request.user, "note.add_alias", Alias(
 | 
					        context["can_create"] = PermissionBackend.check_perm(self.request.user, "note.add_alias", Alias(
 | 
				
			||||||
            note=context["object"].note,
 | 
					            note=context["object"].note,
 | 
				
			||||||
            name="",
 | 
					            name="",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -799,12 +799,12 @@
 | 
				
			|||||||
				"member",
 | 
									"member",
 | 
				
			||||||
				"membership"
 | 
									"membership"
 | 
				
			||||||
			],
 | 
								],
 | 
				
			||||||
			"query": "{\"club\": [\"club\"]}",
 | 
								"query": "{}",
 | 
				
			||||||
			"type": "change",
 | 
								"type": "change",
 | 
				
			||||||
			"mask": 3,
 | 
								"mask": 3,
 | 
				
			||||||
			"field": "roles",
 | 
								"field": "roles",
 | 
				
			||||||
			"permanent": false,
 | 
								"permanent": false,
 | 
				
			||||||
			"description": "Modifier les rôles d'un adhérent d'un club"
 | 
								"description": "Modifier les rôles d'une adhésion"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -2807,6 +2807,38 @@
 | 
				
			|||||||
			"description": "Voir ses propres alias, pour toujours"
 | 
								"description": "Voir ses propres alias, pour toujours"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							"model": "permission.permission",
 | 
				
			||||||
 | 
							"pk": 180,
 | 
				
			||||||
 | 
							"fields": {
 | 
				
			||||||
 | 
								"model": [
 | 
				
			||||||
 | 
									"auth",
 | 
				
			||||||
 | 
									"user"
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"query": "{\"profile__registration_valid\": false}",
 | 
				
			||||||
 | 
								"type": "view",
 | 
				
			||||||
 | 
								"mask": 2,
 | 
				
			||||||
 | 
								"field": "",
 | 
				
			||||||
 | 
								"permanent": false,
 | 
				
			||||||
 | 
								"description": "Voir n'importe quel utilisateur non encore inscrit"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							"model": "permission.permission",
 | 
				
			||||||
 | 
							"pk": 181,
 | 
				
			||||||
 | 
							"fields": {
 | 
				
			||||||
 | 
								"model": [
 | 
				
			||||||
 | 
									"member",
 | 
				
			||||||
 | 
									"profile"
 | 
				
			||||||
 | 
								],
 | 
				
			||||||
 | 
								"query": "{\"registration_valid\": false}",
 | 
				
			||||||
 | 
								"type": "view",
 | 
				
			||||||
 | 
								"mask": 2,
 | 
				
			||||||
 | 
								"field": "",
 | 
				
			||||||
 | 
								"permanent": false,
 | 
				
			||||||
 | 
								"description": "Voir n'importe quel profil non encore inscrit"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		"model": "permission.role",
 | 
							"model": "permission.role",
 | 
				
			||||||
		"pk": 1,
 | 
							"pk": 1,
 | 
				
			||||||
@@ -3402,7 +3434,6 @@
 | 
				
			|||||||
				135,
 | 
									135,
 | 
				
			||||||
				136,
 | 
									136,
 | 
				
			||||||
				137,
 | 
									137,
 | 
				
			||||||
				138,
 | 
					 | 
				
			||||||
				139,
 | 
									139,
 | 
				
			||||||
				140,
 | 
									140,
 | 
				
			||||||
				143,
 | 
									143,
 | 
				
			||||||
@@ -3423,15 +3454,27 @@
 | 
				
			|||||||
			"name": "PC Kfet",
 | 
								"name": "PC Kfet",
 | 
				
			||||||
			"permissions": [
 | 
								"permissions": [
 | 
				
			||||||
				6,
 | 
									6,
 | 
				
			||||||
 | 
									22,
 | 
				
			||||||
				24,
 | 
									24,
 | 
				
			||||||
				25,
 | 
									25,
 | 
				
			||||||
				26,
 | 
									26,
 | 
				
			||||||
				27,
 | 
									27,
 | 
				
			||||||
				30,
 | 
									30,
 | 
				
			||||||
 | 
									49,
 | 
				
			||||||
 | 
									50,
 | 
				
			||||||
 | 
									55,
 | 
				
			||||||
 | 
									56,
 | 
				
			||||||
 | 
									57,
 | 
				
			||||||
 | 
									58,
 | 
				
			||||||
 | 
									143,
 | 
				
			||||||
				150,
 | 
									150,
 | 
				
			||||||
				166,
 | 
									166,
 | 
				
			||||||
				167,
 | 
									167,
 | 
				
			||||||
				168
 | 
									168,
 | 
				
			||||||
 | 
									176,
 | 
				
			||||||
 | 
									177,
 | 
				
			||||||
 | 
									180,
 | 
				
			||||||
 | 
									181
 | 
				
			||||||
			]
 | 
								]
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,8 @@ class TreasuryConfig(AppConfig):
 | 
				
			|||||||
                    source__in=NoteSpecial.objects.filter(~Q(remittancetype=None)),
 | 
					                    source__in=NoteSpecial.objects.filter(~Q(remittancetype=None)),
 | 
				
			||||||
                    specialtransactionproxy=None,
 | 
					                    specialtransactionproxy=None,
 | 
				
			||||||
            ):
 | 
					            ):
 | 
				
			||||||
                SpecialTransactionProxy.objects.create(transaction=transaction, remittance=None)
 | 
					                proxy = SpecialTransactionProxy(transaction=transaction, remittance=None)
 | 
				
			||||||
 | 
					                proxy._force_save = True
 | 
				
			||||||
 | 
					                proxy.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        post_migrate.connect(setup_specialtransactions_proxies, sender=SpecialTransactionProxy)
 | 
					        post_migrate.connect(setup_specialtransactions_proxies, sender=SpecialTransactionProxy)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,9 +10,8 @@ def save_special_transaction(instance, created, **kwargs):
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if not hasattr(instance, "_no_signal"):
 | 
					    if not hasattr(instance, "_no_signal"):
 | 
				
			||||||
        if instance.is_credit():
 | 
					        if created and RemittanceType.objects.filter(
 | 
				
			||||||
            if created and RemittanceType.objects.filter(note=instance.source).exists():
 | 
					                note=instance.source if instance.is_credit() else instance.destination).exists():
 | 
				
			||||||
                SpecialTransactionProxy.objects.create(transaction=instance, remittance=None).save()
 | 
					            proxy = SpecialTransactionProxy(transaction=instance, remittance=None)
 | 
				
			||||||
        else:
 | 
					            proxy._force_save = True
 | 
				
			||||||
            if created and RemittanceType.objects.filter(note=instance.destination).exists():
 | 
					            proxy.save()
 | 
				
			||||||
                SpecialTransactionProxy.objects.create(transaction=instance, remittance=None).save()
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user