Skip to content

Commit

Permalink
Pending users approval from detailed view
Browse files Browse the repository at this point in the history
  • Loading branch information
szabozoltan69 committed Jun 28, 2024
1 parent 164bc1f commit 29b2eb7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/templates/admin/submit_line.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{% if show_save_and_next %}<input type="submit" value="{% trans 'Save and view next one' %}" name="_save_next">{% endif %}
{% if show_save_and_add_another %}<input type="submit" value="{% trans 'Save and add another' %}" name="_addanother">{% endif %}
{% if show_save_and_continue %}<input type="submit" value="{% if can_change %}{% trans 'Save and continue editing' %}{% else %}{% trans 'Save and view' %}{% endif %}" name="_continue">{% endif %}
{% if show_approve_user %}<input type="submit" value="{% trans 'Approve user' %}" name="_approve_user">{% endif %}
{% if show_close %}<a href="{% url opts|admin_urlname:'changelist' %}" class="closelink">{% trans 'Close' %}</a>{% endif %}
{% endblock %}
</div>
13 changes: 13 additions & 0 deletions registrations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PendingAdmin(CompareVersionAdmin):
"get_phone",
"justification",
"created_at",
"email_verified",
)
search_fields = ("user__username", "user__email", "admin_contact_1", "admin_contact_2")
list_display = ("get_username_and_mail", "get_region", "get_country", "created_at", "email_verified")
Expand Down Expand Up @@ -151,6 +152,18 @@ def response_change(self, request, obj):
return HttpResponseRedirect(".")
return super().response_change(request, obj)

def change_view(self, request, object_id, form_url='', extra_context=None):
try:
extra_context['show_approve_user'] = True
except TypeError:
extra_context = {'show_approve_user': True}
return self.changeform_view(request, object_id, form_url, extra_context)

def save_model(self, request, obj, form, change):
if '_approve_user' in request.POST:
self.activate_users(request, [obj])
super().save_model(request, obj, form, change)

def get_actions(self, request):
actions = super(PendingAdmin, self).get_actions(request)
return actions
Expand Down

0 comments on commit 29b2eb7

Please sign in to comment.