misc: remove unused possibility to use a django template for home page (#25599)
This commit is contained in:
parent
8f697269d3
commit
b01abb6652
|
@ -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(
|
||||
|
|
|
@ -21,7 +21,6 @@ from . import compat
|
|||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.home, name='home'),
|
||||
url(r'^backoffice/', views.backoffice),
|
||||
|
||||
# provide django.contrib.auth view names for compatibility with
|
||||
|
|
21
wcs/views.py
21
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'
|
||||
|
||||
|
|
Loading…
Reference in New Issue