1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00

Compare commits

..

7 Commits

Author SHA1 Message Date
Yohann D'ANELLO
f870af139e Typos 2020-08-02 09:51:39 +02:00
Yohann D'ANELLO
7742358b8f Secretaries can view and add memberships 2020-08-02 09:49:45 +02:00
Yohann D'ANELLO
8de7ba14bd Add permission for secretaries 2020-08-02 09:35:32 +02:00
Yohann D'ANELLO
8497dbb25c Club members can see the club 2020-08-02 09:30:18 +02:00
Yohann D'ANELLO
f148c8dacb Better autocomplete field 2020-08-02 09:20:21 +02:00
Yohann D'ANELLO
2f018f8c9d Always query distinct objects 2020-08-02 08:57:16 +02:00
Yohann D'ANELLO
0ae61f3643 BDE memberships can start on 1st august 2020-08-02 08:47:23 +02:00
7 changed files with 104 additions and 15 deletions

View File

@ -131,7 +131,7 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
""" """
We can't display information of a not registered user. We can't display information of a not registered user.
""" """
return super().get_queryset().filter(profile__registration_valid=True).distinct() return super().get_queryset().filter(profile__registration_valid=True)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)

View File

@ -33,7 +33,9 @@ class TransactionCreateView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTabl
extra_context = {"title": _("Transfer money")} extra_context = {"title": _("Transfer money")}
def get_queryset(self, **kwargs): def get_queryset(self, **kwargs):
return super().get_queryset(**kwargs).order_by("-created_at").all()[:20] return Transaction.objects.filter(
PermissionBackend.filter_queryset(self.request.user, Transaction, "view")
).order_by("-created_at").all()[:20]
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
""" """
@ -139,7 +141,9 @@ class ConsoView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
table_class = HistoryTable table_class = HistoryTable
def get_queryset(self, **kwargs): def get_queryset(self, **kwargs):
return super().get_queryset(**kwargs).order_by("-created_at")[:20] return Transaction.objects.filter(
PermissionBackend.filter_queryset(self.request.user, Transaction, "view")
).order_by("-created_at").all()[:20]
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
""" """

View File

