Commit ab7107e3 authored by LETORT Sebastien's avatar LETORT Sebastien
Browse files

sugar +/- PEP8 syntax correction.

remove useless else in helpers.query_webapps_for_user
parent e32ec378
Pipeline #87954 passed with stages
in 1 minute and 31 seconds
......@@ -218,18 +218,17 @@ def query_webapps_for_user(user, only_published_version=False):
if user.is_superuser:
return Webapp.objects.all()
else:
# 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)
qs = Webapp.objects \
.filter(Q(user_id=user.id) | q_filter ) \
.distinct()
#log.debug( "query = {}".format(qs.query) )
# 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)
return qs
qs = Webapp.objects \
.filter(Q(user_id=user.id) | q_filter) \
.distinct()
# log.debug( "query = {}".format(qs.query) )
return qs
......@@ -181,11 +181,13 @@ class WebappList(AllAccessMixin, ListView):
def get_queryset(self):
webapps = query_webapps_for_user(self.request.user, only_published_version=True) \
.order_by('-created_at').values()
.order_by('-created_at') \
.values()
# ~ for x in webapps:
# ~ log.debug( "app : {}".format(x) )
# ~ log.debug( "app : {}".format(x) )
return webapps
class UserWebappList(AllAccessMixin, ListView):
"""List of user's webapp
......@@ -607,7 +609,7 @@ class WebappVersionList(UserAccessMixin, ListView):
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, values in request.POST.items():
if 'csrfmiddlewaretoken' == version_id:
continue
......@@ -1237,10 +1239,10 @@ class JobCreate(AllAccessMixin, SuccessMessageMixin, CreateView):
# select the versions published or all if the app belongs to the user
# and in one of the 3 states SANDBOX,COMMITTED or READY
o_versions = WebappVersion.objects \
.filter(Q(published=True)|Q(webapp__user=self.request.user.id),
webapp=webapp, state__in=( WebappVersion.SANDBOX,
WebappVersion.COMMITTED,
WebappVersion.READY),) \
.filter(Q(published=True) | Q(webapp__user=self.request.user.id),
webapp=webapp, state__in=(WebappVersion.SANDBOX,
WebappVersion.COMMITTED,
WebappVersion.READY),) \
.values_list("number")
# the list of versions to be displayed is sorted (clever mix string+number)
......
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