Skip to content

Commit

Permalink
apps/userdashboard: add activities page view, url, template and link …
Browse files Browse the repository at this point in the history
…from overview
  • Loading branch information
philli-m committed Mar 25, 2021
1 parent 2b732b8 commit 9a9221f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>

<div class="container">
<div class="row pt-4">
<div class="row py-4">

<div class="col-md-3">
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "a4_candy_userdashboard/base_userdashboard.html" %}
{% load i18n %}

{% block dashboard_content %}
<a class="btn btn--none pl-0 pt-0" href="{% url 'userdashboard-overview' %}">
<i class="fa fa-chevron-left" aria-hidden="true"></i>
<span>{% trans 'Back' %}</span>
</a>
<h3 class="mt-2">{% trans 'Activities' %}</h3>

{% for action in view.actions %}
{% include 'a4_candy_actions/includes/action.html' with action=action %}
{% endfor %}

{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ <h3 class="mt-0">{% trans 'Following' %}</h3>
{% endfor %}
</div>

{% for action in view.actions %}
{% for action in view.actions|slice:":5" %}
{% include 'a4_candy_actions/includes/action.html' with action=action %}
{% empty %}
{% trans 'No activity yet. '%}
{% endfor %}

{% if view.actions.count > 5 %}
<a href="{% url 'userdashboard-activities' %}">{% trans 'View more' %}</a>
{% endif %}
{% endblock %}
3 changes: 3 additions & 0 deletions apps/userdashboard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
url(r'^moderation/$',
views.UserDashboardModerationView.as_view(),
name='userdashboard-moderation'),
url(r'^overview/activities/$',
views.UserDashboardActivitiesView.as_view(),
name='userdashboard-activities'),
]
22 changes: 21 additions & 1 deletion apps/userdashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def projects(self):
def actions(self):
return Action.objects.filter(
actor=self.request.user,
).exclude_updates()[:5]
).exclude_updates()


class UserDashboardModerationView(LoginRequiredMixin,
Expand All @@ -62,3 +62,23 @@ def organisations(self):
project__follow__creator=self.request.user,
project__follow__enabled=True
).distinct()


class UserDashboardActivitiesView(LoginRequiredMixin,
generic.base.ContextMixin,
generic.base.TemplateResponseMixin,
generic.base.View,
):

model = User
template_name = 'a4_candy_userdashboard/userdashboard_activities.html'

def get(self, request):
response = self.render_to_response(self.get_context_data())
return response

@property
def actions(self):
return Action.objects.filter(
actor=self.request.user,
).exclude_updates()

0 comments on commit 9a9221f

Please sign in to comment.