'book', 'stage__name',
'user')
- self.book_ids = [x['book_id'] for x in chunk_qs.values('book_id')]
+ self.book_qs = chunk_qs.values('book_id')
def __getitem__(self, key):
if isinstance(key, slice):
raise TypeError('Unsupported list index. Must be a slice or an int.')
def __len__(self):
- return len(self.book_ids)
+ return self.book_qs.count()
def get_slice(self, slice_):
- book_ids = self.book_ids[slice_]
+ book_ids = [x['book_id'] for x in self.book_qs[slice_]]
chunk_qs = self.chunk_qs.filter(book__in=book_ids)
chunks_list = []
# Adding model 'Book'
db.create_table('wiki_book', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('title', self.gf('django.db.models.fields.CharField')(max_length=255)),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=128, db_index=True)),
('gallery', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
('parent', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='children', null=True, to=orm['wiki.Book'])),
('parent_number', self.gf('django.db.models.fields.IntegerField')(db_index=True, null=True, blank=True)),
- ('last_published', self.gf('django.db.models.fields.DateTimeField')(null=True)),
- ('_list_html', self.gf('django.db.models.fields.TextField')(null=True)),
+ ('last_published', self.gf('django.db.models.fields.DateTimeField')(null=True, db_index=True)),
))
db.send_create_signal('wiki', ['Book'])
('description', self.gf('django.db.models.fields.TextField')(default='', blank=True)),
('created_at', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, db_index=True)),
('publishable', self.gf('django.db.models.fields.BooleanField')(default=False)),
- ('tree', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['wiki.Chunk'])),
+ ('tree', self.gf('django.db.models.fields.related.ForeignKey')(related_name='change_set', to=orm['wiki.Chunk'])),
))
db.send_create_signal('wiki', ['ChunkChange'])
},
'wiki.book': {
'Meta': {'ordering': "['parent_number', 'title']", 'object_name': 'Book'},
- '_list_html': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'gallery': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'last_published': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'last_published': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['wiki.Book']"}),
'parent_number': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '128', 'db_index': 'True'}),
- 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})
},
'wiki.chunk': {
'Meta': {'ordering': "['number']", 'unique_together': "[['book', 'number'], ['book', 'slug']]", 'object_name': 'Chunk'},
'patch': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'publishable': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'revision': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
- 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['wiki.ChunkTag']", 'symmetrical': 'False'}),
- 'tree': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['wiki.Chunk']"})
+ 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'change_set'", 'symmetrical': 'False', 'to': "orm['wiki.ChunkTag']"}),
+ 'tree': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'change_set'", 'to': "orm['wiki.Chunk']"})
},
'wiki.chunktag': {
'Meta': {'ordering': "['ordering']", 'object_name': 'ChunkTag'},
class Book(models.Model):
""" A document edited on the wiki """
- title = models.CharField(_('title'), max_length=255)
- slug = models.SlugField(_('slug'), max_length=128, unique=True)
+ title = models.CharField(_('title'), max_length=255, db_index=True)
+ slug = models.SlugField(_('slug'), max_length=128, unique=True, db_index=True)
gallery = models.CharField(_('scan gallery name'), max_length=255, blank=True)
parent = models.ForeignKey('self', null=True, blank=True, verbose_name=_('parent'), related_name="children")
parent_number = models.IntegerField(_('parent number'), null=True, blank=True, db_index=True)
- last_published = models.DateTimeField(null=True, editable=False)
-
- _list_html = models.TextField(editable=False, null=True)
+ last_published = models.DateTimeField(null=True, editable=False, db_index=True)
class NoTextError(BaseException):
pass
def get_absolute_url(self):
return reverse("wiki_book", args=[self.slug])
- def save(self, reset_list_html=True, *args, **kwargs):
- if reset_list_html:
- self._list_html = None
- return super(Book, self).save(*args, **kwargs)
-
@classmethod
def create(cls, creator=None, text=u'', *args, **kwargs):
"""
def __getitem__(self, chunk):
return self.chunk_set.all()[chunk]
- def __len__(self):
- return self.chunk_set.count()
-
- def list_html(self):
- if self._list_html is None:
- print 'rendering', self.title
- self._list_html = render_to_string('wiki/document_list_item.html',
- {'book': self})
- self.save(reset_list_html=False)
- return mark_safe(self._list_html)
-
def materialize(self, publishable=True):
"""
Get full text of the document compiled from chunks.
<div id="tabs-nav">
- <img id="logo" src="{{ STATIC_URL }}img/wl-orange.png" />
+ <a href="{% url wiki_document_list %}">
+ <img id="logo" src="{{ STATIC_URL }}img/wl-orange.png" />
+ </a>
<div id="tabs-nav-left">
{% main_tabs %}
<div id="content">
+{% block content %}
<div id="wiki_layout_left_column">
{% block leftcolumn %}
{% endblock leftcolumn %}
{% block rightcolumn %}
{% endblock rightcolumn %}
</div>
+{% endblock content %}
</div>
<form method="get" action="#">
<table id="file-list">
<tbody>
- {% autopaginate books 20 %}
+ {% autopaginate books 100 %}
{% if not books %}
<tr><td>{% trans "No books found." %}</td></tr>
{% endif %}
tabs = []
user = context['user']
if user.is_authenticated():
- tabs.append(Tab('my', _('Assigned to me'), reverse("wiki_user")))
+ tabs.append(Tab('my', _('My page'), reverse("wiki_user")))
tabs.append(Tab('unassigned', _('Unassigned'), reverse("wiki_unassigned")))
tabs.append(Tab('users', _('Users'), reverse("wiki_users")))
- tabs.append(Tab('all', _('All'), reverse("wiki_document_list")))
tabs.append(Tab('create', _('Add'), reverse("wiki_create_missing")))
tabs.append(Tab('upload', _('Upload'), reverse("wiki_upload")))
def changes_wall(max_len):
qs = Chunk.change_model.objects.filter(revision__gt=-1).order_by('-created_at')
qs = qs.defer('patch')
- qs = qs.select_related('author', 'tree')
- #qs = qs.annotate(book_length=Count('chunk__book__chunk'))
+ qs = qs.select_related('author', 'tree', 'tree__book__title')
qs = qs[:max_len]
for item in qs:
tag = 'stage' if item.tags.count() else 'change'
from django.conf import settings
+from django.contrib import auth
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.db.models import Count
+from django.utils.http import urlquote_plus
from django.views.generic.simple import direct_to_template
from django.views.decorators.http import require_POST, require_GET
from django.core.urlresolvers import reverse
})
+@never_cache
+def logout_then_redirect(request):
+ auth.logout(request)
+ return http.HttpResponseRedirect(urlquote_plus(request.GET.get('next', '/'), safe='/?='))
+
+
@never_cache
def editor(request, slug, chunk=None, template_name='wiki/document_details.html'):
try:
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django_cas.middleware.CASMiddleware',
'django.middleware.doc.XViewMiddleware',
'pagination.middleware.PaginationMiddleware',
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
- 'django_cas.backends.CASBackend',
)
ROOT_URLCONF = 'redakcja.urls'
FIREPYTHON_LOGGER_NAME = "fnp"
-#
-# Central Auth System
-#
-## Set this to where the CAS server lives
-# CAS_SERVER_URL = "http://cas.fnp.pl/
-CAS_LOGOUT_COMPLETELY = True
-
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.admindocs',
'django.contrib.comments',
- 'django_cas',
'compress',
'south',
'sorl.thumbnail',
'apiclient',
)
+LOGIN_REDIRECT_URL = '/documents/user'
+
+
FILEBROWSER_URL_FILEBROWSER_MEDIA = STATIC_URL + 'filebrowser/'
FILEBROWSER_DIRECTORY = 'images/'
FILEBROWSER_ADMIN_VERSIONS = []
-{% extends "base.html" %}
+{% extends "wiki/base.html" %}
{% block subtitle %} - Logowanie {% endblock subtitle %}
-{% block maincontent %}
+{% block content %}
<div class="isection">
-<form method="POST" action="{% url django.contrib.auth.views.login %}">
+<form method="POST" action="{% url login %}">
+{% csrf_token %}
{{ form.as_p }}
<p><input type="submit" value="Login" /></p>
<input type="hidden" name="next" value="{{ next|urlencode }}" />
</form>
</div>
-{% endblock maincontent %}
+{% endblock content %}
urlpatterns = patterns('',
# Auth
- url(r'^accounts/login/$', 'django_cas.views.login', name='login'),
- url(r'^accounts/logout/$', 'django_cas.views.logout', name='logout'),
+ url(r'^accounts/login/$', 'django.contrib.auth.views.login', name='login'),
+ url(r'^accounts/logout/$', 'wiki.views.logout_then_redirect', name='logout'),
# Admin panel
(r'^admin/filebrowser/', include('filebrowser.urls')),