Put case study editing behind a feature flag

This commit is contained in:
Anna Sidwell 2019-03-07 09:15:18 +00:00
parent f346356239
commit 0656eee87a
4 changed files with 13 additions and 1 deletions

View File

@ -166,6 +166,9 @@ class EditCaseStudy(UserPassesTestMixin, BaseEditForm):
form_class = ShortCaseStudyForm
def test_func(self):
if settings.FFCAN_EDIT is False:
return False
object = self.get_object()
if object.author:
author = object.author.id

View File

@ -3,6 +3,8 @@ try:
except ImportError:
from django.core.urlresolvers import reverse
from django.conf import settings
from django.views.generic import DetailView, ListView, RedirectView, UpdateView
from django.contrib.auth.mixins import LoginRequiredMixin
@ -28,6 +30,8 @@ class UserDetailView(LoginRequiredMixin, DetailView):
case_studies = CaseStudy.objects.filter(author=self.request.user.id)
context['case_studies'] = case_studies
context['enable_edit'] = settings.FF_CAN_EDIT
return context

View File

@ -359,3 +359,6 @@ from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
# Feature flags
FF_CAN_EDIT = False

View File

@ -40,8 +40,10 @@
<td>{% if case.language %}{{ case.language }}{% else %}-{% endif %}
<td>{% if case.approved %}Yes{% else %}No{% endif %}
<td>
<a href="{% url 'detail' case.slug %}">View</a> |
<a href="{% url 'detail' case.slug %}">View</a>
{% if enable_edit %} |
<a href="{% url 'edit' case.id %}">Edit</a>
{% endif %}
{% endfor %}
</tbody>
</table>