~netlandish/django-wiki

07561c1782b0c169ccf10a98d17981935826a3d3 — Mads Jensen 5 years ago fd5b421
Various general clean-ups, including templates.
M src/wiki/models/article.py => src/wiki/models/article.py +7 -4
@@ 171,7 171,8 @@ class Article(models.Model):
    def get_for_object(cls, obj):
        return ArticleForObject.objects.get(
            object_id=obj.id,
            content_type=ContentType.objects.get_for_model(obj)).article
            content_type=ContentType.objects.get_for_model(obj),
        ).article

    def __str__(self):
        if self.current_revision:


@@ 193,9 194,11 @@ class Article(models.Model):
            content = preview_content
        else:
            content = self.current_revision.content
        return mark_safe(article_markdown(content, self,
                                          preview=preview_content is not None,
                                          user=user))
        return mark_safe(article_markdown(
            content, self,
            preview=preview_content is not None,
            user=user)
        )

    def get_cache_key(self):
        """Returns per-article cache key."""

M src/wiki/plugins/attachments/forms.py => src/wiki/plugins/attachments/forms.py +3 -8
@@ 133,8 133,7 @@ class AttachmentArchiveForm(AttachmentForm):
                        attachment.articles.add(self.article)
                        attachment_revision = models.AttachmentRevision()
                        attachment_revision.file = f
                        attachment_revision.description = self.cleaned_data[
                            'description']
                        attachment_revision.description = self.cleaned_data['description']
                        attachment_revision.attachment = attachment
                        attachment_revision.set_from_request(self.request)
                        attachment_revision.save()


@@ 153,10 152,8 @@ class AttachmentArchiveForm(AttachmentForm):


class DeleteForm(forms.Form):

    """This form is both used for dereferencing and deleting attachments"""
    confirm = forms.BooleanField(label=_('Yes I am sure...'),
                                 required=False)
    confirm = forms.BooleanField(label=_('Yes I am sure...'), required=False)

    def clean_confirm(self):
        if not self.cleaned_data['confirm']:


@@ 168,7 165,5 @@ class SearchForm(forms.Form):

    query = forms.CharField(
        label="",
        widget=forms.TextInput(
            attrs={
                'class': 'search-query form-control'}),
        widget=forms.TextInput(attrs={'class': 'search-query form-control'}),
    )

M src/wiki/plugins/images/templates/wiki/plugins/images/sidebar.html => src/wiki/plugins/images/templates/wiki/plugins/images/sidebar.html +1 -6
@@ 46,7 46,7 @@ function add_image(form) {
      {% with image.current_revision.imagerevision as revision %}
      {% thumbnail revision.image "50x50" crop="center" as thumb %}
        <tr>
          <td style="white-space: nowrap;">
          <td class="text-nowrap">
            <p>{% trans "Image id" %}: {{ image.id }}</p>
            <p>
              <a href="javascript:void(insert_image({{ image.id }}))"><span class="fa fa-edit"></span> {% trans "Insert" %}</a><br />


@@ 98,11 98,6 @@ function add_image(form) {
  <p>
  {% for field in form.visible_fields %}
    <fieldset id="div_{{ field.auto_id }}" class="control-group fields {% if field.errors %} error{% endif %}">
      {% if field.label %}
        <!--<label for="{{ field.id_for_label }}" class="{% if field.field.required %}requiredField{% endif %}">
        {{ field.label|safe }}
        </label>-->
      {% endif %}
      {{ field }}
      {% if field.errors %}
      <div id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="help-block">

M src/wiki/sites.py => src/wiki/sites.py +0 -1
@@ 7,7 7,6 @@ from wiki.core.plugins import registry


class WikiSite:

    """
    Wiki site configurator.


M src/wiki/templates/wiki/base_site.html => src/wiki/templates/wiki/base_site.html +1 -7
@@ 12,12 12,6 @@
    <link href="{% static "wiki/bootstrap/css/wiki-bootstrap.min.css" %}" rel="stylesheet">

    {% render_block "css" %}

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

  </head>

  <body>


@@ 145,7 139,7 @@
        {% block wiki_footer_prepend %}
        {% endblock %}
        <p>{% blocktrans %}Powered by <a href="http://www.django-wiki.org">django-wiki</a>, an open source application under the <a href="http://www.gnu.org/licenses/quick-guide-gplv3.html">GPLv3</a> license. Let knowledge be the cure.{% endblocktrans %}</p>
        <div style="clear: both"></div>
        <div class="clearfix"></div>
      </footer>
      </div>


M src/wiki/templates/wiki/create_root.html => src/wiki/templates/wiki/create_root.html +3 -1
@@ 32,7 32,9 @@
    <div class="form-group form-actions">
      <div class="col-lg-2"></div>
      <div class="col-lg-10">
        <input type="submit" name="save_changes" value="{% trans "Create root" %} &raquo;" class="btn btn-primary btn-lg" />
        <button type="submit" name="save_changes" class="btn btn-primary btn-lg">
          {% trans "Create root" %} &raquo;
        </button>
      </div>
    </div>
  </form>

M src/wiki/templates/wiki/edit.html => src/wiki/templates/wiki/edit.html +1 -1
@@ 63,7 63,7 @@

</div>

<div style="clear: both"></div>
<div class="clearfix"></div>

{% include "wiki/includes/modals.html" %}


M src/wiki/templates/wiki/history.html => src/wiki/templates/wiki/history.html +1 -1
@@ 95,7 95,7 @@
              {% endif %}

            </div>
            <div style="clear: both"></div>
            <div class="clearfix"></div>
          </div>
          <div id="collapse{{ revision.revision_number }}" class="panel-collapse collapse">
            <div class="panel-body diff-container" style="padding: 0;">

M src/wiki/templates/wiki/includes/breadcrumbs.html => src/wiki/templates/wiki/includes/breadcrumbs.html +1 -1
@@ 56,6 56,6 @@
    </ul>
  </div>
</div>
<div style="clear: both"></div>
<div class="clearfix"></div>
</div>
{% endif %}

M src/wiki/templates/wiki/includes/searchresult.html => src/wiki/templates/wiki/includes/searchresult.html +1 -1
@@ 16,7 16,7 @@
    {% endif %}
    <p class="muted"><small>{{ article.render|get_content_snippet:search_query }}</small></p>
  </td>
  <td style="white-space: nowrap">
  <td class="text-nowrap">
    {{ article.current_revision.created|naturaltime }}
  </td>
</tr>

M src/wiki/views/accounts.py => src/wiki/views/accounts.py +1 -1
@@ 131,7 131,7 @@ class Update(UpdateView):

    def form_valid(self, form):
        pw = form.cleaned_data["password1"]
        if pw is not "":
        if pw != "":
            self.object.set_password(pw)
        self.object.save()


M tests/base.py => tests/base.py +4 -6
@@ 71,8 71,7 @@ class WebTestCommonMixin(RequireBasicData, django_functest.ShortcutLoginMixin):
    def setUp(self):
        super().setUp()

        self.shortcut_login(username=SUPERUSER1_USERNAME,
                            password=SUPERUSER1_PASSWORD)
        self.shortcut_login(username=SUPERUSER1_USERNAME, password=SUPERUSER1_PASSWORD)


class WebTestBase(WebTestCommonMixin, django_functest.FuncWebTestMixin, TestCase):


@@ 88,7 87,7 @@ class SeleniumBase(WebTestCommonMixin, django_functest.FuncSeleniumMixin, Static
    display = os.environ.get('SELENIUM_SHOW_BROWSER', '0') == '1'

    if not INCLUDE_SELENIUM_TESTS:
        # Don't call super() in setUpClass(), it will attempt to instatiate
        # Don't call super() in setUpClass(), it will attempt to instantiate
        # a browser instance which is slow and might fail
        @classmethod
        def setUpClass(cls):


@@ 106,7 105,6 @@ class ArticleWebTestUtils:
        Get the article response for the path.
        Example:  self.get_by_path("Level1/Slug2/").title
        """

        return self.client.get(reverse('wiki:get', kwargs={'path': path}))




@@ 125,11 123,11 @@ class TemplateTestCase(TestCase):
class wiki_override_settings(override_settings):

    def enable(self):
        super(wiki_override_settings, self).enable()
        super().enable()
        self.reload_wiki_settings()

    def disable(self):
        super(wiki_override_settings, self).disable()
        super().disable()
        self.reload_wiki_settings()

    def reload_wiki_settings(self):

M tests/core/test_checks.py => tests/core/test_checks.py +2 -2
@@ 45,10 45,10 @@ class CheckTests(TestCase):

    def test_custom_user_model_mitigation_required(self):
        """
        Django & six check django.forms.ModelForm.Meta on definition, and raises an error if Meta.fields don't exist in Meta.model.
        Django check django.forms.ModelForm.Meta on definition, and raises an error if Meta.fields don't exist in Meta.model.
        This causes problems in wiki.forms.UserCreationForm and wiki.forms.UserUpdateForm when a custom user model doesn't have fields django-wiki assumes.
        There is some code in wiki.forms that detects this situation.
        This check asserts that Django/six are still raising an exception on definition, and asserts the mitigation code in wiki.forms,
        This check asserts that Django are still raising an exception on definition, and asserts the mitigation code in wiki.forms,
        and that test_check_for_fields_in_custom_user_model below are required.
        """
        from django.core.exceptions import FieldError

M tests/core/test_views.py => tests/core/test_views.py +1 -1
@@ 27,7 27,7 @@ class RootArticleViewTestsBase(FuncBaseMixin):
            '#id_content': 'test heading h1\n====\n',
            '#id_title': 'Wiki Test',
        })
        self.submit('input[name="save_changes"]')
        self.submit('button[name="save_changes"]')
        self.assertUrlsEqual('/')
        self.assertTextPresent('test heading h1')
        article = URLPath.root().article