Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show project and owner in list page title fixes #413 #415

Merged
merged 1 commit into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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