Skip to content

Commit

Permalink
Admin badge (SEA-1613).
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrillkuettel committed Nov 9, 2024
1 parent a3084fa commit ac13197
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/privatim/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ def fullname(self) -> str:
return self.email
return ' '.join(parts)

@property
def is_admin(self) -> bool:
return ('admin' in self.first_name.lower() or 'admin' in
self.last_name.lower())

@property
def picture(self) -> GeneralFile:
""" Returns the user's profile picture or the default picture. """
Expand Down
3 changes: 2 additions & 1 deletion src/privatim/views/people.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def people_view(request: 'IRequest') -> 'RenderData':
'name': f'{user.last_name} {user.first_name}',
'download_link': user.profile_pic_download_link(request),
'url': request.route_url('person', id=user.id),
'buttons': button_html
'buttons': button_html,
'is_admin': user.is_admin
})

return {
Expand Down
9 changes: 5 additions & 4 deletions src/privatim/views/templates/people.pt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@
</tr>
</thead>
<tbody>
<tr tal:repeat="person people">
<tr tal:repeat="user people">
<td>
<div class="d-flex align-items-center">
<img src="${person.download_link}" alt="${person.name}'s avatar" class="rounded-circle me-2" width="32" height="32">
<a href="${person.url}" class="mb-0 text-decoration-none">${person.name}</a>
<img src="${user.download_link}" alt="${user.name}'s avatar" class="rounded-circle me-2" width="32" height="32">
<a href="${user.url}" class="mb-0 text-decoration-none">${user.name}</a>
<span tal:condition="user.is_admin" class="badge bg-primary ms-2" i18n:translate="">Admin</span>
</div>
</td>
<td class="text-end">
<div class="d-flex justify-content-end gap-2" tal:content="person.buttons"></div>
<div class="d-flex justify-content-end gap-2" tal:content="user.buttons"></div>
</td>
</tr>
</tbody>
Expand Down

0 comments on commit ac13197

Please sign in to comment.