diff --git a/media/css/core.css b/media/css/core.css index b02168877..56f14c95a 100644 --- a/media/css/core.css +++ b/media/css/core.css @@ -217,6 +217,10 @@ p.build-success { font-size: .8em; color: #108830; margin: 0 0 3px; } p.build-failure { font-size: .8em; color: #dc1020; margin: 0 0 3px; } p.build-missing { font-size: .8em; color: #9d9a55; margin: 0 0 3px; } +/* build page */ + +#build_list select { width: 10em; } + /* dashboard bar */ diff --git a/readthedocs/builds/filters.py b/readthedocs/builds/filters.py new file mode 100644 index 000000000..effbc2b0a --- /dev/null +++ b/readthedocs/builds/filters.py @@ -0,0 +1,29 @@ +import django_filters + +from builds import constants +from builds.models import Build, Version + + +ANY_REPO = ( + ('', 'Any'), +) + +BUILD_TYPES = ANY_REPO + constants.BUILD_TYPES + + +class VersionFilter(django_filters.FilterSet): + project = django_filters.CharFilter(name='project__name', lookup_type="icontains") + slug= django_filters.CharFilter(label="Slug", name='slug', lookup_type='icontains') + + class Meta: + model = Version + fields = ['project', 'slug'] + +class BuildFilter(django_filters.FilterSet): + date = django_filters.DateRangeFilter(label="Build Date", name="date") + type = django_filters.ChoiceFilter(label="Build Type", choices=BUILD_TYPES) + + class Meta: + model = Build + fields = ['type', 'date', 'version', 'success'] + diff --git a/readthedocs/builds/views.py b/readthedocs/builds/views.py index 2087825d5..51bfa41d4 100644 --- a/readthedocs/builds/views.py +++ b/readthedocs/builds/views.py @@ -4,6 +4,7 @@ from django.shortcuts import get_object_or_404 from django.views.generic.list_detail import object_list, object_detail from builds.models import Build +from builds.filters import BuildFilter from projects.models import Project from taggit.models import Tag @@ -12,6 +13,7 @@ def build_list(request, project_slug=None, tag=None): """Show a list of builds. """ queryset = Build.objects.all() + filter = BuildFilter(request.GET, queryset=queryset) if tag: tag = get_object_or_404(Tag, slug=tag) @@ -28,6 +30,7 @@ def build_list(request, project_slug=None, tag=None): queryset=queryset, extra_context={ 'project': project, + 'filter': filter, 'tag': tag, 'active_builds': active_builds }, diff --git a/readthedocs/projects/filters.py b/readthedocs/projects/filters.py new file mode 100644 index 000000000..15f6aa6cd --- /dev/null +++ b/readthedocs/projects/filters.py @@ -0,0 +1,25 @@ +import django_filters + +from projects import constants +from projects.models import Project + +ANY_REPO = ( + ('', 'Any'), +) + +REPO_CHOICES = ANY_REPO + constants.REPO_CHOICES + +class ProjectFilter(django_filters.FilterSet): + name = django_filters.CharFilter(label="Name", name='name', lookup_type='icontains') + pub_date = django_filters.DateRangeFilter(label="Created Date", name="pub_date") + repo = django_filters.CharFilter(label="Repository URL", name='repo', lookup_type='icontains') + repo_type = django_filters.ChoiceFilter( + label="Repository", + name='repo', + lookup_type='icontains', + choices=REPO_CHOICES, + ) + + class Meta: + model = Project + fields = ['name', 'pub_date', 'repo', 'repo_type'] diff --git a/readthedocs/templates/base_filter.html b/readthedocs/templates/base_filter.html new file mode 100644 index 000000000..aa886f3b2 --- /dev/null +++ b/readthedocs/templates/base_filter.html @@ -0,0 +1,29 @@ +{% extends "base.html" %} + +{% load i18n %} + +{% block nav-dashboard %} class="active"{% endblock %} + +{% block project_editing %} + + +