mirror of https://gitlab.crans.org/bde/nk20
🐛 Fix entry page view
This commit is contained in:
parent
4cb162de87
commit
c5f40e0952
|
@ -130,19 +130,11 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
$.post("/api/note/transaction/transaction/", {
|
$.post("/api/note/transaction/transaction/", {
|
||||||
"csrfmiddlewaretoken": CSRF_TOKEN,
|
"csrfmiddlewaretoken": CSRF_TOKEN,
|
||||||
"quantity": 1,
|
"quantity": 1,
|
||||||
"amount": {
|
"amount": {{ activity.activity_type.guest_entry_fee }},
|
||||||
{
|
|
||||||
activity.activity_type.guest_entry_fee
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"reason": "Crédit " + credit_name +
|
"reason": "Crédit " + credit_name +
|
||||||
" (invitation {{ activity.name }})",
|
" (invitation {{ activity.name }})",
|
||||||
"valid": true,
|
"valid": true,
|
||||||
"polymorphic_ctype": {
|
"polymorphic_ctype": {{ notespecial_ctype }},
|
||||||
{
|
|
||||||
notespecial_ctype
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resourcetype": "SpecialTransaction",
|
"resourcetype": "SpecialTransaction",
|
||||||
"source": credit_id,
|
"source": credit_id,
|
||||||
"destination": target.attr('data-inviter'),
|
"destination": target.attr('data-inviter'),
|
||||||
|
|
|
@ -139,6 +139,7 @@ class ActivityInviteView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||||
form = super().get_form(form_class)
|
form = super().get_form(form_class)
|
||||||
form.activity = Activity.objects.filter(PermissionBackend.filter_queryset(self.request.user, Activity, "view"))\
|
form.activity = Activity.objects.filter(PermissionBackend.filter_queryset(self.request.user, Activity, "view"))\
|
||||||
.get(pk=self.kwargs["pk"])
|
.get(pk=self.kwargs["pk"])
|
||||||
|
form.fields["inviter"].initial = self.request.user.note
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
@ -196,7 +197,6 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView):
|
||||||
| Q(inviter__alias__normalized_name__regex=Alias.normalize(pattern))
|
| Q(inviter__alias__normalized_name__regex=Alias.normalize(pattern))
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
pattern = None
|
|
||||||
guest_qs = guest_qs.none()
|
guest_qs = guest_qs.none()
|
||||||
return guest_qs
|
return guest_qs
|
||||||
|
|
||||||
|
@ -224,7 +224,8 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView):
|
||||||
# Filter with permission backend
|
# Filter with permission backend
|
||||||
note_qs = note_qs.filter(PermissionBackend.filter_queryset(self.request.user, Alias, "view"))
|
note_qs = note_qs.filter(PermissionBackend.filter_queryset(self.request.user, Alias, "view"))
|
||||||
|
|
||||||
if pattern:
|
if "search" in self.request.GET and self.request.GET["search"]:
|
||||||
|
pattern = self.request.GET["search"]
|
||||||
note_qs = note_qs.filter(
|
note_qs = note_qs.filter(
|
||||||
Q(note__noteuser__user__first_name__regex=pattern)
|
Q(note__noteuser__user__first_name__regex=pattern)
|
||||||
| Q(note__noteuser__user__last_name__regex=pattern)
|
| Q(note__noteuser__user__last_name__regex=pattern)
|
||||||
|
@ -234,7 +235,7 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView):
|
||||||
else:
|
else:
|
||||||
note_qs = note_qs.none()
|
note_qs = note_qs.none()
|
||||||
|
|
||||||
if settings.DATABASES[note_qs.db]["ENGINE"] == 'django.db.backends.postgresql_psycopg2':
|
if settings.DATABASES[note_qs.db]["ENGINE"] == 'django.db.backends.postgresql':
|
||||||
note_qs = note_qs.distinct('note__pk')[:20]
|
note_qs = note_qs.distinct('note__pk')[:20]
|
||||||
else:
|
else:
|
||||||
# SQLite doesn't support distinct fields. For compatibility reason (in dev mode), the note list will only
|
# SQLite doesn't support distinct fields. For compatibility reason (in dev mode), the note list will only
|
||||||
|
@ -253,13 +254,13 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView):
|
||||||
.distinct().get(pk=self.kwargs["pk"])
|
.distinct().get(pk=self.kwargs["pk"])
|
||||||
context["activity"] = activity
|
context["activity"] = activity
|
||||||
|
|
||||||
matched=[]
|
matched = []
|
||||||
|
|
||||||
for guest in get_invited_guest(self,activity):
|
for guest in self.get_invited_guest(activity):
|
||||||
guest.type = "Invité"
|
guest.type = "Invité"
|
||||||
matched.append(guest)
|
matched.append(guest)
|
||||||
|
|
||||||
for note in get_invited_note(self,activity):
|
for note in self.get_invited_note(activity):
|
||||||
note.type = "Adhérent"
|
note.type = "Adhérent"
|
||||||
note.activity = activity
|
note.activity = activity
|
||||||
matched.append(note)
|
matched.append(note)
|
||||||
|
|
Loading…
Reference in New Issue