Skip to content

Commit

Permalink
Further additions to activity page (not authed)
Browse files Browse the repository at this point in the history
  • Loading branch information
madprime committed Feb 22, 2019
1 parent 4b04b05 commit 85ac52b
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 45 deletions.
72 changes: 46 additions & 26 deletions open_humans/templates/member/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="flex-grow-1 mb-3">
<div class="d-none d-sm-inline-block">
<h1>{{ project.name }}</h1>
{% include 'partials/activity-info-table-bs4.html' %}
{% include 'partials/activity-info-short-bs4.html' %}
</div>
<div class="d-flex justify-content-center d-sm-none">
<img class="w-25 m-2" src="{% static 'images/default-badge.png' %}">
Expand All @@ -20,7 +20,7 @@ <h1>{{ project.name }}</h1>
<h1 class="justify-content-center">{{ project.name }}</h1>
</div>
<div class="d-flex justify-content-center d-sm-none">
{% include 'partials/activity-info-table-bs4.html' %}
{% include 'partials/activity-info-short-bs4.html' %}
</div>
</div>
<div class="d-none d-sm-inline-block w-25">
Expand All @@ -44,23 +44,11 @@ <h2>Project membership</h2>
You'll review terms and permissions before finalizing authorization.
</div>
</div>
{% if project.request_username_access or project.requested_sources.exists %}
{% if requests_permissions %}
<h3>Permissions</h3>
<div class="row">
<div class="col">
<b>Requested permissions:</b>
</div>
<div class="col">
{% for source_project in project.requested_sources.all %}
<a href="{% url 'activity-management' source_project.slug %}">
{{ source_project.name }}</a><br>
{% endfor %}
{% if project.request_username_access %}
Username
{% endif %}
</div>
</div>
{% include 'partials/activity-permissions-bs4.html' %}
{% endif %}
<hr class="d-md-none">
</div>
<div class="col-md">
{% if requesting_projects %}
Expand All @@ -69,7 +57,7 @@ <h2>Projects &amp; studies</h2>
You can use &amp; share your data from {{ project.name }} with the
following other projects:
</p>
<div class="d-flex flex-wrap p-2 mb-2">
<div class="d-flex flex-wrap p-2">
{% for req_project in requesting_projects %}
<div class="w-25">
<div class="d-flex justify-content-center">
Expand All @@ -83,6 +71,7 @@ <h2>Projects &amp; studies</h2>
</div>
{% endfor %}
</div>
<hr>
{% endif %}
{% if notebooks %}
<h2>Notebooks</h2>
Expand All @@ -95,9 +84,10 @@ <h2>Notebooks</h2>
<li><a href="{{ notebook.details_url }}">{{ notebook.name }}</a></li>
{% endfor %}
</ul>
<hr>
{% endif %}
<h2>Project Members</h2>
<div class="d-flex">
<div class="d-flex py-2">
<div class="w-25">
<div class="d-flex justify-content-center">
<img src="{% static 'images/profile-placeholder.png' %}" style="height:2.5rem;">
Expand Down Expand Up @@ -134,17 +124,47 @@ <h2>Project Members</h2>
</div>
</div>
</div>
<p><a href="{% url 'api:members-by-source' %}?source={{ project.id_label }}">See all members...</a></p>
<p>
<a href="{% url 'api:members-by-source' %}?source={{ project.id_label }}">See
all members...</a>
</p>
<hr>
<h2>Project information</h2>
<div>
<b>Managed by:</b>
<div class="d-inline-block">
{{ project.leader }}
</div><br>
<b>Contact email:</b> {{ project.contact_email }}<br>
<b>Joined by:</b>
{% include 'partials/activity-info-short-bs4.html' %}
<div class="mb-1">
<b class="mr-2">Joined by:</b>
<a href="{% url 'api:members-by-source' %}?source={{ project.id_label }}">
{{ project.authorized_members }} members</a>
</div>
<div class="mb-1">
<b class="mr-2">Launched:</b> {{ project.project_approval_date|date }}
</div>
<div class="mb-1">
<b class="mr-2">Project website:</b>
<a href="{{ project.info_url }}">{{ project.info_url }}</a>
</div>
<div class="mb-1">
<b class="mr-2">Contact email:</b>
<a href="mailto:{{ project.contact_email }}">{{ project.contact_email }}</a>
</div>
<div class="mb-1">
<b class="mr-2">Project terms:</b>
<a href="{% if project.terms_url %}{{ project.terms_url }}{% else %}{{ project.info_url }}{% endif %}">Read here</a>
</div>
{% if requests_permissions %}
{% include 'partials/activity-permissions-bs4.html' %}
{% endif %}
{% if project.returned_data_description %}
<div class="d-flex mb-1">
<div class="pr-3">
<b>Uploaded&nbsp;data:</b>
</div>
<div class="text-muted">
{{ project.returned_data_description }}
</div>
</div>
{% endif %}
</div>
</div>
</div>
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>
13 changes: 0 additions & 13 deletions open_humans/templates/partials/activity-info-table-bs4.html

This file was deleted.

15 changes: 15 additions & 0 deletions open_humans/templates/partials/activity-permissions-bs4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="d-flex mb-1">
<div class="pr-3">
<b>Requested permissions:</b>
</div>
<div>
{% for source_project in project.requested_sources.all %}
<a href="{% url 'activity-management' source_project.slug %}">
{{ source_project.name }}</a><br>
{% endfor %}
{% if project.request_username_access %}
Username
{% endif %}
</div>
</div>

28 changes: 22 additions & 6 deletions open_humans/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,33 @@ class ActivityView(NeverCacheMixin, DetailView):
context_object_name = "project"
template_name = "member/activity.html"

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context["requesting_projects"] = self.object.requesting_projects.filter(
active=True
).filter(approved=True)
def get_notebooks(self):
resp = requests.get(
"https://exploratory.openhumans.org/notebook_by_source/",
params={"source": self.object.name},
)
if resp.status_code == 200:
context["notebooks"] = resp.json()["notebooks"]
return resp.json()["notebooks"]

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)

requesting_projects_filtered = self.object.requesting_projects.filter(
active=True
).filter(approved=True)
requests_permissions = (
self.object.request_username_access
or self.object.requested_sources.exists()
)

context.update(
{
"notebooks": self.get_notebooks(),
"requesting_projects": requesting_projects_filtered,
"requests_permissions": requests_permissions,
}
)

return context


Expand Down

0 comments on commit 85ac52b

Please sign in to comment.