@ -68,7 +68,7 @@
"mask": 1, "mask": 1,
"field": "", "field": "",
"permanent": true, "permanent": true,
"description": "Vioir sa propre note d'utilisateur" "description": "Voir sa propre note d'utilisateur"
} }
}, },
{ {
@ -353,7 +353,7 @@
], ],
"query": "{\"pk\": [\"club\", \"pk\"]}", "query": "{\"pk\": [\"club\", \"pk\"]}",
"type": "view", "type": "view",
"mask": 3, "mask": 1,
"field": "", "field": "",
"permanent": false, "permanent": false,
"description": "Voir les informations d'un club" "description": "Voir les informations d'un club"
@ -868,7 +868,7 @@
"mask": 3, "mask": 3,
"field": "", "field": "",
"permanent": false, "permanent": false,
"description": "Modifier n'import quel utilisateur" "description": "Modifier n'importe quel utilisateur"
} }
}, },
{ {
@ -2263,6 +2263,54 @@
"description": "Modifier mes préférences en terme de bus et d'équipe si mon inscription n'est pas validée et que je suis en 2A+" "description": "Modifier mes préférences en terme de bus et d'équipe si mon inscription n'est pas validée et que je suis en 2A+"
} }
}, },
{
"model": "permission.permission",
"pk": 145,
"fields": {
"model": [
"note",
"noteclub"
],
"query": "{}",
"type": "view",
"mask": 1,
"field": "",
"permanent": false,
"description": "Voir toutes les notes de club"
}
},
{
"model": "permission.permission",
"pk": 146,
"fields": {
"model": [
"member",
"membership"
],
"query": "{}",
"type": "view",
"mask": 3,
"field": "",
"permanent": false,
"description": "Voir tous les adhérents du club"
}
},
{
"model": "permission.permission",
"pk": 147,
"fields": {
"model": [
"member",
"membership"
],
"query": "{}",
"type": "add",
"mask": 3,
"field": "",
"permanent": false,
"description": "Ajouter un membre à n'importe quel club"
}
},
{ {
"model": "permission.role", "model": "permission.role",
"pk": 1, "pk": 1,
@ -2282,6 +2330,7 @@
11, 11,
12, 12,
13, 13,
22,
48, 48,
52, 52,
126 126
@ -2306,6 +2355,7 @@
15, 15,
16, 16,
17, 17,
22,
78, 78,
79, 79,
83, 83,
@ -2327,7 +2377,9 @@
"fields": { "fields": {
"for_club": null, "for_club": null,
"name": "Membre de club", "name": "Membre de club",
"permissions": [] "permissions": [
22
]
} }
}, },
{ {
@ -2337,7 +2389,6 @@
"for_club": null, "for_club": null,
"name": "Bureau de club", "name": "Bureau de club",
"permissions": [ "permissions": [
22,
47, 47,
49, 49,
50, 50,
@ -2437,7 +2488,9 @@
137, 137,
138, 138,
139, 139,
143 143,
146,
147
] ]
} }
}, },
@ -2587,7 +2640,10 @@
141, 141,
142, 142,
143, 143,
144 144,
145,
146,
147
] ]
} }
}, },
@ -2757,6 +2813,30 @@
] ]
} }
}, },
{
"model": "permission.role",
"pk": 19,
"fields": {
"for_club": 1,
"name": "Secrétaire BDE",
"permissions": [
54,
55,
56,
57,
58,
135,
136,
137,
138,
139,
140,
145,
146,
147
]
}
},
{ {
"model": "wei.weirole", "model": "wei.weirole",
"pk": 12, "pk": 12,

View File

@ -20,7 +20,7 @@ class ProtectQuerysetMixin:
""" """
def get_queryset(self, **kwargs): def get_queryset(self, **kwargs):
qs = super().get_queryset(**kwargs) qs = super().get_queryset(**kwargs)
return qs.filter(PermissionBackend.filter_queryset(self.request.user, qs.model, "view")) return qs.filter(PermissionBackend.filter_queryset(self.request.user, qs.model, "view")).distinct()
def get_form(self, form_class=None): def get_form(self, form_class=None):
form = super().get_form(form_class) form = super().get_form(form_class)

@ -1 +1 @@
Subproject commit 4b37f8286f493b1a28bd0faa0052ee3967fe543e Subproject commit 1f300c3b7bac0b7a31c1a252a83ba68a8268d33d

View File

@ -18,7 +18,8 @@ $(document).ready(function () {
html += li(prefix + "_" + obj.id, obj[name_field]); html += li(prefix + "_" + obj.id, obj[name_field]);
}); });
$("#" + prefix + "_list").html(html); let results_list = $("#" + prefix + "_list");
results_list.html(html);
objects.results.forEach(function (obj) { objects.results.forEach(function (obj) {
$("#" + prefix + "_" + obj.id).click(function() { $("#" + prefix + "_" + obj.id).click(function() {
@ -32,6 +33,10 @@ $(document).ready(function () {
if (input === obj[name_field]) if (input === obj[name_field])
$("#" + prefix + "_pk").val(obj.id); $("#" + prefix + "_pk").val(obj.id);
}); });
if (results_list.children().length === 1 && e.originalEvent.keyCode >= 32) {
results_list.children().first().trigger("click");
}
}); });
}); });
}); });

View File

@ -86,8 +86,8 @@ function getMatchedNotes(pattern, fun) {
* Generate a <li> entry with a given id and text * Generate a <li> entry with a given id and text
*/ */
function li(id, text, extra_css) { function li(id, text, extra_css) {
return "<li class=\"list-group-item py-1 px-2 d-flex justify-content-between align-items-center text-truncate " + extra_css + "\"" + return "<li class=\"list-group-item py-1 px-2 d-flex justify-content-between align-items-center text-truncate "
" id=\"" + id + "\">" + text + "</li>\n"; + (extra_css ? extra_css : "") + "\"" + " id=\"" + id + "\">" + text + "</li>\n";
} }
/** /**