Skip to content

Commit

Permalink
group permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
handebeklen committed Feb 24, 2025
1 parent 294252f commit f5a3c56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion canvas/templates/canvas/partials/chip.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<h4 style="display:inline">{{ chip }}</h4>
<span class="badge pico-background-cyan-500">{{ chip.chip_type }}</span>
</div>
{% if user.is_staff %}
{% if user.is_staff or user|has_group:"chip_edit" %}
<nav class="icon-nav">
<ul>
<li>
Expand Down
4 changes: 3 additions & 1 deletion canvas/templates/canvas/partials/sample.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% load chip_tags %}

<article
{% if forloop.last and samples.has_next %}
hx-get="{% url 'sample_search' %}" hx-trigger="intersect once"
Expand All @@ -8,7 +10,7 @@
style="border-radius:1em; padding:2em;"
>
<header style="border-radius:1em; padding:1em;">
{% if user.is_staff %}
{% if user.is_staff or user|has_group:"sample_edit" %}
<nav style="float:right; transform:translateY(-25%);">
<ul>
<li>
Expand Down
5 changes: 5 additions & 0 deletions canvas/templatetags/chip_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def get_chip_status(chip):
return check_pipeline_status(chip.chip_id)


@register.filter(name="has_group")
def has_group(user, group_name):
return user.groups.filter(name=group_name).exists()


@register.simple_tag(name="sorted_chip", takes_context=True)
def sortedchip(context, chip, matches=None):
user = context["user"]
Expand Down

0 comments on commit f5a3c56

Please sign in to comment.