Skip to content
Snippets Groups Projects
Commit 3eb02b14 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Add way to mark registration as payed

parent ec63a455
No related branches found
No related tags found
1 merge request!33Resolve "Mark as payed on registration overview page"
Pipeline #76608 failed
...@@ -253,3 +253,6 @@ rules.add_perm("paweljong.can_retract_registration_rule", can_retract_registrati ...@@ -253,3 +253,6 @@ rules.add_perm("paweljong.can_retract_registration_rule", can_retract_registrati
can_view_terms_predicate = has_person & (is_participant) can_view_terms_predicate = has_person & (is_participant)
rules.add_perm("paweljong.can_view_terms_rule", can_view_terms_predicate) rules.add_perm("paweljong.can_view_terms_rule", can_view_terms_predicate)
can_mark_payment_as_payed_predicate = has_person & (is_organiser)
rules.add_perm("paweljong.mark_payment_payed_rule", can_mark_payment_as_payed_predicate)
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
{% has_perm 'paweljong.delete_registration' user registration as can_delete_registration %} {% has_perm 'paweljong.delete_registration' user registration as can_delete_registration %}
{% has_perm 'paweljong.send_notification_mail' user registration as can_send_notification %} {% has_perm 'paweljong.send_notification_mail' user registration as can_send_notification %}
{% has_perm 'paweljong.can_retract_registration_rule' user registration as can_retract_registration %} {% has_perm 'paweljong.can_retract_registration_rule' user registration as can_retract_registration %}
{% has_perm 'paweljong.mark_payment_payed_rule' user registration as can_mark_registration_payed %}
{% has_perm 'tezor.view_invoice_rule' user registration as can_view_invoice %} {% has_perm 'tezor.view_invoice_rule' user registration as can_view_invoice %}
{% has_perm 'core.edit_person_rule' user person as can_change_person %} {% has_perm 'core.edit_person_rule' user person as can_change_person %}
...@@ -282,11 +283,7 @@ ...@@ -282,11 +283,7 @@
<i class="material-icons iconify" data-icon="{{ invoice.get_variant_icon }}"></i> <i class="material-icons iconify" data-icon="{{ invoice.get_variant_icon }}"></i>
</td> </td>
<td> <td>
<select name="variant" disabled> {{ invoice.variant }}
{% for choice in invoice.get_variant_choices %}
<option value="{{ choice.0 }}" {% if invoice.variant == choice.0 %}selected{% endif %}>{{ choice.1 }}</option>
{% endfor %}
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -305,6 +302,16 @@ ...@@ -305,6 +302,16 @@
{{ invoice.due_date }} {{ invoice.due_date }}
</td> </td>
</tr> </tr>
{% if can_mark_registration_payed and not invoice.status == "confirmed" %}
<tr>
<td>
<a href="{% url 'pay_registration_by_pk' registration.pk %}" class="btn waves-effect waves-light">
<i class="material-icons left iconify" data-icon="mdi:account-check"></i>
{% trans "Mark payed" %}
</a>
</td>
</tr>
{% endif %}
</table> </table>
</div> </div>
</div> </div>
......
...@@ -84,6 +84,11 @@ urlpatterns = [ ...@@ -84,6 +84,11 @@ urlpatterns = [
views.CheckInRegistration.as_view(), views.CheckInRegistration.as_view(),
name="check_in_registration_by_pk", name="check_in_registration_by_pk",
), ),
path(
"event/registrations/<int:pk>/pay",
views.MarkRegistrationPayed.as_view(),
name="pay_registration_by_pk",
),
path( path(
"event/registrations/<int:pk>/retract", "event/registrations/<int:pk>/retract",
views.RetractRegistration.as_view(), views.RetractRegistration.as_view(),
......
...@@ -25,6 +25,7 @@ from rules.contrib.views import PermissionRequiredMixin, permission_required ...@@ -25,6 +25,7 @@ from rules.contrib.views import PermissionRequiredMixin, permission_required
from templated_email import send_templated_mail from templated_email import send_templated_mail
from aleksis.apps.postbuero.models import MailAddress from aleksis.apps.postbuero.models import MailAddress
from aleksis.apps.tezor.models.invoice import Invoice
from aleksis.core.mixins import AdvancedCreateView, AdvancedDeleteView, AdvancedEditView from aleksis.core.mixins import AdvancedCreateView, AdvancedDeleteView, AdvancedEditView
from aleksis.core.models import Activity, Group, Person from aleksis.core.models import Activity, Group, Person
from aleksis.core.util import messages from aleksis.core.util import messages
...@@ -1034,3 +1035,22 @@ class CheckInRegistration(PermissionRequiredMixin, View): ...@@ -1034,3 +1035,22 @@ class CheckInRegistration(PermissionRequiredMixin, View):
messages.error(self.request, _("Person is already checked in!")) messages.error(self.request, _("Person is already checked in!"))
return redirect("event_detail_by_name", slug=registration.event.slug) return redirect("event_detail_by_name", slug=registration.event.slug)
class MarkRegistrationPayed(PermissionRequiredMixin, View):
permission_required = "paweljong.mark_payment_payed_rule"
def get_object(self, *args, **kwargs):
registration = EventRegistration.objects.get(id=self.kwargs["pk"])
invoice = registration.get_invoice()
return invoice
def get(self, *args, **kwargs):
invoice = self.get_object()
invoice.status = "confirmed"
invoice.save()
messages.success(request, _("Successfully marked as payed!"))
return redirect("registration_by_pk", pk=invoice.for_object.pk)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment