Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 7aa839c4 authored by LETORT Sebastien's avatar LETORT Sebastien
Browse files

Several fixes after code review.

query_webapps_for_user doesn't have the only_published_version param anymore.
comment explains the filtering with 'webapp__published'.
debug log comment are removed.
WebappVersion in error state are show to the user.
WebappVersionList.get_queryset return query_set and not values.
no more mention of atomic transaction.
WebappVersionList.post: var name correction.
parent ab7107e3
......@@ -213,7 +213,7 @@ def get_request_user(request):
return request.user
def query_webapps_for_user(user, only_published_version=False):
def query_webapps_for_user(user):
"""Return a queryset of all webapps visible by a given user"""
if user.is_superuser:
......@@ -222,13 +222,12 @@ def query_webapps_for_user(user, only_published_version=False):
# select webapps that are either public or owned by the user
# if only_published_version is True, then only published version of non user app
# are returned.
q_filter = Q(private=False)
if only_published_version:
q_filter = q_filter & Q(webapp__published=True)
# webapp__ refers to WebappVersion_set, with 'related_name'
# cf https://docs.djangoproject.com/en/2.2/topics/db/queries/#following-relationships-backward
q_filter = Q(private=False) & Q(webapp__published=True)
qs = Webapp.objects \
.filter(Q(user_id=user.id) | q_filter) \
.distinct()
# log.debug( "query = {}".format(qs.query) )
return qs
......@@ -180,11 +180,8 @@ class WebappList(AllAccessMixin, ListView):
template_name = 'webapp_list.html'
def get_queryset(self):
webapps = query_webapps_for_user(self.request.user, only_published_version=True) \
.order_by('-created_at') \
.values()
# ~ for x in webapps:
# ~ log.debug( "app : {}".format(x) )
webapps = query_webapps_for_user(self.request.user) \
.order_by('-created_at')
return webapps
......@@ -594,7 +591,7 @@ class WebappVersionList(UserAccessMixin, ListView):
name = self.kwargs['docker_name']
queryset = WebappVersion.objects \
.filter(webapp__docker_name=name) \
.exclude(state__in=(WebappVersion.ERROR, WebappVersion.REPLACED))
.exclude(state__in=(WebappVersion.REPLACED))
return queryset
......@@ -605,16 +602,15 @@ class WebappVersionList(UserAccessMixin, ListView):
return super().get_context_data(**kwargs)
@transaction.atomic
def post(self, request, *args, **kwargs):
log.info("WebappVersionList.post {} - {}".format(request.POST, kwargs))
for version_id, values in request.POST.items():
for version_id, value in request.POST.items():
if 'csrfmiddlewaretoken' == version_id:
continue
o_version = WebappVersion.objects.get(id=version_id)
o_version.published = values
o_version.published = value
o_version.save()
messages.success(request, "Published status have been updated.\n")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment