Commit d4af4bc9 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

ContributorsView

parent 6ef5b155
import django_filters
from .models import Project
from . import models
class ProjectFilter(django_filters.FilterSet):
name = django_filters.CharFilter(lookup_expr='icontains')
class Meta:
model = Project
model = models.Project
fields = ('name',)
class ContributorFilter(django_filters.FilterSet):
name = django_filters.CharFilter(name='contributorname__name', label='name', lookup_expr='icontains')
mail = django_filters.CharFilter(name='contributormail__mail', label='mail', lookup_expr='icontains')
project = django_filters.CharFilter(name='projects__name', label='project', lookup_expr='icontains')
class Meta:
model = models.Contributor
fields = ('name', 'mail', 'project')
......@@ -102,3 +102,10 @@ class ContributorTable(StrippedTable):
class Meta:
model = models.Contributor
fields = ('names', 'mails')
class ContributorProjectTable(ContributorTable):
projects = tables.Column(accessor='contributed', orderable=False)
class Meta:
fields = ('names', 'mails', 'projects')
......@@ -6,4 +6,5 @@
<li><a href="{% url 'rainboard:articles' %}">Articles</a></li>
<li><a href="{% url 'rainboard:forges' %}">Forges</a></li>
<li><a href="{% url 'rainboard:namespaces' %}">Namespaces</a></li>
<li><a href="{% url 'rainboard:contributors' %}">Contributors</a></li>
{% endblock %}
{% extends 'base.html' %}
{% load django_tables2 bootstrap3 %}
{% block content %}
<h1>Contributors</h1>
{% if filter %}
<form action="" method="get" class="form form-inline">
{% bootstrap_form filter.form layout='inline' %}
{% bootstrap_button 'filter' %}
</form>
{% endif %}
{% render_table table %}
{% endblock %}
......@@ -4,13 +4,14 @@
{% block content %}
<h1>Projects</h1>
{% if filter %}
<form action="" method="get" class="form form-inline">
{% bootstrap_form filter.form layout='inline' %}
{% bootstrap_button 'filter' %}
</form>
{% endif %}
{% render_table table %}
{% render_table table %}
{% endblock %}
......@@ -10,6 +10,7 @@ urlpatterns = [
path('articles', views.ArticlesView.as_view(), name='articles'),
path('article/create', views.ArticleCreateView.as_view(), name='article-new'),
path('namespaces', views.NamespacesView.as_view(), name='namespaces'),
path('contributors', views.ContributorsView.as_view(), name='contributors'),
path('projects', views.ProjectsView.as_view(), name='projects'),
path('project/<str:slug>/robotpkg', views.ProjectView.as_view(), name='project'),
path('project/<str:slug>/repos', views.ProjectReposView.as_view(), name='project-repos'),
......
......@@ -4,8 +4,7 @@ from django_filters.views import FilterView
from django_tables2 import RequestConfig
from django_tables2.views import SingleTableMixin, SingleTableView
from . import models, tables
from .filters import ProjectFilter
from . import models, tables, filters
class ArticlesView(SingleTableView):
......@@ -31,7 +30,7 @@ class NamespacesView(SingleTableView):
class ProjectsView(SingleTableMixin, FilterView):
model = models.Project
table_class = tables.ProjectTable
filterset_class = ProjectFilter
filterset_class = filters.ProjectFilter
class ProjectView(DetailView):
......@@ -78,3 +77,9 @@ class ProjectContributorsView(ProjectTableView):
def get_object_list(self):
return self.object.contributors()
class ContributorsView(SingleTableMixin, FilterView):
model = models.Contributor
table_class = tables.ContributorProjectTable
filterset_class = filters.ContributorFilter
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment