widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #09367
Re: [Merge] lp:~widelands-dev/widelands-website/bug-1399461_error_on_renaming_article into lp:widelands-website
Linguistic proofreading done.
Diff comments:
>
> === added file 'templates/wiki/backlinks.html'
> --- templates/wiki/backlinks.html 1970-01-01 00:00:00 +0000
> +++ templates/wiki/backlinks.html 2017-01-15 12:03:32 +0000
> @@ -0,0 +1,38 @@
> +{% extends 'wiki/base.html' %}
> +{% load wiki_extras %}
> +{% load i18n %}
> +{% block title %}
> +{{ name }} - Backlinks - {{block.super}}
> +{% endblock %}
> +
> +{% block content %}
> +<div class="posRight small">
> + <a class="invertedColor" href="{% url 'wiki_article' name %}">Back to article</a>
> +</div>
> +<h1>{% trans "Backlinks of " %} {{ name }}</h1>
> +<div class="blogEntry">
> + {% if found_links or found_old_links %}
> + {% if found_links %}
> + <h3>Following pages have link(s) which points to this article:</h3>
The following pages have link(s) which point to this article:
> + <ul>
> + {% for article in found_links %}
> + <li><a href="{% url 'wiki_article' article.title %}">{{ article.title }}</a></li>
> + {% endfor %}
> + </ul>
> + {% endif %}
> + {% if found_old_links %}
> + <h3> Following articles have links which points to one of the old name(s) of this article (redirects):</h3>
<h3>The following articles have links which point to one of the old name(s) of this article (redirects):</h3>
> + <ul>
> + {% for article in found_old_links %}
> + <li><a href="{% url 'wiki_article' article.title %}">{{ article.title }}</a>
> + (has at least one link to: "{{ article.old_title }}")</li>
> + {% endfor %}
> + </ul>
> + {% endif %}
> + {% else %}
> + <p><span class="errormessage">Every Wikipage must at least be linked from within another page.</span>
Every Wikipage must be linked from at least one other page.
> + Please link it <img src="/wlmedia/img/smileys/face-smile.png" alt="face-smile.png"> See <a href="/wiki/WikiSyntax/#links">Wiki Syntax</a> for explanations.</p></p>
explanations -> help?
> + {% endif %}
> +</div>
> +{% endblock %}
> +
>
> === modified file 'wiki/forms.py'
> --- wiki/forms.py 2016-12-13 18:28:51 +0000
> +++ wiki/forms.py 2017-01-15 12:03:32 +0000
> @@ -34,11 +34,31 @@
> 'group', 'created_at', 'last_update')
>
> def clean_title(self):
> - """Page title must be a WikiWord."""
> + """Check for some errors regarding the title:
> +
> + 1. Check for bad characters
> + 2. Check for already used titles
> +
> + Immediately trying to change the title of a new article to an existing title
> + is handled on Database level.
... on the database level.
> +
> + """
> +
> title = self.cleaned_data['title']
> if not wikiword_pattern.match(title):
> - raise forms.ValidationError(_('Must be a WikiWord.'))
> -
> + raise forms.ValidationError(
> + _('The title can only consist of alphanumeric characters the underscore and a blank space'))
Only alphanumeric characters, blank spaces and the underscore are allowed in a title.
> +
> + # 'self.initial' contains the prefilled values of the form
> + pre_title = self.initial.get('title', None)
> + if pre_title != title or not pre_title:
> + # Check if the new name once has been used
# Check if the new name has been used already
> + cs = ChangeSet.objects.filter(old_title=title)
> + if cs:
> + raise forms.ValidationError(
> + _('The title %(title)s is already in use, maybe an other article had once this name.'), params={'title': title},)
The title %(title)s is already in use, maybe another article used to have this name.
> +
> + # title not changed, no errors
> return title
>
> def clean(self):
>
> === modified file 'wiki/views.py'
> --- wiki/views.py 2016-12-13 18:28:51 +0000
> +++ wiki/views.py 2017-01-15 12:03:32 +0000
> @@ -478,18 +475,23 @@
>
> article = get_object_or_404(article_qs, **article_args)
>
> - if request.user.is_authenticated():
> - article.revert_to(revision, get_real_ip(request), request.user)
> - else:
> - article.revert_to(revision, get_real_ip(request))
> -
> - # NOCOMM Franku: This has never worked as i know and is IMHO
> - # useless. If we want this it has to be fixed for django 1.8
> - # See comment in edit_article()
> - # if request.user.is_authenticated():
> - # request.user.message_set.create(
> - # message=u"The article was reverted successfully.")
> -
> +
> + # Check whether there is another Article with the same name to which this article
> + # want's to be reverted to. If so: prevent it and show a message.
wants
's is used for genitive only ;)
> + old_title = article.changeset_set.filter(
> + revision=revision+1).get().old_title
> + try:
> + art = Article.objects.exclude(pk=article.pk).get(title=old_title)
> + except Article.DoesNotExist:
> + # No existing article found -> reverting possible
> + if request.user.is_authenticated():
> + article.revert_to(revision, get_real_ip(request), request.user)
> + else:
> + article.revert_to(revision, get_real_ip(request))
> + return redirect(article)
> + # An article with this name exists
> + messages.error(
> + request, 'Reverting not possible because an article with name \'%s\' already exists' % old_title)
> return redirect(article)
>
> return HttpResponseNotAllowed(['POST'])
--
https://code.launchpad.net/~widelands-dev/widelands-website/bug-1399461_error_on_renaming_article/+merge/314033
Your team Widelands Developers is subscribed to branch lp:widelands-website.
References