From 0788215b813c55d0ba9f8396687140930123b097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 7 Aug 2018 22:52:04 +0200 Subject: [PATCH] misc: remove unused possibility to use a django template for home page (#25599) --- wcs/forms/root.py | 64 ----------------------------------------------- wcs/urls.py | 1 - wcs/views.py | 21 ---------------- 3 files changed, 86 deletions(-) diff --git a/wcs/forms/root.py b/wcs/forms/root.py index 491cb3dd..d2335a2d 100644 --- a/wcs/forms/root.py +++ b/wcs/forms/root.py @@ -1472,70 +1472,6 @@ class RootDirectory(AccessControlled, Directory): from wcs.api import ApiFormdefsDirectory return ApiFormdefsDirectory(self.category)._q_index() - def get_context(self): - from wcs.api import is_url_signed, get_user_from_api_query_string - user = get_user_from_api_query_string() or get_request().user - list_all_forms = (user and user.is_admin) or (is_url_signed() and user is None) - - list_forms = [] - - if self.category: - formdefs = FormDef.select(lambda x: ( - str(x.category_id) == str(self.category.id) and ( - not x.is_disabled() or x.disabled_redirection)), - order_by='name', - ignore_errors=True, - lightweight=True) - else: - formdefs = FormDef.select(lambda x: not x.is_disabled() or x.disabled_redirection, - order_by='name', - ignore_errors=True, - lightweight=True) - - charset = get_publisher().site_charset - - for formdef in formdefs: - authentication_required = False - if formdef.roles and not list_all_forms: - if not user: - if not formdef.always_advertise: - continue - authentication_required = True - elif logged_users_role().id not in formdef.roles: - for q in user.roles or []: - if q in formdef.roles: - break - else: - if not formdef.always_advertise: - continue - authentication_required = True - - formdict = {'title': unicode(formdef.name, charset), - 'slug': formdef.url_name, - 'url': formdef.get_url(), - 'authentication_required': authentication_required} - - formdict['redirection'] = bool(formdef.is_disabled() and - formdef.disabled_redirection) - - # we include the count of submitted forms so it's possible to sort - # them by popularity - formdict['count'] = formdef.data_class().count() - - if formdef.category: - formdict['category'] = unicode(formdef.category.name, charset) - formdict['category_position'] = (formdef.category.position or 0) - else: - formdict['category_position'] = sys.maxint - - list_forms.append(formdict) - - list_forms.sort(lambda x, y: cmp(x['category_position'], y['category_position'])) - for formdict in list_forms: - del formdict['category_position'] - - return list_forms - def get_categories(self, user): result = [] formdefs = FormDef.select( diff --git a/wcs/urls.py b/wcs/urls.py index 594b26b6..6eebcafd 100644 --- a/wcs/urls.py +++ b/wcs/urls.py @@ -22,7 +22,6 @@ from . import views from . import api urlpatterns = [ - url(r'^$', views.home, name='home'), url(r'^backoffice/', views.backoffice), url(r'^api/validate-condition$', api.validate_condition, name='api-validate-condition'), diff --git a/wcs/views.py b/wcs/views.py index 7fcf020e..3c1afb34 100644 --- a/wcs/views.py +++ b/wcs/views.py @@ -22,27 +22,6 @@ from .qommon import template from . import compat -class Home(compat.TemplateWithFallbackView): - template_name = 'home.html' - - def get_context_data(self, **kwargs): - context = super(Home, self).get_context_data(**kwargs) - - with compat.request(self.request): - user = get_request().user - if user: - context['message'] = TextsDirectory.get_html_text('welcome-logged') - else: - context['message'] = TextsDirectory.get_html_text('welcome-unlogged') - - root_directory = FormsRootDirectory() - context['forms'] = root_directory.get_context() - - return context - -home = Home.as_view() - - class Backoffice(compat.TemplateWithFallbackView): template_name = 'wcs/backoffice.html' -- 2.18.0