-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a projects page to the organization. This makes the UI a little…
… more regular.
- Loading branch information
Showing
6 changed files
with
175 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
django_kala/organizations/templates/organizations/organization.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{% extends 'base.html' %} | ||
{% load i18n static kala_tags %} | ||
|
||
{% block content %} | ||
{% include 'includes/header.html' %} | ||
|
||
<div class="ui container"> | ||
{% if messages %} | ||
<div class="ui success message"> | ||
<i class="close icon"></i> | ||
<ul class="messages" style="margin-top: 0"> | ||
{% for message in messages %} | ||
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
{% endif %} | ||
|
||
<div class="repo title"> | ||
<div class="repo options"> | ||
{# <a class="ui compact button" href="{% url 'projects:export_project' project.pk %}">#} | ||
{# {% trans 'Download ZIP' %}#} | ||
{# </a>#} | ||
{# <div class="ui labeled button">#} | ||
{# <div class="ui compact floating watch dropdown button" data-content="Choose display options">#} | ||
{# <input type="hidden" value="watching">#} | ||
{# <i class="checklist icon"></i> {% trans 'Filter' %}#} | ||
{# <i class="dropdown icon"></i>#} | ||
{# <div class="menu" id="category-menu">#} | ||
{# <div class="item">#} | ||
{# <h4 data-value="">{% trans 'No Filter' %}</h4>#} | ||
{# </div>#} | ||
{# {% for category in project.category_set.all %}#} | ||
{# <div class="item">#} | ||
{# <h4 data-value="{{ category }}">{{ category }}</h4>#} | ||
{# </div>#} | ||
{# {% endfor %}#} | ||
{# </div>#} | ||
{# </div>#} | ||
{# </div>#} | ||
{# <div class="ui labeled button">#} | ||
{# <div class="ui compact floating watch dropdown button" data-content="Choose display options">#} | ||
{# <input type="hidden" value="watching">#} | ||
{# <i class="checklist icon"></i> {% trans 'Sort' %}#} | ||
{# <i class="dropdown icon"></i>#} | ||
{# <div class="menu" id="sort-menu">#} | ||
{# <div class="item">#} | ||
{# <h4 data-value="Alphabetically">{% trans 'Alphabetically' %}</h4>#} | ||
{# </div>#} | ||
{# <div class="item">#} | ||
{# <h4 data-value="Date">{% trans 'Date' %}</h4>#} | ||
{# </div>#} | ||
{# </div>#} | ||
{# </div>#} | ||
{# </div>#} | ||
</div> | ||
{% if organization|can_create:request.user %} | ||
<a class="ui positive compact icon button" href="{% url 'projects:new_project' %}"> | ||
+ {% trans 'New project' %} | ||
</a> | ||
{% else %} | ||
<p>{% trans 'You do not have permission to create new projects for this organization.' %}</p> | ||
{% endif %} | ||
</div> | ||
<div class="ui divider"> | ||
</div> | ||
<div class="ui container"> | ||
<div class="ui cards"> | ||
{% for project in projects %} | ||
<div class="ui card"> | ||
{# <a href="{% url 'projects:project' project.pk %}">#} | ||
{# <div class="ui fade reveal image">#} | ||
{# <img class="visible content" style="background-color: #f3f3f3"#} | ||
{# src="{% static project.get_icon %}"#} | ||
{# alt="{{ project.get_alt }}">#} | ||
{# <img class="hidden content" src="{% static "images/icons/android-download.png" %}"#} | ||
{# alt="{{ project.get_alt }}">#} | ||
{# </div>#} | ||
{# </a>#} | ||
<div class="content"> | ||
<a class="header" style="word-wrap: break-word;" | ||
href="{% url 'projects:project' project.pk %}">{{ project.name }}</a> | ||
</div> | ||
</div> | ||
{% empty %} | ||
<div class="ui container">{% trans 'There are no documents uploaded for this project.' %}</div> | ||
{% endfor %} | ||
|
||
</div> | ||
|
||
<div class="ui divider"></div> | ||
|
||
<div class="ui pagination menu"> | ||
{% for page in page_range %} | ||
<a class="{% if page == current_page %}active{% endif %} item" | ||
href="{% url 'organizations:organization' organization.pk %}?page={{ page }}"> | ||
{{ page }} | ||
</a> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
{% endblock content %} | ||
|
||
{% block scripts %} | ||
<script> | ||
var queryParameters = {}, queryString = location.search.substring(1), | ||
re = /([^&=]+)=([^&]*)/g, m; | ||
|
||
// Creates a map with the query string parameters | ||
while (m = re.exec(queryString)) { | ||
queryParameters[decodeURIComponent(m[1])] = decodeURIComponent(m[2]); | ||
} | ||
|
||
$('.dropdown') | ||
.dropdown({ | ||
direction: 'upward' | ||
}) | ||
; | ||
</script> | ||
{% endblock scripts %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from django.contrib.auth.decorators import login_required | ||
from django.core.exceptions import PermissionDenied | ||
from django.core.paginator import Paginator, InvalidPage | ||
from django.shortcuts import get_object_or_404 | ||
from django.utils.decorators import method_decorator | ||
from django.utils.translation import ugettext as _ | ||
from django.views.generic import TemplateView | ||
|
||
from organizations.models import Organization | ||
|
||
|
||
class OrganizationView(TemplateView): | ||
template_name = 'organizations/organization.html' | ||
|
||
def get_context_data(self, **kwargs): | ||
per_page = self.request.GET.get('per_page', 20) | ||
page = self.request.GET.get('page', 1) | ||
paginator = Paginator(self.projects, per_page) | ||
try: | ||
projects = paginator.page(page).object_list | ||
except InvalidPage: | ||
projects = paginator.page(1) | ||
return { | ||
'organization': self.organization, | ||
'projects': projects, | ||
'page_range': paginator.page_range, | ||
'current_page': page, | ||
} | ||
|
||
@method_decorator(login_required) | ||
def dispatch(self, request, pk, *args, **kwargs): | ||
self.organization = get_object_or_404(Organization.objects.active().prefetch_related('project_set'), pk=pk) | ||
self.projects = self.organization.get_projects(user=self.request.user) | ||
if not self.organization.can_create(user=self.request.user): | ||
raise PermissionDenied( | ||
_('You do not have permission to view this organization.') | ||
) | ||
|
||
return super(OrganizationView, self).dispatch(request, *args, **kwargs) |