--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# This file is part of MIL/PEER, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+import django_filters
+from django.forms.widgets import TextInput
+from django.utils.translation import ugettext_lazy as _
+
+from catalogue.filters import tag_filter
+from organizations.models import Organization
+
+
+class OrganizationFilterSet(django_filters.FilterSet):
+ name = django_filters.CharFilter(
+ lookup_expr='icontains', label='',
+ widget=TextInput(attrs={'placeholder': _('name')}))
+ language = tag_filter('language')
+ license = tag_filter('rights')
+ audience = tag_filter('audience')
+
+ class Meta:
+ model = Organization
+ fields = []
+
+ def filter_by_tag(self, queryset, name, value):
+ if not value:
+ return queryset
+ return queryset.filter(document__tags__in=value).distinct()
--- /dev/null
+{% load thumbnail %}
+
+<div style="width: 182px; height: 180px; position: relative; border: 1px solid #aaa; margin: 10px; display: inline-block; padding: 0; vertical-align: bottom">
+ <a style='display:block' href="{% url 'organizations_main' org.pk %}">
+ {% if org.logo %}
+ {% thumbnail org.logo "160x100" format="PNG" padding=True as th %}
+ <img src="{{ th.url }}" style="margin: 10px;">
+ {% endthumbnail %}
+ {% endif %}
+ <div style="position: absolute; bottom: 10px; left: 10px; width: 160px; height: 40px; overflow:hidden">{{ org.name }}</div>
+ </a>
+</div>
{% extends "catalogue/base.html" %}
-{% load i18n thumbnail %}
+{% load i18n %}
-{% block inner_content %}
-
-<h1>{% trans "Organizations" %}</h1>
-{% for org in organizations %}
- <div style="width: 182px; height: 180px; position: relative; border: 1px solid #aaa; margin: 10px; display: inline-block; padding: 0px; vertical-align: bottom">
- <a style='display:block' href="{% url 'organizations_main' org.pk %}">
- {% if org.logo %}
- {% thumbnail org.logo "160x100" format="PNG" padding=True as th %}
- <img src="{{ th.url }}" style="margin: 10px;">
- {% endthumbnail %}
- {% endif %}
- <div style="position: absolute; bottom: 10px; left: 10px; width: 160px; height: 40px; overflow:hidden">{{ org.name }}</div>
- </a>
+{% block content %}
+ <div class="row">
+ <h1 class="col-md-8 col-md-offset-3">{% trans "Organizations" %}</h1>
+ </div>
+ <div class="row">
+ <div class="col-md-2 col-md-offset-1">
+ <h3>{% trans "Filters" %}</h3>
+ <form action="" method="get">
+ {{ filter_set.form.as_p }}
+ <input type="submit" value="{% trans "Apply" %}" />
+ </form>
+ </div>
+ <div class="col-md-8">
+ {% for org in filter_set.qs %}
+ {% include "organizations/organization_box.html" %}
+ {% endfor %}
+ </div>
</div>
-{% endfor %}
-
{% endblock %}
from django.contrib.auth.models import User
from django.shortcuts import render, redirect
from django.http import Http404
+
+from organizations.filters import OrganizationFilterSet
from .forms import OrganizationForm, UserCardForm
from .models import Organization, Membership, UserCard
def organizations(request):
+ f = OrganizationFilterSet(request.GET, queryset=Organization.objects.all())
return render(request, "organizations/organizations.html", {
- 'organizations': Organization.objects.all(),
+ 'filter_set': f,
})
{% extends "catalogue/base.html" %}
{% load i18n %}
-{% load thumbnail %}
{% load static %}
<section>
<h1>{% trans "See active organizations and join" %}</h1>
{% for org in organizations %}
- <div style="width: 182px; height: 180px; position: relative; border: 1px solid #aaa; margin: 10px; display: inline-block; padding: 0; vertical-align: bottom">
- <a style='display:block' href="{% url 'organizations_main' org.pk %}">
- {% if org.logo %}
- {% thumbnail org.logo "160x100" format="PNG" padding=True as th %}
- <img src="{{ th.url }}" style="margin: 10px;">
- {% endthumbnail %}
- {% endif %}
- <div style="position: absolute; bottom: 10px; left: 10px; width: 160px; height: 40px; overflow:hidden">{{ org.name }}</div>
- </a>
- </div>
+ {% include "organizations/organization_box.html" %}
{% endfor %}
{% if more_organizations %}
<p style="text-align: right"><a href="{% url 'organizations' %}">{% trans "More organizations" %}</a></p>