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

Allow in review experiments to be edited fixes #416 #417

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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lint: compose_build
black: compose_build
docker-compose run app black -l 79 .

check: compose_build lint black test
check: compose_build black lint test
echo "Success"

makemigrations: compose_build
Expand Down
94 changes: 47 additions & 47 deletions app/experimenter/experiments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def is_in_review(self):
return self.status == self.STATUS_REVIEW

@property
def is_readonly(self):
return not self.is_draft
def is_editable(self):
return self.is_draft or self.is_in_review

@property
def is_begun(self):
Expand All @@ -136,6 +136,51 @@ def _transition_date(self, start_state, end_state):
if change.count() == 1:
return change.get().changed_on

@property
def is_high_risk(self):
return True in self._risk_questions

@property
def completed_overview(self):
return self.pk is not None

@property
def completed_variants(self):
return self.variants.exists()

@property
def completed_objectives(self):
return (
self.objectives != self.OBJECTIVES_DEFAULT
and self.analysis != self.ANALYSIS_DEFAULT
)

@property
def _risk_questions(self):
return (
self.risk_partner_related,
self.risk_brand,
self.risk_fast_shipped,
self.risk_confidential,
self.risk_release_population,
)

@property
def completed_risks(self):
return (
None not in self._risk_questions
and self.testing != self.TESTING_DEFAULT
)

@property
def is_ready_for_review(self):
return (
self.completed_overview
and self.completed_variants
and self.completed_objectives
and self.completed_risks
)

@property
def population(self):
return "{percent:g}% of {channel} Firefox {version}".format(
Expand Down Expand Up @@ -185,51 +230,6 @@ def test_tube_url(self):
"https://firefox-test-tube.herokuapp.com/experiments/{slug}/"
).format(slug=self.slug)

@property
def _risk_questions(self):
return (
self.risk_partner_related,
self.risk_brand,
self.risk_fast_shipped,
self.risk_confidential,
self.risk_release_population,
)

@property
def is_high_risk(self):
return True in self._risk_questions

@property
def completed_overview(self):
return self.pk is not None

@property
def completed_variants(self):
return self.variants.exists()

@property
def completed_objectives(self):
return (
self.objectives != self.OBJECTIVES_DEFAULT
and self.analysis != self.ANALYSIS_DEFAULT
)

@property
def completed_risks(self):
return (
None not in self._risk_questions
and self.testing != self.TESTING_DEFAULT
)

@property
def is_ready_for_review(self):
return (
self.completed_overview
and self.completed_variants
and self.completed_objectives
and self.completed_risks
)


class ExperimentVariant(models.Model):
experiment = models.ForeignKey(
Expand Down
27 changes: 19 additions & 8 deletions app/experimenter/experiments/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,26 @@ def test_variant_property_returns_experiment_variant(self):
)
self.assertEqual(experiment.variant, variant)

def test_experiment_with_created_status_is_not_readonly(self):
experiment = ExperimentFactory.create_with_variants()
self.assertFalse(experiment.is_readonly)
def test_experiment_is_editable_when_is_draft(self):
experiment = ExperimentFactory.create_with_status(
Experiment.STATUS_DRAFT
)
self.assertTrue(experiment.is_editable)

def test_experiment_with_any_status_after_created_is_readonly(self):
experiment = ExperimentFactory.create_with_variants()
experiment.status = experiment.STATUS_REVIEW
experiment.save()
self.assertTrue(experiment.is_readonly)
def test_experiment_is_editable_when_is_in_review(self):
experiment = ExperimentFactory.create_with_status(
Experiment.STATUS_REVIEW
)
self.assertTrue(experiment.is_editable)

def test_experient_is_not_editable_after_review(self):
all_statuses = set([status[0] for status in Experiment.STATUS_CHOICES])
editable_statuses = set(
[Experiment.STATUS_DRAFT, Experiment.STATUS_REVIEW]
)
for status in all_statuses - editable_statuses:
experiment = ExperimentFactory.create_with_status(status)
self.assertFalse(experiment.is_editable)

def test_experiment_is_not_begun(self):
statuses = (
Expand Down
14 changes: 7 additions & 7 deletions app/experimenter/templates/experiments/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h4 class="col-md-8 md-mt-0">
Overview
</h4>

{% if experiment.is_draft %}
{% if experiment.is_editable %}
<div class="col-md-4 text-right">
<a class="noanchorstyle" href="{% url "experiments-overview-update" slug=experiment.slug %}"><h5><span class="glyphicon glyphicon-pencil"></span> Edit</h5></a>
</div>
Expand Down Expand Up @@ -64,7 +64,7 @@ <h4 class="col-md-8">
Population
</h4>

{% if experiment.is_draft %}
{% if experiment.is_editable %}
<div class="col-md-4 text-right">
<a class="noanchorstyle" href="{% url "experiments-overview-update" slug=experiment.slug %}"><h5><span class="glyphicon glyphicon-pencil"></span> Edit</h5></a>
</div>
Expand All @@ -86,7 +86,7 @@ <h4 class="col-md-8">
Firefox Pref &amp; Branches
</h4>

{% if experiment.is_draft %}
{% if experiment.is_editable %}
<div class="col-md-4 text-right">
<a class="noanchorstyle" href="{% url "experiments-variants-update" slug=experiment.slug %}"><h5><span class="glyphicon glyphicon-pencil"></span> Edit</h5></a>
</div>
Expand Down Expand Up @@ -118,7 +118,7 @@ <h4 class="col-md-8">
Objectives
</h4>

{% if experiment.is_draft %}
{% if experiment.is_editable %}
<div class="col-md-4 text-right">
<a class="noanchorstyle" href="{% url "experiments-objectives-update" slug=experiment.slug %}"><h5><span class="glyphicon glyphicon-pencil"></span> Edit</h5></a>
</div>
Expand All @@ -143,7 +143,7 @@ <h4 class="col-md-8">
Analysis
</h4>

{% if experiment.is_draft %}
{% if experiment.is_editable %}
<div class="col-md-4 text-right">
<a class="noanchorstyle" href="{% url "experiments-objectives-update" slug=experiment.slug %}"><h5><span class="glyphicon glyphicon-pencil"></span> Edit</h5></a>
</div>
Expand All @@ -169,7 +169,7 @@ <h4 class="col-md-8">
Risk Assessment
</h4>

{% if experiment.is_draft %}
{% if experiment.is_editable %}
<div class="col-md-4 text-right">
<a class="noanchorstyle" href="{% url "experiments-risks-update" slug=experiment.slug %}"><h5><span class="glyphicon glyphicon-pencil"></span> Edit</h5></a>
</div>
Expand Down Expand Up @@ -252,7 +252,7 @@ <h4 class="col-md-8">
Testing Plan
</h4>

{% if experiment.is_draft %}
{% if experiment.is_editable %}
<div class="col-md-4 text-right">
<a class="noanchorstyle" href="{% url "experiments-risks-update" slug=experiment.slug %}"><h5><span class="glyphicon glyphicon-pencil"></span> Edit</h5></a>
</div>
Expand Down