From 75f4c551817cea97f3555524f330858d42bf2159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Fri, 16 Dec 2016 16:41:17 +0100 Subject: [PATCH] Removed viewpoint for Django url patterns. Fixed #1453. --- openslides/core/static/js/core/site.js | 34 -------------------------- openslides/core/urls.py | 4 --- openslides/core/views.py | 20 --------------- tests/unit/core/test_views.py | 17 ------------- 4 files changed, 75 deletions(-) diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index 873e06a60..307b9d2ff 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -381,21 +381,6 @@ angular.module('OpenSlidesApp.core.site', [ } ]) -// Helper to add ui.router states at runtime. -// Needed for the django url_patterns. -.provider('runtimeStates', [ - '$stateProvider', - function($stateProvider) { - this.$get = function($q, $timeout, $state) { - return { - addState: function(name, state) { - $stateProvider.state(name, state); - } - }; - }; - } -]) - /* This factory handles the filtering of the OS-data-tables. It contains * all logic needed for the table header filtering. Things to configure: * - multiselectFilters: A dict associating the filter name to a list (empty per default). E.g. @@ -559,25 +544,6 @@ angular.module('OpenSlidesApp.core.site', [ } ]) -// Load the django url patterns -.run([ - 'runtimeStates', - '$http', - function(runtimeStates, $http) { - $http.get('/core/url_patterns/').then(function(data) { - for (var pattern in data.data) { - runtimeStates.addState(pattern, { - 'url': data.data[pattern], - data: {extern: true}, - onEnter: function($window) { - $window.location.href = this.url; - } - }); - } - }); - } -]) - // angular formly config options .run([ 'formlyConfig', diff --git a/openslides/core/urls.py b/openslides/core/urls.py index 8f99d192c..982ed8914 100644 --- a/openslides/core/urls.py +++ b/openslides/core/urls.py @@ -3,10 +3,6 @@ from django.conf.urls import url from . import views urlpatterns = [ - url(r'^core/url_patterns/$', - views.UrlPatternsView.as_view(), - name='core_url_patterns'), - url(r'^core/servertime/$', views.ServerTime.as_view(), name='core_servertime'), diff --git a/openslides/core/views.py b/openslides/core/views.py index 5e187e6e8..c0541ce08 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -1,7 +1,6 @@ import base64 import json import os -import re import uuid from collections import OrderedDict from operator import attrgetter @@ -11,7 +10,6 @@ from urllib.parse import unquote from django.apps import apps from django.conf import settings from django.contrib.staticfiles import finders -from django.core.urlresolvers import get_resolver from django.db.models import F from django.http import Http404, HttpResponse from django.utils.timezone import now @@ -785,24 +783,6 @@ class CountdownViewSet(ModelViewSet): # Special API views -class UrlPatternsView(utils_views.APIView): - """ - Returns a dictionary with all url patterns as json. The patterns kwargs - are transformed using a colon. - """ - URL_KWARGS_REGEX = re.compile(r'%\((\w*)\)s') - http_method_names = ['get'] - - def get_context_data(self, **context): - result = {} - url_dict = get_resolver(None).reverse_dict - for pattern_name in filter(lambda key: isinstance(key, str), url_dict.keys()): - normalized_regex_bits, p_pattern, pattern_default_args = url_dict[pattern_name] - url, url_kwargs = normalized_regex_bits[0] - result[pattern_name] = self.URL_KWARGS_REGEX.sub(r':\1', url) - return result - - class ServerTime(utils_views.APIView): """ Returns the server time as UNIX timestamp. diff --git a/tests/unit/core/test_views.py b/tests/unit/core/test_views.py index 7012b4d91..0d5dbd350 100644 --- a/tests/unit/core/test_views.py +++ b/tests/unit/core/test_views.py @@ -5,23 +5,6 @@ from openslides.core import views from openslides.utils.rest_api import ValidationError -class TestUrlPatternsView(TestCase): - @patch('openslides.core.views.get_resolver') - def test_get_context_data(self, mock_resolver): - mock_resolver().reverse_dict = { - 'url_pattern1': ([['my_url1', [None]]], None, None), - 'url_pattern2': ([['my_url2/%(kwarg)s/', ['kwargs']]], None, None), - ('not_a_str', ): [[['not_a_str']]]} - view = views.UrlPatternsView() - - context = view.get_context_data() - - self.assertEqual( - context, - {'url_pattern1': 'my_url1', - 'url_pattern2': 'my_url2/:kwarg/'}) - - @patch('openslides.core.views.ProjectorViewSet.get_object') class ProjectorAPI(TestCase): def setUp(self):