widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #09419
[Merge] lp:~widelands-dev/widelands-website/post_django1_8_cleanup into lp:widelands-website
kaputtnik has proposed merging lp:~widelands-dev/widelands-website/post_django1_8_cleanup into lp:widelands-website.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/post_django1_8_cleanup/+merge/315301
Some cleanups...
- Removed some superfluous files
- Removed some commented code
- Cleanup setup.py regarding the update to django1.8
- Formerly i assumed 'NOCOM' has the meaning of 'NoComment', so i changed the remaining ones into TODOs
- Adjusted the README to reflect the changes regarding http://bazaar.launchpad.net/~widelands-dev/widelands-website/trunk/revision/432 "Reactivating AutoOneToOneField"
- Use os.path.join in local_settings.py to get a clean path
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/post_django1_8_cleanup into lp:widelands-website.
=== modified file 'README.txt'
--- README.txt 2016-09-04 11:16:02 +0000
+++ README.txt 2017-01-21 20:06:44 +0000
@@ -93,11 +93,9 @@
^^^^^^^^^^^^^^^^^^^^^^^
Go to http://localhost:8000/admin. Log in with your super user and go to the
-following tables:
+following table:
- Site/Sites: Change your site name from example.com to localhost:8000.
-- Wlprofile/Profiles: Add yourself as a user
-- Wlggz/Ggz: Add yourself as a user
Now everything should work.
=== modified file 'local_settings.py.sample'
--- local_settings.py.sample 2016-12-10 12:18:48 +0000
+++ local_settings.py.sample 2017-01-21 20:06:44 +0000
@@ -3,8 +3,8 @@
bd = os.getcwd() # Better make this a static path
-STATIC_MEDIA_PATH = bd + '/media'
-MEDIA_ROOT = bd + '/media/'
+STATIC_MEDIA_PATH = os.path.join(bd, 'media')
+MEDIA_ROOT = os.path.join(bd, 'media/')
WIDELANDS_SVN_DIR = "/path/to/widelands/trunk/"
DATABASES = {
=== modified file 'mainpage/templatetags/wl_markdown.py'
--- mainpage/templatetags/wl_markdown.py 2016-12-13 18:28:51 +0000
+++ mainpage/templatetags/wl_markdown.py 2017-01-21 20:06:44 +0000
@@ -37,7 +37,7 @@
# We will also need the site domain
from django.contrib.sites.models import Site
from settings import SITE_ID, SMILEYS, SMILEY_DIR, \
- SMILEY_PREESCAPING, BZR_URL
+ SMILEY_PREESCAPING
try:
_domain = Site.objects.get(pk=SITE_ID).domain
@@ -79,18 +79,6 @@
return text
-revisions_re = [
- re.compile('bzr:r(\d+)'),
-]
-
-
-def _insert_revision(text):
- for r in revisions_re:
- text = r.sub( lambda m: """<a href="%s">r%s</a>""" % (
- settings.BZR_URL % m.group(1), m.group(1)), text)
- return text
-
-
def _classify_link(tag):
"""Returns a classname to insert if this link is in any way special
(external or missing wikipages)
@@ -206,8 +194,7 @@
# went over it General consensus is to avoid replacing anything in
# links [blah](blkf)
if custom:
- # Replace bzr revisions
- rv = _insert_revision(text)
+ rv = text
# Replace smileys; only outside "code-tags"
if not text.parent.name == 'code':
rv = _insert_smileys(rv)
=== modified file 'pip_requirements.txt'
--- pip_requirements.txt 2016-07-20 09:06:47 +0000
+++ pip_requirements.txt 2017-01-21 20:06:44 +0000
@@ -20,11 +20,8 @@
Pygments==2.1.3
pyparsing==2.1.4
six==1.10.0
-#franku: sphinxdoc is now included in wl
-#django-sphinxdoc==0.3.2
Sphinx==1.4.5
untokenize==0.1.1
-#-e git://github.com/kerin/django-sphinx.git/@1c5ef8abcf86f9a9458f763ceb9e5d882247ea37#egg=djangosphinx
-e git://github.com/kerin/django-sphinx.git#egg=django-sphinx
bleach==1.4.3
=== modified file 'pybb/forms.py'
--- pybb/forms.py 2016-12-13 18:28:51 +0000
+++ pybb/forms.py 2017-01-21 20:06:44 +0000
@@ -21,7 +21,7 @@
class Meta:
model = Post
- # Listing fields again to get the the right order; See also the NOCOMM
+ # Listing fields again to get the the right order; See also the TODO
fields = ['name', 'body', 'markup', 'attachment', ]
def __init__(self, *args, **kwargs):
@@ -31,7 +31,7 @@
self.ip = kwargs.pop('ip', None)
super(AddPostForm, self).__init__(*args, **kwargs)
- # NOCOMM: This doesn't work anymore with django 1.8 Use 'field_order'
+ # TODO (Franku): This doesn't work anymore with django 1.8 Use 'field_order'
# with django 1.9
self.fields.keyOrder = ['name',
'body',
@@ -65,7 +65,7 @@
topic = self.topic
# Check for spam and hide the post
- # TODO: This is currently a simple keyword search. Maybe add akismet check here
+ # TODO (Franku): This is currently a simple keyword search. Maybe add akismet check here
# could be improved...
# The admins get informed of hidden post(s) over
# a Django command. See pybb/management/commands
=== modified file 'pybb/util.py'
--- pybb/util.py 2016-12-13 18:28:51 +0000
+++ pybb/util.py 2017-01-21 20:06:44 +0000
@@ -34,7 +34,7 @@
return output
kwargs = {'context_instance': RequestContext(request)}
- # NOCOMM: 'MIME_TYPE' is never in output as i can see for now.
+ # TODO (Franku): 'MIME_TYPE' is never in output as i can see for now.
# But if, this should maybe 'content_type' instead
if 'MIME_TYPE' in output:
kwargs['mimetype'] = output.pop('MIME_TYPE')
@@ -126,7 +126,7 @@
class JsonResponse(HttpResponse):
"""HttpResponse subclass that serialize data into JSON format."""
- # NOCOMM: The mimetype argument maybe must be replaced with content_type
+ # TODO (Franku): The mimetype argument maybe must be replaced with content_type
def __init__(self, data, mimetype='application/json'):
json_data = LazyJSONEncoder().encode(data)
@@ -239,7 +239,7 @@
return page, paginator
-# NOCOMM: This function is never used AFAIK
+# TODO (Franku): This function is never used AFAIK
# 'django_language' isn't available since django 1.8
def set_language(request, language):
"""Change the language of session of authenticated user."""
=== modified file 'settings.py'
--- settings.py 2016-12-15 12:55:44 +0000
+++ settings.py 2017-01-21 20:06:44 +0000
@@ -77,7 +77,6 @@
'django.contrib.sites',
'django.contrib.humanize',
'django.contrib.sitemaps',
- 'django_comments',
'nocaptcha_recaptcha',
# Thirdparty apps, but need preload
'tracking', # included as wlapp
@@ -106,16 +105,13 @@
'threadedcomments', # included as wlapp
'notification', # included as wlapp
'django_messages',
- #'pagination',
'linaro_django_pagination',
'tagging',
'djangoratings', # included as wlapp
'sphinxdoc', # included as wlapp
- #'south', included in django itself
)
MIDDLEWARE_CLASSES = (
- # 'simplestats.middleware.RegexLoggingMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
@@ -127,7 +123,6 @@
# Remove this, when load gets to high or attachments are enabled
'django.middleware.gzip.GZipMiddleware',
- #'pagination.middleware.PaginationMiddleware',
'linaro_django_pagination.middleware.PaginationMiddleware',
'tracking.middleware.VisitorTrackingMiddleware',
'tracking.middleware.VisitorCleanUpMiddleware',
@@ -175,10 +170,7 @@
######################
# User configuration #
######################
-# AUTH_PROFILE_MODULE = 'wlprofile.Profile' # NOCOMM: This is not longer used anymore, see:
-# https://docs.djangoproject.com/en/1.8/releases/1.5/#auth-profile-module
-
-DEFAULT_TIME_ZONE = 3
+DEFAULT_TIME_ZONE = 3 # See wlprofile.templatetags.custom_date
DEFAULT_TIME_DISPLAY = r"%ND(Y-m-d,) H:i" # According to ISO 8601
DEFAULT_MARKUP = 'markdown'
SIGNATURE_MAX_LENGTH = 255
@@ -269,14 +261,6 @@
# or for ChangeLog displays
WIDELANDS_SVN_DIR = ''
-#####################
-# ChangeLog display #
-#####################
-# NOCOMM franku: This is only used in mainpage/wl_markdown/templatetags/wl_markdon.py/_insert_revision()
-# Since there is a plan to have only some prosa in the Changelog, both (this setting and the function)
-# could be removed. It didn't worked either...
-BZR_URL = r'http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/revision/%s'
-
###############
# Screenshots #
###############
=== modified file 'templates/pybb/inlines/forum_row.html'
--- templates/pybb/inlines/forum_row.html 2016-03-02 21:02:38 +0000
+++ templates/pybb/inlines/forum_row.html 2017-01-21 20:06:44 +0000
@@ -17,8 +17,6 @@
<div class="index_forum">
<span class="item">
<a href="{{ forum.get_absolute_url }}">{{ forum.name }}</a>
- {# TODO: RSS feeds #}
- {# (<a href="http://xoops.widelands.org/modules/newbb/rss.php?f=2" target="_blank" title="RSS feed">RSS</a>) #}
<br />
{{ forum.description }}
</span>
=== modified file 'templates/threadedcomments/inlines/reply_to.js'
--- templates/threadedcomments/inlines/reply_to.js 2016-05-15 14:41:54 +0000
+++ templates/threadedcomments/inlines/reply_to.js 2017-01-21 20:06:44 +0000
@@ -23,9 +23,6 @@
+ '<td class="text">'
+ '<form method="POST" action="' + url + '?next={{object.get_absolute_url}}">'
+ '<span class="errormessage">{{ form.comment.errors }}</span>'
- /* NOCOMM franku: i don't know the reason why this do not work anymore
- I just replaced it with the next line
- + '{{ form.comment }}'*/
+ '<textarea cols="40" id="id_comment" maxlength="1000" name="comment" rows="10"></textarea>'
+ '<br />'
+ '<input type="hidden" name="markup" value="1" />'
=== modified file 'threadedcomments/templatetags/threadedcommentstags.py'
--- threadedcomments/templatetags/threadedcommentstags.py 2016-12-13 18:28:51 +0000
+++ threadedcomments/templatetags/threadedcommentstags.py 2017-01-21 20:06:44 +0000
@@ -136,34 +136,12 @@
def auto_transform_markup(comment):
"""Given a comment (``ThreadedComment`` or ``FreeThreadedComment``), this
- tag looks up the markup type of the comment and formats the output
- accordingly.
-
- It can also output the formatted content to a context variable, if a
- context name is specified.
+ tag simply returns the commetn after wl_markdown runs over it.
"""
- # NOCOMM franku: django.contrib.markup doesn't exist anymore
- try:
- from django.utils.html import escape
- from threadedcomments.models import MARKDOWN, TEXTILE, REST, PLAINTEXT
- if comment.markup == MARKDOWN:
- from django.contrib.markup.templatetags.markup import markdown
- return markdown(comment.comment)
- elif comment.markup == TEXTILE:
- from django.contrib.markup.templatetags.markup import textile
- return textile(comment.comment)
- elif comment.markup == REST:
- from django.contrib.markup.templatetags.markup import restructuredtext
- return restructuredtext(comment.comment)
-# elif comment.markup == HTML:
-# return mark_safe(force_unicode(comment.comment))
- elif comment.markup == PLAINTEXT:
- return escape(comment.comment)
- except ImportError:
- # Not marking safe, in case tag fails and users input malicious code.
- # NOCOMM franku: bleach the comment
- return do_wl_markdown(comment.comment, 'bleachit')
+
+ # Franku: bleach the comment
+ return do_wl_markdown(comment.comment, 'bleachit')
def do_auto_transform_markup(parser, token):
=== removed file 'update_problems.txt'
--- update_problems.txt 2016-06-13 07:14:59 +0000
+++ update_problems.txt 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
-##################
- Modules/apps
-##################
-
-# South:
- South is now integrated into django, see
- http://south.readthedocs.org/en/latest/releasenotes/1.0.html#library-migration-path
-
- An upgrading from old south migrations to django is decribed here:
- https://docs.djangoproject.com/en/1.9/topics/migrations/#upgrading-from-south
-
- Should be easy. I tested this with mysql and a copy from wl_alpha ... it works
-
- Original migration:
- http://bazaar.launchpad.net/~widelands-dev/widelands-website/trunk/revision/323#pybb/migrations/0001_initial.py
- http://bazaar.launchpad.net/~widelands-dev/widelands-website/trunk/revision/323#pybb/migrations/0002_auto__del_field_topic_post_count.py
-
-# Django-ratings
- django-ratings is no longer maintained; see
- https://github.com/dcramer/django-ratings
-
- django-ratings is currently used only in wlmaps.
-
- Old app included as widelands app (including adjustments to django 1.8)
-
-# Django-notifications
- Old app included as widelands app (including adjustments to django 1.8)
-
-# threadedcomments
- Old app included as widelands app (including adjustments to django 1.8)
-
-# Django-tracking
- The original django-tracking is disowned, see http://www.codekoala.com/posts/django-projects/
- User bashu has adopt it, see: https://github.com/bashu/django-tracking
- But it looks not really maintained.
-
- Old app included as widelands app (including adjustments to django 1.8)
-
-# django-sphinx (sphinxdoc)
- Not longer maintained, see: https://github.com/dcramer/django-sphinx
-
- This is used for the search. An alternative is maybe django-sphinxdoc in combination with
- haystack (dependencie of django-sphinxdoc).
-
- Old app included as widelands app (including adjustments to django 1.8)
-
-########################
-Settings and other stuff
-########################
-
-# User model
- The current setting in settings.py:
-
- AUTH_PROFILE_MODULE = 'wlprofile.Profile'
-
- Has been removed in Django 1.7. I am not sure how to handle this change at the moment.
- See also Database_affected_changes.txt
-
- Found a solution for get_profile() but i am unsure with the AUTH_PROFILE_SETTING.
-
-# Sorting of fields in Forms
- The old 'keyOrder = ["fields"]' isn't available in Django 1.8
- In Django 1.9 a new function 'order_keys' get's implemented.
- Until then it is possible to order the fields in class Meta:
- f.e.: fields = ['name','body', 'markup', 'attachment',]
-
-##########################
- Warnings for Django 1.9
-##########################
-
-/wl_django1_8/lib/python2.7/site-packages/django/core/handlers/wsgi.py:126: RemovedInDjango19Warning: `MergeDict` is deprecated, use `dict.update()` instead.
- self._request = datastructures.MergeDict(self.POST, self.GET)
-
-/wl_django1_8/lib/python2.7/site-packages/django_messages/urls.py:7: RemovedInDjango19Warning: Default value of 'RedirectView.permanent' will change from True to False in Django 1.9. Set an explicit value to silence this warning.
- url(r'^$', RedirectView.as_view(url='inbox/'), name='messages_redirect'),
\ No newline at end of file
=== removed file 'widelandslib/map.py'
--- widelandslib/map.py 2016-12-13 18:28:51 +0000
+++ widelandslib/map.py 1970-01-01 00:00:00 +0000
@@ -1,301 +0,0 @@
-#!/usr/bin/env python -tt
-# encoding: utf-8
-#
-
-from PIL import Image
-from cStringIO import StringIO
-from conf import WidelandsConfigParser as Cp, NoOptionError, NoSectionError
-from numpy import fromstring, array, empty, gradient
-import numpy
-import os
-import struct
-import zipfile
-
-
-class Terrain(object):
-
- def __init__(self, name, id):
- self._id = id
- self._name = name
-
- @property
- def name(self):
- return self._name
-
- @property
- def animation(self):
- return self._animation
-
- @property
- def id(self):
- return self._id
-
- def __repr__(self):
- return self._name
-
-
-###########################################################################
-# ERRORS #
-###########################################################################
-class WlMapLibraryException(Exception):
- pass
-
-
-class InvalidMapPackage(WlMapLibraryException):
-
- def __init__(self, package_name, error):
- self.pn = package_name
- self.error = error
-
- def __str__(self):
- return 'Error reading package %s: %s' % (self.pn, self.error)
-
-
-class WlInvalidFile(WlMapLibraryException):
- pass
-
-
-class WidelandsMap(object):
- """This class parses a widelands map file as long as it is a directory (not
- a zip file)."""
-
- def __init__(self, fn=None):
- if fn is not None:
- self.load(fn)
-
-#############
-# FUNCTIONS #
-#############
- def load(self, fn):
- """Load a map from the given directory or zipfile.
-
- fn - path to directory or zipfile or a file handle to the opened zipfile
-
- """
-
- if isinstance(fn, str) and os.path.isdir(fn):
- basedir = fn + '/'
- self._is_zip = False
- open_file = open
- else:
- self._is_zip = True
- try:
- zf = zipfile.ZipFile(fn)
- except zipfile.BadZipfile:
- raise WlInvalidFile()
-
- # Try to find elemental packet
- elementals = [i.filename for i in zf.filelist if
- i.filename.find('elemental') != -1 and
- i.filename.find('.svn') == -1]
-
- if len(elementals) != 1:
- # Try to use the one called 'elemental'
- elementals = [
- e for e in elementals if os.path.basename(e) == 'elemental']
- if len(elementals) != 1:
- raise WlInvalidFile(
- 'Map contains an invalid number of elemental packets')
- el = elementals[0].rsplit('/')
- if len(el) == 1:
- basedir = ''
- else:
- basedir = el[0] + '/'
-
- open_file = lambda fn, mode: StringIO(zf.read(fn))
-
- # Okay, try to read our files
- self._read_elemental(open_file(basedir + 'elemental', 'r'))
- self._read_heights(open_file(basedir + 'binary/heights', 'rb'))
- self._read_terrains(open_file(basedir + 'binary/terrain', 'rb'))
-
-##############
-# Properties #
-##############
- @property
- def dim(self):
- """Map dimensions (h,w).
-
- Not: height first! like in numpy
-
- """
- return self._dim
-
- @property
- def w(self):
- return self._dim[1]
-
- @property
- def h(self):
- return self._dim[0]
-
- @property
- def nr_players(self):
- """Nr of players."""
- return self._nr_players
-
- @property
- def world_name(self):
- """Name of world."""
- return self._world_name
-
- @property
- def name(self):
- """Name of map."""
- return self._name
-
- @property
- def author(self):
- """The maps creator."""
- return self._author
-
- @property
- def descr(self):
- """The maps description."""
- return self._descr
-
- @property
- def heights(self):
- 'The heights of the various fields, an 2d array: a[y,x]'
- return self._heights
-
- @property
- def ter_r(self):
- """The RO foo property."""
- return self._terr
-
- @property
- def ter_d(self):
- """The RO foo property."""
- return self._terd
-
- @property
- def terrains(self):
- """The RO foo property."""
- return self._terrains
-
-
-###########################################################################
-# PRIVATE PARSING FUNCTIONALITY BELOW #
-###########################################################################
- def _read_elemental(self, file):
- def error(m):
- raise InvalidMapPackage('elemental', m)
- cp = Cp(file)
-
- try:
- version = cp.getint('global', 'packet_version')
- if version != 1:
- error('Invalid package version: %i' % version)
-
- self._dim = cp.getint(
- 'global', 'map_h'), cp.getint('global', 'map_w')
- self._nr_players = cp.getint('global', 'nr_players')
- self._world_name = cp.getstring('global', 'world')
- self._name = cp.getstring('global', 'name')
- self._author = cp.getstring('global', 'author')
- self._descr = cp.getstring('global', 'descr')
- except NoOptionError, e:
- error('Missing option: %s:%s' % (e.section, e.option))
- except NoSectionError, e:
- error('Missing section: %s' % (e.section,))
-
- # TODO: background picture
-
- def _read_heights(self, file):
- def error(m):
- raise InvalidMapPackage('heights', m)
- s = file.read()
- version, = struct.unpack_from('<H', s)
- if version != 1:
- error('Invalid package version: %i' % version)
- if len(s) != self._dim[0] * self._dim[1] + 2:
- error('Package has wrong length.')
- self._heights = fromstring(s[2:], dtype='u1').reshape(self._dim)
-
- def _read_terrains(self, file):
- def error(m):
- raise InvalidMapPackage('terrain', m)
- s = file.read()
- version, = struct.unpack_from('<H', s)
- if version != 1:
- error('Invalid package version: %i' % version)
-
- try:
- nrterrains, = struct.unpack_from('<H', s, 2)
- except struct.error:
- error('Package has wrong length.')
-
- terrains = [None] * nrterrains
- nread = 4
- for i in range(nrterrains):
- try:
- tid, = struct.unpack_from('<H', s, nread)
- except struct.error:
- error('Package has wrong length.')
- if tid >= nrterrains:
- error('Invalid terrain id in package-header')
-
- nread += 2
- name = s[nread:s.find('\x00', nread)]
- nread += len(name) + 1
-
- terrains[tid] = Terrain(name, tid)
-
- self._terrains = terrains
- a = fromstring(s[nread:], dtype='u1')
-
- if len(a) != self._dim[0] * self._dim[1] * 2:
- error('Package has wrong length.')
-
- try:
- self._terr = numpy.empty(
- self._dim[0] * self._dim[1], dtype='object')
- self._terr[:] = [terrains[o] for o in a[::2]]
- self._terr.shape = self._dim
- self._terd = numpy.empty(
- self._dim[0] * self._dim[1], dtype='object')
- self._terd[:] = [terrains[o] for o in a[1::2]]
- self._terd.shape = self._dim
- except IndexError:
- error('Invalid terrain index in package.')
-
- def make_minimap(self, datadir):
- """Returns an RGB minimap of the map.
-
- datadir - Path to widelands directory so that the texture can be read
-
- """
- # Read the terrains
- colors = [None] * len(self._terrains)
- for t in self._terrains:
- i = Image.open(datadir + '/worlds/' + self._world_name +
- '/pics/' + t.name + '_00.png').convert('RGB')
- i = fromstring(i.tostring(), dtype='uint8').reshape((64, 64, 3))
- colors[t.id] = i.mean(axis=0).mean(axis=0)
-
- # Make the minimap
- mm = empty((self._dim) + (3,), dtype='uint8')
- for y in range(self._dim[0]):
- for x in range(self._dim[1]):
- t = self._terr[y, x]
- mm[y, x] = colors[t.id]
-
- # Now, add the heights
- rubbish, dx = gradient(self._heights.astype('float64'))
- dx -= dx.min()
- if dx.max():
- dx /= dx.max()
- dx *= 255.
- rdx = empty((self._dim) + (3,), dtype='float64')
- rdx[:, :, 0] = dx
- rdx[:, :, 1] = dx
- rdx[:, :, 2] = dx
- dx = rdx
-
- # This is taken from the gimps overlay functionality
- # see here:
- # http://docs.gimp.org/en/gimp-concepts-layer-modes.html
- mm = mm / 255. * (mm + 2 * dx / 255. * (255. - mm))
-
- return mm.astype('uint8')
=== removed file 'wiki/templatetags/wikiurl.py.delete'
--- wiki/templatetags/wikiurl.py.delete 2016-04-26 16:10:04 +0000
+++ wiki/templatetags/wikiurl.py.delete 1970-01-01 00:00:00 +0000
@@ -1,118 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from django.template import Node, Library, TemplateSyntaxError
-from django.core.urlresolvers import reverse, NoReverseMatch
-
-register = Library()
-
-class WikiURLNode(Node):
- def __init__(self, url_name, group,
- article=None, revision=None, asvar=None):
- self.url_name = 'wiki_' + url_name
- self.group = group
- self.article = article
- self.revision = revision
- self.asvar = asvar
-
- def resolve(self, attrname, context):
- attr = getattr(self, attrname)
- if attr is None:
- return
- return attr.resolve(context)
-
- def render(self, context):
- group = self.resolve('group', context)
- article = self.resolve('article', context)
- revision = self.resolve('revision', context)
-
- kw = {'group_slug': group.slug}
- if article is not None:
- kw['title'] = article.title
- if revision is not None:
- kw['revision'] = revision
-
- app = group._meta.app_label
- urlconf = '.'.join([app, 'urls'])
-
- url = ''
- try:
- url_bits = ['/', app, reverse(self.url_name, urlconf, kwargs=kw)]
- url = ''.join(url_bits) # @@@ hardcoding /app_name/wiki_url/
- except NoReverseMatch, err:
- if self.asvar is None:
- raise
-
- if self.asvar is not None:
- context[self.asvar] = url
- return ''
- else:
- return url
-
-def wikiurl(parser, token):
- """
- Returns an absolute URL matching given url name with its parameters,
- given the articles group and (optional) article and revision number.
-
- This is a way to define links that aren't tied to our URL configuration::
-
- {% wikiurl edit group article %}
-
- The first argument is a url name, without the ``wiki_`` prefix.
-
- For example if you have a view ``app_name.client`` taking client's id and
- the corresponding line in a URLconf looks like this::
-
- url('^edit/(\w+)/$', 'wiki.edit_article', name='wiki_edit')
-
- and this app's URLconf is included into the project's URLconf under some
- path::
-
- url('^groups/(?P<group_slug>\w+)/mywiki/', include('wiki.urls'), kwargs)
-
- then in a template you can create a link to edit a certain article like this::
-
- {% wikiurl edit group article %}
-
- The URL will look like ``groups/some_group/mywiki/edit/WikiWord/``.
-
- This tag is also able to set a context variable instead of returning the
- found URL by specifying it with the 'as' keyword::
-
- {% wikiurl edit group article as wiki_article_url %}
-
- """
- bits = token.contents.split(' ')
- kwargs = {}
- if len(bits) == 3: # {% wikiurl url_name group %}
- url_name = bits[1]
- group = parser.compile_filter(bits[2])
- elif len(bits) == 4: # {% wikiurl url_name group article %}
- url_name = bits[1]
- group = parser.compile_filter(bits[2])
- kwargs['article'] = parser.compile_filter(bits[3])
- elif len(bits) == 5: # {% wikiurl url_name group as var %} or {% wikiurl url_name group article revision %}
- url_name = bits[1]
- group = parser.compile_filter(bits[2])
- if bits[3] == "as":
- kwargs['asvar'] = bits[4]
- else:
- kwargs['article'] = parser.compile_filter(bits[3])
- kwargs['revision'] = parser.compile_filter(bits[4])
- elif len(bits) == 6: # {% wikiurl url_name group article as var %}
- if bits[4] == "as":
- raise TemplateSyntaxError("4th argument to %s should be 'as'" % bits[0])
- url_name = bits[1]
- group = parser.compile_filter(bits[2])
- kwargs['article'] = parser.compile_filter(bits[3])
- kwargs['asvar'] = parser.compile_filter(bits[5])
- elif len(bits) == 7: # {% wikiurl url_name group article revision as var %}
- url_name = bits[1]
- group = parser.compile_filter(bits[2])
- kwargs['article'] = parser.compile_filter(bits[3])
- kwargs['revision'] = parser.compile_filter(bits[4])
- kwargs['asvar'] = parser.compile_filter(bits[6])
- else:
- raise TemplateSyntaxError("wrong number of arguments to %s" % bits[0])
- return WikiURLNode(url_name, group, **kwargs)
-
-wikiurl = register.tag(wikiurl)
=== modified file 'wiki/views.py'
--- wiki/views.py 2017-01-18 20:19:12 +0000
+++ wiki/views.py 2017-01-21 20:06:44 +0000
@@ -65,15 +65,13 @@
url = reverse(urlname, urlconf, kwargs=kw)
return ''.join(['/', app, url]) # @@@ harcoded: /app/.../
-# NOCOMM Franku: This Class is currently not used
-# If we want this it has to be checked for the changes
-# related to django 1.8.
-# A javascript alert box is maybe a better solution
-
class ArticleEditLock(object):
"""A soft lock to edting an article."""
-
+ # TODO (Franku): This Class is currently not used
+ # If we want this it has to be checked for the changes
+ # related to django 1.8.
+ # A javascript alert box is maybe a better solution
def __init__(self, title, request, message_template=None):
self.title = title
self.user_ip = get_real_ip(request)
@@ -292,7 +290,7 @@
elif request.method == 'GET':
user_ip = get_real_ip(request)
- # NOCOMM FrankU: Never worked IMHO
+ # TODO (Franku): Never worked IMHO
# lock = cache.get(title, None)
# if lock is None:
# lock = ArticleEditLock(title, request)
=== modified file 'wlmaps/tests/test_views.py'
--- wlmaps/tests/test_views.py 2016-12-13 18:28:51 +0000
+++ wlmaps/tests/test_views.py 2017-01-21 20:06:44 +0000
@@ -5,7 +5,7 @@
from django.test import TestCase as DjangoTest, Client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
-# NOCOMM: Not used, but should be replaced with python json because it gets removed in django 1.7
+# TODO (Franku): Not used, but should be replaced with python json because it gets removed in django 1.7
#from django.utils import simplejson as json
from wlmaps.models import *
=== modified file 'wlpoll/models.py'
--- wlpoll/models.py 2016-12-13 18:28:51 +0000
+++ wlpoll/models.py 2017-01-21 20:06:44 +0000
@@ -2,13 +2,8 @@
from django.contrib.auth.models import User
import datetime
-# lambda couldn't be used in field default and for python2 it must be declared
-# in module body
-# NOCOMM franku: The lambda won't work; why not return the result?
-
def closed_date_default():
- # return lambda: datetime.datetime.now() + datetime.timedelta(days=90)
return datetime.datetime.now() + datetime.timedelta(days=90)
Follow ups