Compare commits
No commits in common. "master" and "hotjazz" have entirely different histories.
18
.travis.yml
18
.travis.yml
@ -1,18 +0,0 @@
|
||||
language: python
|
||||
python:
|
||||
- "2.6"
|
||||
- "2.7"
|
||||
- "3.3"
|
||||
env:
|
||||
- DJANGO_PACKAGE="Django<1.5"
|
||||
- DJANGO_PACKAGE="Django>=1.5,<1.6"
|
||||
- DJANGO_PACKAGE="Django>=1.6,<1.7"
|
||||
install: pip install $DJANGO_PACKAGE markdown docutils django-markupfield --use-mirrors
|
||||
script: django-admin.py test --settings=example.settings --pythonpath=.
|
||||
matrix:
|
||||
exclude:
|
||||
- python: "3.3"
|
||||
env: DJANGO_PACKAGE="Django<1.5"
|
||||
notifications:
|
||||
email:
|
||||
- james.p.turk@gmail.com
|
@ -1,12 +1,7 @@
|
||||
0.3.0
|
||||
=====
|
||||
- lots of tests
|
||||
- new escape_html option
|
||||
- csrf token
|
||||
- autolockarticles management command
|
||||
- null editors
|
||||
- fix revert
|
||||
|
||||
-
|
||||
|
||||
0.2.0
|
||||
===================
|
||||
|
@ -1,5 +1,3 @@
|
||||
import os
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
@ -29,7 +27,7 @@ MIDDLEWARE_CLASSES = (
|
||||
|
||||
ROOT_URLCONF = 'example.urls'
|
||||
|
||||
TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates'), )
|
||||
TEMPLATE_DIRS = ( 'templates', )
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.auth',
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.conf.urls import *
|
||||
from django.conf.urls.defaults import *
|
||||
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
# from django.contrib import admin
|
||||
|
@ -34,9 +34,9 @@ ARTICLE_STATUSES = (
|
||||
|
||||
class Article(models.Model):
|
||||
title = models.CharField(max_length=200)
|
||||
creator = models.ForeignKey(User, related_name='wiki_articles', blank=True, null=True)
|
||||
creator = models.ForeignKey(User, related_name='wiki_articles')
|
||||
status = models.IntegerField(choices=ARTICLE_STATUSES, default=PUBLIC)
|
||||
redirect_to = models.ForeignKey('self', blank=True, null=True)
|
||||
redirect_to = models.ForeignKey('self', null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
@ -50,11 +50,6 @@ class Article(models.Model):
|
||||
if '/' in self.title:
|
||||
return self.title.rsplit('/',1)[0]
|
||||
|
||||
# def save(self, **kwargs):
|
||||
# if self.creator is not None and self.creator.is_anonymous():
|
||||
# self.creator = None
|
||||
# super(Article, self).save(**kwargs)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('view_article', args=[self.title])
|
||||
|
||||
@ -73,25 +68,21 @@ class Article(models.Model):
|
||||
else:
|
||||
return EDITOR_TEST_FUNC(user)
|
||||
|
||||
def get_write_lock(self, user_or_request, release=False):
|
||||
if hasattr(user_or_request, 'session'):
|
||||
lock_id = user_or_request.session.session_key
|
||||
else:
|
||||
lock_id = user_or_request.id
|
||||
def get_write_lock(self, user, release=False):
|
||||
cache_key = 'markupwiki_articlelock_%s' % self.id
|
||||
lock = cache.get(cache_key)
|
||||
if lock:
|
||||
if release:
|
||||
cache.delete(cache_key)
|
||||
return lock == lock_id
|
||||
return lock == user.id
|
||||
|
||||
if not release:
|
||||
cache.set(cache_key, lock_id, WRITE_LOCK_SECONDS)
|
||||
cache.set(cache_key, user.id, WRITE_LOCK_SECONDS)
|
||||
return True
|
||||
|
||||
class ArticleVersion(models.Model):
|
||||
article = models.ForeignKey(Article, related_name='versions')
|
||||
author = models.ForeignKey(User, related_name='article_versions', blank=True, null=True)
|
||||
author = models.ForeignKey(User, related_name='article_versions')
|
||||
number = models.PositiveIntegerField()
|
||||
body = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE,
|
||||
markup_choices=WIKI_MARKUP_TYPES,
|
||||
@ -108,10 +99,5 @@ class ArticleVersion(models.Model):
|
||||
def __unicode__(self):
|
||||
return '%s rev #%s' % (self.article, self.number)
|
||||
|
||||
# def save(self, **kwargs):
|
||||
# if self.author is not None and self.author.is_anonymous():
|
||||
# self.author = None
|
||||
# super(ArticleVersion, self).save(**kwargs)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('article_version', args=[self.article.title, self.number])
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
{% if article and mod_form %}
|
||||
<div class="article_moderation">
|
||||
<form method="POST" action="{% url "update_article_status" article.title %}">
|
||||
<form method="POST" action="{% url update_article_status article.title %}">
|
||||
<ul>
|
||||
<li>{{mod_form.status.label_tag}} {{ mod_form.status }}</li>
|
||||
<li>
|
||||
@ -16,7 +16,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<form method="POST" action="{% url "rename_article" article.title %}">
|
||||
<form method="POST" action="{% url rename_article article.title %}">
|
||||
<ul>
|
||||
{{ rename_form.as_ul}}
|
||||
<li>
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
<h2 class="article_title">
|
||||
{% block article_title %}
|
||||
{% if article.section_name %}<a href="{% url "view_article" article.section_name %}">{{article.section_name}}</a> / {% endif %}
|
||||
{% if article.section_name %}<a href="{% url view_article article.section_name %}">{{article.section_name}}</a> / {% endif %}
|
||||
{{article.display_title}}
|
||||
|
||||
{% if article.is_deleted %} [deleted] {% endif %}
|
||||
@ -42,10 +42,10 @@
|
||||
<div class="article_meta">
|
||||
{% block article_meta %}
|
||||
{% if article.editable %}
|
||||
<a href="{% url "edit_article" article.title %}">edit article</a> |
|
||||
<a href="{% url edit_article article.title %}">edit article</a> |
|
||||
{% endif %}
|
||||
{% if article %}
|
||||
<a href="{% url "article_history" article.title %}">view history</a>
|
||||
<a href="{% url article_history article.title %}">view history</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
{% block article_meta %}
|
||||
{% if article %}
|
||||
<a href="{% url "view_article" article.title %}">view article</a> |
|
||||
<a href="{% url "article_history" article.title %}">view history</a>
|
||||
<a href="{% url view_article article.title %}">view article</a> |
|
||||
<a href="{% url article_history article.title %}">view history</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
@ -12,32 +12,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block article_body %}
|
||||
|
||||
<form action="{% url revert article.title %}" method="post">
|
||||
|
||||
{% csrf_token %}
|
||||
|
||||
<label for="revert-version">Revert to</label>
|
||||
<select name="revision" id="revert-version">
|
||||
{% for version in versions reversed %}
|
||||
{% if not forloop.first %}
|
||||
<option value="{{ version.number }}">
|
||||
{% if version.number == 0 %}
|
||||
Initial
|
||||
{% else %}
|
||||
{{ version.number }}
|
||||
{% endif %}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<button class="compareBtn" type="submit">
|
||||
<span>Revert to version</span>
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<table>
|
||||
<thead> <tr>
|
||||
<th>Version</th>
|
||||
@ -72,5 +46,4 @@
|
||||
<span>Compare Selected Versions</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.conf.urls import *
|
||||
from django.conf.urls.defaults import *
|
||||
from markupwiki.feeds import LatestEditsFeed, LatestArticleEditsFeed
|
||||
|
||||
WIKI_REGEX = r'^(?P<title>.+)'
|
||||
@ -12,6 +12,5 @@ urlpatterns = patterns('markupwiki.views',
|
||||
url(WIKI_REGEX + '/history/$', 'article_history', name='article_history'),
|
||||
url(WIKI_REGEX + '/history/(?P<n>\d+)/$', 'view_article', name='article_version'),
|
||||
url(WIKI_REGEX + '/diff/$', 'article_diff', name='article_diff'),
|
||||
url(WIKI_REGEX + '/revert/$', 'revert', name='revert'),
|
||||
url(WIKI_REGEX + '/$', 'view_article', name='view_article'),
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ from django.contrib import messages
|
||||
from django.http import Http404
|
||||
from django.template import RequestContext
|
||||
from django.utils.functional import wraps
|
||||
from markupwiki.models import Article, ArticleVersion, PUBLIC, DELETED, LOCKED
|
||||
from markupwiki.models import Article, PUBLIC, DELETED, LOCKED
|
||||
from markupwiki.forms import ArticleForm, StaffModerationForm, ArticleRenameForm
|
||||
|
||||
CREATE_MISSING_ARTICLE = getattr(settings,
|
||||
@ -115,13 +115,11 @@ def edit_article(request, title):
|
||||
form = ArticleForm()
|
||||
elif request.method == 'POST':
|
||||
form = ArticleForm(request.POST)
|
||||
user = None if request.user.is_anonymous() else request.user
|
||||
|
||||
if form.is_valid():
|
||||
if not article:
|
||||
# if article doesn't exist create it and start num at 0
|
||||
article = Article.objects.create(title=title,
|
||||
creator=user)
|
||||
creator=request.user)
|
||||
num = 0
|
||||
else:
|
||||
if not article.get_write_lock(request.user):
|
||||
@ -135,11 +133,11 @@ def edit_article(request, title):
|
||||
# create a new version attached to article specified in name
|
||||
version = form.save(False)
|
||||
version.article = article
|
||||
version.author = user
|
||||
version.author = request.user
|
||||
version.number = num
|
||||
version.save()
|
||||
|
||||
article.get_write_lock(user or request, release=True)
|
||||
article.get_write_lock(request.user, release=True)
|
||||
|
||||
# redirect to view article on save
|
||||
return redirect(article)
|
||||
@ -169,7 +167,7 @@ def revert(request, title):
|
||||
'''
|
||||
article = get_object_or_404(Article, title=title)
|
||||
revision_id = int(request.POST['revision'])
|
||||
revision = get_object_or_404(article.versions, number=revision_id)
|
||||
revision = get_object_or_404(revision, number=revision_id)
|
||||
ArticleVersion.objects.create(article=article, author=request.user,
|
||||
number=article.versions.latest().number,
|
||||
comment='reverted to r%s' % revision_id,
|
||||
|
Loading…
Reference in New Issue
Block a user