Skip to content

Commit

Permalink
Show project and owner in list page title fixes #413
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlockhart committed May 30, 2018
1 parent e9bde06 commit 6894506
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/experimenter/experiments/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@
from experimenter.experiments.views import (
ExperimentCreateView,
ExperimentFilterset,
ExperimentFiltersetForm,
ExperimentFormMixin,
ExperimentOrderingForm,
)
from experimenter.projects.tests.factories import ProjectFactory


class TestExperimentFiltersetForm(TestCase):

def test_get_project_display_value_returns_project_str(self):
project = ProjectFactory.create()
form = ExperimentFiltersetForm({"project": project.id})
self.assertEqual(form.get_project_display_value(), str(project))

def test_get_owner_display_value_returns_user_str(self):
user = UserFactory.create()
form = ExperimentFiltersetForm({"owner": user.id})
self.assertEqual(form.get_owner_display_value(), str(user))


class TestExperimentFilterset(TestCase):

def test_filters_out_archived_by_default(self):
Expand Down
12 changes: 12 additions & 0 deletions app/experimenter/experiments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ def clean_archived(self):

return False

def get_project_display_value(self):
project_id = self.data.get("project", None)

if project_id is not None:
return str(Project.objects.get(id=project_id))

def get_owner_display_value(self):
user_id = self.data.get("owner", None)

if user_id is not None:
return str(get_user_model().objects.get(id=user_id))


class ExperimentFilterset(filters.FilterSet):
archived = filters.BooleanFilter(
Expand Down
8 changes: 8 additions & 0 deletions app/experimenter/templates/experiments/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
{{ filter.form.status.value }}
{% endif %}

{% if filter.form.project.value %}
{{ filter.form.get_project_display_value }}
{% endif %}

{% if filter.form.firefox_channel.value %}
{{ filter.form.firefox_channel.value }}
{% endif %}
Expand All @@ -19,6 +23,10 @@
{{ filter.form.firefox_version.value }}
{% endif %}
Experiment{{ experiments|pluralize:"s" }}

{% if filter.form.owner.value %}
by {{ filter.form.get_owner_display_value }}
{% endif %}
</div>
<div class="col-md-3 text-right">
<div class="row">
Expand Down

0 comments on commit 6894506

Please sign in to comment.