Skip to content

Commit 53522c0

Browse files
[Offering] Update UI (#2890)
* feat(#2883): Display tasks/events using account benefits in account benefit details page * feat(#2887): Update wording for account benefits
1 parent e11735b commit 53522c0

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed

src/offering/templates/offering/account_benefit_details.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,56 @@
7373
</tr>
7474
</table>
7575

76+
{% if object.benefit.unit_type == "seat" %}
77+
<h3>Usage: tasks</h3>
78+
<table class="table table-striped">
79+
<tr>
80+
<th>Event</th>
81+
<th>Person</th>
82+
<th>Role</th>
83+
<th class="additional-links"></th>
84+
</tr>
85+
{% for task in tasks %}
86+
<tr>
87+
<td><a href="{{ task.event.get_absolute_url }}">{{ task.event }}</a></td>
88+
<td><a href="{{ task.person.get_absolute_url }}">{{ task.person }}</a></td>
89+
<td>{{ task.role }}</td>
90+
<td>
91+
<a href="{% url 'task_details' task.id %}" title="View {{ task }}"><i class="fas fa-info-circle"></i></a>
92+
&nbsp;
93+
{% if perms.workshops.change_task %}
94+
<a href="{% url 'task_edit' task.id %}" title="Edit {{ task }}"><i class="fas fa-edit"></i></a>
95+
{% endif %}
96+
</td>
97+
</tr>
98+
{% endfor %}
99+
</table>
100+
{% endif %}
101+
102+
{% if object.benefit.unit_type == "event" %}
103+
<h3>Usage: events</h3>
104+
<table class="table table-striped">
105+
<tr>
106+
<th>Slug</th>
107+
<th>Host</th>
108+
<th>Dates</th>
109+
<th class="additional-links"></th>
110+
</tr>
111+
{% for event in events %}
112+
<tr>
113+
<td><a href="{{ event.get_absolute_url }}">{{ event.slug }}</a></td>
114+
<td><a href="{% url 'organization_details' event.host.domain_quoted %}">{{ event.host }}</a></td>
115+
<td>{{ event.start }} &ndash; {{ event.end }}</td>
116+
<td>
117+
<a href="{% url 'event_details' event.slug %}" title="View {{ event.slug }}"><i class="fas fa-info-circle"></i></a>
118+
&nbsp;
119+
{% if perms.workshops.change_event %}
120+
<a href="{% url 'event_edit' event.slug %}" title="Edit {{ event.slug }}"><i class="fas fa-edit"></i></a>
121+
{% endif %}
122+
</td>
123+
</tr>
124+
{% endfor %}
125+
</table>
126+
{% endif %}
127+
76128
{% endblock %}

src/offering/templates/offering/account_benefit_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<th>Account</th>
99
<th>Partnership</th>
1010
<th>Benefit</th>
11-
<th>Allocation</th>
11+
<th>Used / allocated</th>
1212
<th>Discount</th>
1313
<th>Curriculum</th>
1414
<th>Dates</th>

src/offering/templates/offering/includes/account_benefits.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<th>Partnership</th>
66
{% endif %}
77
<th>Dates</th>
8-
<th>Allocation</th>
8+
<th>Used / allocated</th>
99
<th>Discount</th>
1010
<th>Curriculum</th>
1111
<th>Active</th>

src/offering/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232
from src.workshops.filters import EventCategoryFilter
3333
from src.workshops.forms import EventCategoryForm
34-
from src.workshops.models import EventCategory, Person
34+
from src.workshops.models import Event, EventCategory, Person, Task
3535
from src.workshops.utils.access import OnlyForAdminsMixin
3636
from src.workshops.utils.urls import safe_next_or_default_url
3737

@@ -274,6 +274,8 @@ class AccountBenefitDetails(OnlyForAdminsMixin, FlaggedViewMixin, AMYDetailView[
274274
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
275275
context = super().get_context_data(**kwargs)
276276
context["title"] = str(self.object)
277+
context["tasks"] = Task.objects.filter(allocated_benefit=self.object).select_related("event", "person", "role")
278+
context["events"] = Event.objects.filter(allocated_benefit=self.object).select_related("host")
277279
return context
278280

279281

0 commit comments

Comments
 (0)