Skip to content

Commit

Permalink
New activity pages (#1100)
Browse files Browse the repository at this point in the history
Replace activity page with updated version. Uses a new view and new base template for bootstrap 4.

This also renders an old view and old templates obsolete, but hasn't yet removed them. A later PR should be done to clean this up.
  • Loading branch information
madprime authored Mar 6, 2020
1 parent 70f56ad commit 24d500a
Show file tree
Hide file tree
Showing 30 changed files with 778 additions and 33 deletions.
2 changes: 1 addition & 1 deletion common/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def activity_from_data_request_project(project, user=None):
"label": project.id_label,
"name": project.name,
"url": "direct-sharing/images/badge.png",
"href": reverse("activity-management", kwargs={"source": project.slug}),
"href": reverse("activity", kwargs={"slug": project.slug}),
},
"source_name": project.id_label,
"project": project,
Expand Down
2 changes: 1 addition & 1 deletion common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def send_emails(project_id, project_members, subject, message, all_members=False
"project": project.name,
"username": project_member.member.user.username,
"activity_management_url": full_url(
reverse("activity-management", kwargs={"source": project.slug})
reverse("activity", kwargs={"slug": project.slug})
),
"project_message_form": full_url(
reverse("activity-messaging", kwargs={"source": project.slug})
Expand Down
2 changes: 1 addition & 1 deletion data_import/templates/data_import/datatypes-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h4 class="card-subtitle">{{ object.description }}</h4>
{% if object.source_projects.all %}
<ul>
{% for project in object.source_projects.all %}
{% if project.approved %}<li><a href="{% url 'activity-management' project.slug %}">{{ project.name }}</a></li>{% endif %}
{% if project.approved %}<li><a href="{% url 'activity' project.slug %}">{{ project.name }}</a></li>{% endif %}
{% endfor %}
</ul>
{% endif %}
Expand Down
59 changes: 59 additions & 0 deletions open_humans/templates/member/activity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% extends 'base-bs4.html' %}
{% load static %}
{% load utilities %}

{% block head_title %}{{ project.name }}{% endblock %}

{% block meta_description %}&quot;{{ project.name }}&quot; on Open Humans: {{ project.long_description }}{% endblock meta_description %}

{% block main %}
<div class="d-flex mt-4">
<div class="flex-grow-1 mb-3">
<div class="d-none d-sm-inline-block">
<h1>{{ project.name }}</h1>
{% include 'partials/activity-info-short-bs4.html' %}
</div>
<div class="d-flex justify-content-center d-sm-none">
<div class="w-25 m-2">
<img class="img-fluid" src="{% static 'images/default-badge.png' %}">
</div>
</div>
<div class="d-flex justify-content-center d-sm-none text-center">
<h1 class="justify-content-center">{{ project.name }}</h1>
</div>
<div class="d-flex justify-content-center d-sm-none">
{% include 'partials/activity-info-short-bs4.html' %}
</div>
</div>
<div class="d-none d-sm-inline-block w-25">
<img class="img-fluid max-width px-sm-1 pt-sm-1 px-md-3 pt-md-2" src="{% static 'images/default-badge.png' %}" style="max-height:10rem;">
</div>
</div>
<h2>About {{ project.name }}</h2>
<p>{{ project.long_description|markdown }}</p>
<ul class="nav nav-tabs" id="activity-panel-nav" role="tablist">

<li class="nav-item">
<a class="nav-link active" id="activity-panel-info-tab" data-toggle="tab"
href="#activity-panel-info" role="tab" aria-controls="activity-panel-info"
aria-selected="true">Info</a>
</li>
{% if project.returned_data_description or member_data_files %}
<li class="nav-item">
<a class="nav-link{% if not member_data_files %} disabled{% endif %}" id="activity-panel-data-tab" data-toggle="tab"
href="#activity-panel-data" role="tab" aria-controls="activity-panel-data"
aria-selected="false">Data</a>
</li>
{% endif %}
</ul>
<div class="tab-content mt-3" id="myTabContent">
<div class="tab-pane fade show active" id="activity-panel-info" role="tabpanel"
aria-labelledby="activity-panel-info-tab">
{% include 'partials/activity-panel-info.html' %}
</div>
<div class="tab-pane fade" id="activity-panel-data" role="tabpanel"
aria-labelledby="activity-panel-data-tab">
{% include 'partials/activity-panel-data.html' %}
</div>
</div>
{% endblock main %}
4 changes: 2 additions & 2 deletions open_humans/templates/member/my-member-joined.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2>Current projects</h2>
<li>
<p>
<b><a href="{% if project.slug %}
{% url 'activity-management' project.slug %}
{% url 'activity' project.slug %}
{% else %}
{% url 'direct-sharing:join-on-site' slug=project.slug %}
{% endif %}">{{ project.name }}</a></b><br>
Expand All @@ -43,7 +43,7 @@ <h2>Past projects</h2>
<li>
<p>
<b><a href="{% if project.slug %}
{% url 'activity-management' project.slug %}
{% url 'activity' project.slug %}
{% else %}
{% url 'direct-sharing:join-on-site' slug=project.slug %}
{% endif %}">{{ project.name }}</a></b><br>
Expand Down
6 changes: 3 additions & 3 deletions open_humans/templates/pages/data-processing-activities.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h5>Project data</h5>
</p>
<ul>
{% for project in project_data_sources %}
<li><b><a href="{% url 'activity-management' project.slug %}">{{ project.name }}:</a></b> {{ project.returned_data_description }}</li>
<li><b><a href="{% url 'activity' project.slug %}">{{ project.name }}:</a></b> {{ project.returned_data_description }}</li>
{% endfor %}
</ul>
<h3>Categories of data recipients</h3>
Expand All @@ -141,13 +141,13 @@ <h4>Projects</h4>
</p>
<ul>
{% for project in project_data_recipients %}
<li><b><a href="{% url 'activity-management' project.slug %}">{{ project.name }}</a>:</b>
<li><b><a href="{% url 'activity' project.slug %}">{{ project.name }}</a>:</b>
Led by {{ project.leader }}
{% if project.organization %}({{ project.organization }}){% endif %}<br>
Receiving:
<ul style="padding-bottom:8px;">
{% for source_proj in project.requested_sources.all %}
<li><a href="{% url 'activity-management' source_proj.slug %}">{{ source_proj.name }}</a></li>
<li><a href="{% url 'activity' source_proj.slug %}">{{ source_proj.name }}</a></li>
{% endfor %}
</ul>
</li>
Expand Down
4 changes: 2 additions & 2 deletions open_humans/templates/partials/activity-feed-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
<b><a href="{% url 'member-detail-direct' event.member.user.username %}">{{ event.member.name }}</a></b>
(<a href="{% url 'member-detail-direct' event.member.user.username %}">{{ event.member.user.username }}</a>)
joined
<b><a href="{% url 'activity-management' event.project.slug %}">{{ event.project.name }}</a></b>.
<b><a href="{% url 'activity' event.project.slug %}">{{ event.project.name }}</a></b>.
{% elif event.action == 'publicly-shared' %}
<b><a href="{% url 'member-detail-direct' event.member.user.username %}">{{ event.member.name }}</a></b>
(<a href="{% url 'member-detail-direct' event.member.user.username %}">{{ event.member.user.username }}</a>)
publicly shared
<b><a href="{% url 'activity-management' event.project.slug %}">{{ event.project.name }}</a></b>
<b><a href="{% url 'activity' event.project.slug %}">{{ event.project.name }}</a></b>
data.
{% endif %}
<br>
Expand Down
9 changes: 9 additions & 0 deletions open_humans/templates/partials/activity-info-short-bs4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="d-flex mb-1">
<div class="pr-3"><b>Managed by:</b></div>
<div>
{{ project.leader }}
{% if project.organization %}
<br><span class="text-muted">{{ project.organization}}</span>
{% endif %}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{% for requested_project in permissions.share_sources %}

<li>
<a href="{% url 'activity-management' source=requested_project.slug %}">
<a href="{% url 'activity' requested_project.slug %}">
<strong>{{ requested_project.name }}</strong>
</a>
{% project_is_connected requested_project user as connected %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h2>Sharing Opportunities</h2>
<ul>
{% for requesting_activity in requesting_activities %}
<li>
<a href="{% url 'activity-management' source=requesting_activity.slug %}">
<a href="{% url 'activity' requesting_activity.slug %}">
{{ requesting_activity.name }}:
</a>

Expand Down
42 changes: 42 additions & 0 deletions open_humans/templates/partials/activity-panel-data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% load static %}
{% load utilities %}
{# the "data" panel on an activity page #}
<h2>Your Data</h2>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Filename</th>
<th scope="col">Description</th>
<th scope="col">Download link</th>
<th scope="col">Tags</th>
<th scope="col">DataTypes</th>
</tr>
</thead>
<tbody>
{% for datafile in member_data_files|dictsort:'basename' %}
<tr>
<td>{{ datafile.basename }}</td>
<td>
<small>
{% if datafile.size %}<b>({{ datafile.size|filesizeformat }})</b>{% endif %}
{{ datafile.description }}
</small>
</td>
<td>
<a class="btn btn-primary-hollow btn-sm" href="{% get_download_url datafile %}" download>
Download</a>
</td>
<td>
{% for tag in datafile.tags %}
<span class="badge" style="background-color: #c9ecef">{{ tag }}</span>
{% endfor %}
</td>
<td>
{% for datatype in datafile.datatypes.all %}
<a href="{% url 'data-management:datatypes-detail' datatype.id %}">{{ datatype.name }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
Loading

0 comments on commit 24d500a

Please sign in to comment.