Merge pull request #2785 from normanjaeckel/RemoveDjangoUrlPatternsView

Removed viewpoint for Django url patterns. Fixed #1453.
This commit is contained in:
Emanuel Schütze 2016-12-16 19:12:25 +01:00 committed by GitHub
commit 4a4f5622f4
4 changed files with 0 additions and 75 deletions

View File

@ -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',

View File

@ -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'),

View File

@ -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.

View File

@ -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):