Skip to content

Commit

Permalink
Add a custom menu for the dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
danniel committed Sep 12, 2024
1 parent 07ee0de commit d74140b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
10 changes: 6 additions & 4 deletions backend/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ class UserDashboard(ModelAdmin):
readonly_fields = ("last_login", "date_joined")
exclude = ("password",)

def user_name(self):
return "asdasd"

@admin.display(empty_value="", description=_("Full Name"))
def view_full_name(self, obj):
return f"{obj.first_name} {obj.last_name}"

@admin.display(empty_value="", description=_("Role"))
def view_role(self, obj):
return ""
if obj.is_superuser:
return _("Administrator")
else:
# TODO: other roles Manager/Member/...
return _("Member")

def changelist_view(self, request, extra_context=None):
extra_context = {"title": _("Manage users")}
return super().changelist_view(request, extra_context=extra_context)


dashboard_site.register(User, UserDashboard)

17 changes: 5 additions & 12 deletions backend/dashboard/templates/dashboard/app_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@

<h2>
<a href="{{ app.app_url }}"
class="block font-semibold mb-2 mt-4 text-font-important-light text-sm truncate dark:text-font-important-dark"
title="{% blocktranslate with name=app.name %}Models in the {{ name }} application{% endblocktranslate %}">
Accounts
class="block font-semibold mb-2 mt-4 text-font-important-light text-sm truncate dark:text-font-important-dark">
{% translate "Accounts" %}
</a>
</h2>

<ol>
<li class="model-user {% if 'asdasdasd' in request.path|urlencode %} current-model{% endif %}">
{% comment %}
<h3 class="font-medium my-3 text-gray-900 text-sm dark:text-gray-200">
Users
</h3>
{% endcomment %}

<a href="{% url 'app:accounts_user_changelist' %}" id="link-asdasdasd"
class="block -mx-3 px-3 py-3 rounded-md truncate {% if 'asdasdasd' in request.path|urlencode %}bg-gray-100 font-semibold text-primary-600 dark:bg-white/[.06] dark:text-primary-500{% endif %}">
Users
<a href="{% url 'app:accounts_user_changelist' %}" id="link-user-changelist"
class="block -mx-3 px-3 py-3 rounded-md truncate">
{% translate "Users" %}
</a>
</li>
</ol>
Expand Down

0 comments on commit d74140b

Please sign in to comment.