Permalink
Browse files

Merge branch 'master' of git://github.com/ridethepony/django-fiber

  • Loading branch information...
2 parents b5b24b3 + 6257be1 commit 74cabcff0aecf4247c51b750219ea72485da6d1a Nick Badoux committed Jan 10, 2012
View
2 fiber/admin.py
@@ -45,7 +45,7 @@ class PageAdmin(MPTTModelAdmin):
form = forms.PageForm
fieldsets = (
(None, {'fields': ('parent', 'title', 'url', 'redirect_page', 'template_name')}),
- (_('Advanced options'), {'classes': ('collapse',), 'fields': ('mark_current_regexes', 'show_in_menu', 'protected', 'metadata',)}),
+ (_('Advanced options'), {'classes': ('collapse',), 'fields': ('mark_current_regexes', 'show_in_menu', 'is_public', 'protected', 'metadata',)}),
)
inlines = (PageContentItemInline,)
View
7 fiber/context_processors.py
@@ -62,10 +62,9 @@ def page_info(request):
"""
Block access to pages that the current user isn't supposed to see.
"""
- if request.user.is_authenticated():
- if page:
- if page not in Page.objects.visible_pages_for_user(request.user):
- page = None
+ if page:
+ if page not in Page.objects.public_for_user(request.user):
+ page = None
"""
Find pages that should be marked as current in menus.
View
BIN fiber/locale/nl/LC_MESSAGES/django.mo
Binary file not shown.
View
183 fiber/locale/nl/LC_MESSAGES/django.po
@@ -2,13 +2,13 @@
# Copyright (C) 2011 Ride The Pony
# This file is distributed under the same license as the Django Fiber package.
# Ride The Pony <info@ridethepony.org>, 2011.
-#
+#
msgid ""
msgstr ""
"Project-Id-Version: Django Fiber\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-05-13 13:16+0200\n"
-"PO-Revision-Date: 2011-05-13 06:17\n"
+"POT-Creation-Date: 2012-01-10 16:02+0100\n"
+"PO-Revision-Date: 2012-01-10 16:06+0100\n"
"Last-Translator: Bram Simons <bsimons@leukeleu.nl>\n"
"Language-Team: Ride The Pony <info@ridethepony.org>\n"
"MIME-Version: 1.0\n"
@@ -17,61 +17,40 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Translated-Using: django-rosetta 0.6.0\n"
-#: admin.py:25 models.py:151
-msgid "URL"
-msgstr "URL"
-
-#: admin.py:26
-msgid "Example: '/section-1/products' or 'products' or '\"some_named_url\"'"
-msgstr "Voorbeeld: '/sectie-1/producten' of 'producten' of '\"een_named_url\"'"
-
-#: admin.py:27
-msgid ""
-"This value must contain only letters, numbers, underscores, dashes or "
-"slashes."
-msgstr ""
-"Deze waarde mag alleen letters, cijfers, underscores, min-tekens en "
-"schuine strepen bevatten."
-
-#: admin.py:28
-msgid "Redirect page"
-msgstr "Automatische doorverwijzing"
-
-#: admin.py:35
-msgid "No reverse match found for the named url"
-msgstr "Geen 'reverse match' gevonden voor de 'named url'"
-
-#: admin.py:42
-msgid "A named url can't be combined with a redirect page"
-msgstr ""
-"Een 'named url' kan niet worden gecombineerd met een automatische "
-"doorverwijzing"
-
-#: admin.py:58 admin.py:155
+#: admin.py:32
+#: admin.py:48
msgid "Advanced options"
msgstr "Uitgebreide opties"
-#: admin.py:72
+#: admin.py:62
msgid "View on site"
msgstr "Toon op site"
-#: admin.py:85
+#: admin.py:74
msgid "Move up"
msgstr "Verplaats omhoog"
-#: admin.py:90
+#: admin.py:79
msgid "Move down"
msgstr "Verplaats omlaag"
-#: admin.py:96
+#: admin.py:85
msgid "Add sub page"
msgstr "Voeg een subpagina toe"
-#: admin.py:100
+#: admin.py:89
msgid "Actions"
msgstr "Acties"
-#: admin.py:108
+#: admin_forms.py:20
+msgid "Redirect page"
+msgstr "Automatische doorverwijzing"
+
+#: admin_forms.py:35
+msgid "A named url can't be combined with a redirect page"
+msgstr "Een 'named url' kan niet worden gecombineerd met een automatische doorverwijzing"
+
+#: admin_forms.py:42
msgid "Template"
msgstr "Sjabloon"
@@ -80,137 +59,154 @@ msgid "This account is inactive."
msgstr "Dit account is inactief."
#: admin_views.py:30
-msgid ""
-"Please enter a correct username and password. Note that both fields are"
-" case-sensitive."
-msgstr ""
-"Voer een correcte gebruikersnaam en wachtwoord in. Let op, de velden "
-"zijn hoofdlettergevoelig."
+msgid "Please enter a correct username and password. Note that both fields are case-sensitive."
+msgstr "Voer een correcte gebruikersnaam en wachtwoord in. Let op, de velden zijn hoofdlettergevoelig."
-#: models.py:54
+#: managers.py:41
msgid "used more than once"
msgstr "meerdere keren gebruikt"
-#: models.py:55
+#: managers.py:42
msgid "unused"
msgstr "ongebruikt"
-#: models.py:56
+#: managers.py:43
msgid "used once"
msgstr "één keer gebruikt"
-#: models.py:57
+#: managers.py:44
msgid "recently changed"
msgstr "recent gewijzigd"
-#: models.py:99 models.py:143 models.py:301 models.py:328
+#: models.py:21
+#: models.py:66
+#: models.py:211
+#: models.py:237
msgid "created"
msgstr "aangemaakt"
-#: models.py:100 models.py:144 models.py:302 models.py:329
+#: models.py:22
+#: models.py:67
+#: models.py:212
+#: models.py:238
msgid "updated"
msgstr "bijgewerkt"
-#: models.py:102
+#: models.py:23
msgid "name"
msgstr "naam"
-#: models.py:103 models.py:104 templates/fiber/admin.html:26
+#: models.py:24
+#: models.py:25
+#: templates/fiber/admin.html:26
msgid "Content"
msgstr "Content"
-#: models.py:105 models.py:157
+#: models.py:26
+#: models.py:78
msgid "protected"
msgstr "beschermd"
-#: models.py:107
+#: models.py:27
msgid "metadata"
msgstr "metadata"
-#: models.py:118
-msgid "[ EMPTY ]"
-msgstr "[ LEEG ]"
+#: models.py:28
+#: models.py:75
+msgid "template name"
+msgstr "sjabloonnaam"
-#: models.py:130 models.py:292
+#: models.py:33
+#: models.py:202
msgid "content item"
msgstr "content item"
-#: models.py:131 models.py:159
+#: models.py:34
+#: models.py:79
msgid "content items"
msgstr "content items"
-#: models.py:146
+#: models.py:43
+msgid "[ EMPTY ]"
+msgstr "[ LEEG ]"
+
+#: models.py:68
msgid "parent"
msgstr "parent"
-#: models.py:150 models.py:305 models.py:332
+#: models.py:70
+#: models.py:214
+#: models.py:240
msgid "title"
msgstr "titel"
-#: models.py:152
+#: models.py:72
msgid "redirect page"
msgstr "automatische doorverwijzing"
-#: models.py:153
+#: models.py:73
msgid "mark current regexes"
msgstr "reguliere expressies markeren als current"
-#: models.py:155
-msgid "template name"
-msgstr "sjabloonnaam"
-
-#: models.py:156
+#: models.py:76
msgid "show in menu"
msgstr "toon in menu"
-#: models.py:254 models.py:293
+#: models.py:77
+msgid "is public"
+msgstr "is openbaar"
+
+#: models.py:86
+#: models.py:203
msgid "page"
msgstr "pagina"
-#: models.py:255
+#: models.py:87
msgid "pages"
msgstr "pagina’s"
-#: models.py:294
+#: models.py:204
msgid "block name"
msgstr "block naam"
-#: models.py:295
+#: models.py:205
msgid "sort"
msgstr "sortering"
-#: models.py:304 models.py:322
+#: models.py:213
+#: models.py:219
msgid "image"
msgstr "afbeelding"
-#: models.py:306
+#: models.py:215
msgid "width"
msgstr "breedte"
-#: models.py:307
+#: models.py:216
msgid "height"
msgstr "hoogte"
-#: models.py:323
+#: models.py:220
msgid "images"
msgstr "afbeeldingen"
-#: models.py:331 models.py:340
+#: models.py:239
+#: models.py:243
msgid "file"
msgstr "bestand"
-#: models.py:341
+#: models.py:244
msgid "files"
msgstr "bestanden"
#: templates/fiber/admin.html:9
-msgid "Backend"
-msgstr "Backend"
-
-#: templates/fiber/admin.html:10
msgid "Log out"
msgstr "Uitloggen"
+#: templates/fiber/admin.html:10
+msgid "Backend"
+msgstr "Backend"
+
#: templates/fiber/admin.html:13
msgid "Pages"
msgstr "Pagina’s"
@@ -265,3 +261,22 @@ msgstr "%s maanden geleden"
#, python-format
msgid "%s years ago"
msgstr "%s jaar geleden"
+
+#: utils/fields.py:13
+msgid "URL"
+msgstr "URL"
+
+#: utils/form_fields.py:10
+msgid "Example: '/section-1/products' or 'products' or '\"some_named_url\"'"
+msgstr "Voorbeeld: '/sectie-1/producten' of 'producten' of '\"een_named_url\"'"
+
+#: utils/validators.py:27
+msgid "No reverse match found for the named url"
+msgstr "Geen 'reverse match' gevonden voor de 'named url'"
+
+#~ msgid ""
+#~ "This value must contain only letters, numbers, underscores, dashes or "
+#~ "slashes."
+#~ msgstr ""
+#~ "Deze waarde mag alleen letters, cijfers, underscores, min-tekens en "
+#~ "schuine strepen bevatten."
View
15 fiber/managers.py
@@ -84,12 +84,19 @@ def rename_markup(markup):
class PageManager(models.Manager):
- def visible_pages_for_user(self, user):
- visible_pages_qs = self.get_query_set()
+ def public_for_user(self, user):
+ public_pages_qs = self.get_query_set()
if not user.is_staff:
- visible_pages_qs = visible_pages_qs.filter(show_in_menu=True)
+ public_pages_qs = public_pages_qs.filter(is_public=True)
- return visible_pages_qs
+ return public_pages_qs
+
+ def shown_in_menu_for_user(self, user):
+ shown_in_menu_pages_qs = self.get_query_set()
+ if not user.is_staff:
+ shown_in_menu_pages_qs = shown_in_menu_pages_qs.filter(show_in_menu=True, is_public=True)
+
+ return shown_in_menu_pages_qs
class PageContentItemManager(models.Manager):
View
89 fiber/migrations/0010_auto__add_field_page_is_public__chg_field_page_url.py
@@ -0,0 +1,89 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding field 'Page.is_public'
+ db.add_column('fiber_page', 'is_public', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False)
+
+ # Changing field 'Page.url'
+ db.alter_column('fiber_page', 'url', self.gf('fiber.utils.fields.FiberURLField')(max_length=255))
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'Page.is_public'
+ db.delete_column('fiber_page', 'is_public')
+
+ # Changing field 'Page.url'
+ db.alter_column('fiber_page', 'url', self.gf('django.db.models.fields.CharField')(max_length=255))
+
+
+ models = {
+ 'fiber.contentitem': {
+ 'Meta': {'object_name': 'ContentItem'},
+ 'content_html': ('fiber.utils.fields.FiberHTMLField', [], {}),
+ 'content_markup': ('fiber.utils.fields.FiberMarkupField', [], {}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'metadata': ('fiber.utils.json.JSONField', [], {'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'protected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'template_name': ('django.db.models.fields.CharField', [], {'max_length': '70', 'blank': 'True'}),
+ 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
+ },
+ 'fiber.file': {
+ 'Meta': {'ordering': "('file',)", 'object_name': 'File'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
+ },
+ 'fiber.image': {
+ 'Meta': {'ordering': "('image',)", 'object_name': 'Image'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'height': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '255'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'width': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'})
+ },
+ 'fiber.page': {
+ 'Meta': {'ordering': "('tree_id', 'lft')", 'object_name': 'Page'},
+ 'content_items': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['fiber.ContentItem']", 'through': "orm['fiber.PageContentItem']", 'symmetrical': 'False'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'mark_current_regexes': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'metadata': ('fiber.utils.json.JSONField', [], {'null': 'True', 'blank': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'subpages'", 'null': 'True', 'to': "orm['fiber.Page']"}),
+ 'protected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'redirect_page': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'redirected_pages'", 'null': 'True', 'to': "orm['fiber.Page']"}),
+ 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'show_in_menu': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'template_name': ('django.db.models.fields.CharField', [], {'max_length': '70', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'url': ('fiber.utils.fields.FiberURLField', [], {'max_length': '255', 'blank': 'True'})
+ },
+ 'fiber.pagecontentitem': {
+ 'Meta': {'object_name': 'PageContentItem'},
+ 'block_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'content_item': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'page_content_items'", 'to': "orm['fiber.ContentItem']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'page': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'page_content_items'", 'to': "orm['fiber.Page']"}),
+ 'sort': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['fiber']
View
1 fiber/models.py
@@ -81,6 +81,7 @@ class Page(MPTTModel):
# TODO: add `alias_page` field
template_name = models.CharField(_('template name'), blank=True, max_length=70)
show_in_menu = models.BooleanField(_('show in menu'), default=True)
+ is_public = models.BooleanField(_('is public'), default=True)
protected = models.BooleanField(_('protected'), default=False)
content_items = models.ManyToManyField(ContentItem, through='PageContentItem', verbose_name=_('content items'))
metadata = JSONField(blank=True, null=True, schema=METADATA_PAGE_SCHEMA, prefill_from='fiber.models.Page')
View
19 fiber/static/fiber/css/admin.css
@@ -254,7 +254,7 @@ ins.jstree-icon {
#df-wpr-sidebar .jstree .ui-state-default .ui-icon,
.jstree .ui-state-default .ui-icon {
- background: url(../images/ckeditor/icon-page.png);
+ background: url(../images/icon-page.png);
background-position: 0 0;
}
@@ -263,26 +263,33 @@ ins.jstree-icon {
margin-top: 14px;
}
-li.hidden-in-menu {
+li.hidden-in-menu,
+li.not-public, {
opacity: 0.5;
filter: alpha(opacity=50);
}
-#df-wpr-sidebar .jstree li.hidden-in-menu {
+#df-wpr-sidebar .jstree li.hidden-in-menu,
+#df-wpr-sidebar .jstree li.not-public {
opacity: 1;
filter: alpha(opacity=100);
}
-#df-wpr-sidebar .jstree li.hidden-in-menu a {
+#df-wpr-sidebar .jstree li.hidden-in-menu a,
+#df-wpr-sidebar .jstree li.not-public a {
color: #999;
}
#df-wpr-sidebar .jstree li.hidden-in-menu > .ui-state-default .ui-icon {
- background: url(../images/ckeditor/icon-page-hidden.png);
+ background: url(../images/icon-page-hidden.png);
+}
+
+#df-wpr-sidebar .jstree li.not-public > .ui-state-default .ui-icon {
+ background: url(../images/icon-page-not-public.png);
}
#df-wpr-sidebar .jstree li.redirect > .ui-state-default .ui-icon {
- background: url(../images/ckeditor/icon-page-redirect.png);
+ background: url(../images/icon-page-redirect.png);
}
#df-wpr-busy {
View
0 ...iber/images/ckeditor/icon-page-hidden.png → .../static/fiber/images/icon-page-hidden.png
File renamed without changes
View
BIN fiber/static/fiber/images/icon-page-not-public.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 ...er/images/ckeditor/icon-page-redirect.png → ...tatic/fiber/images/icon-page-redirect.png
File renamed without changes
View
0 ...tatic/fiber/images/ckeditor/icon-page.png → fiber/static/fiber/images/icon-page.png
File renamed without changes
View
2 fiber/templates/fiber/menu.html
@@ -6,7 +6,7 @@
<ul>
{% endif %}
{% recursetree fiber_menu_pages %}
- <li class="{{ node.title|slugify }}{% if node in fiber_current_pages %} current{% endif %}{% if node.is_first_child %} first{% endif %}{% if node.is_last_child %} last{% endif %}{% if not node.show_in_menu %} hidden-in-menu{% endif %}{% if node.redirect_page %} redirect{% endif %}">
+ <li class="{{ node.title|slugify }}{% if node in fiber_current_pages %} current{% endif %}{% if node.is_first_child %} first{% endif %}{% if node.is_last_child %} last{% endif %}{% if not node.show_in_menu %} hidden-in-menu{% endif %}{% if not node.is_public %} not-public{% endif %}{% if node.redirect_page %} redirect{% endif %}">
<a href="{{ node.get_absolute_url }}" data-fiber-data='{"type": "page", "id": {{ node.id }}, "parent_id": {{ node.parent.id }}, "url": "{{ node.get_change_url }}", "add_url": "{{ Page.get_add_url }}"}'>{{ node.title }}</a>
{% if children %}
<ul data-fiber-data='{"type": "page", "add_url": "{{ Page.get_add_url }}", "parent_id": {{ node.id }}}'>
View
6 fiber/templatetags/fiber_tags.py
@@ -56,10 +56,10 @@ def show_menu(context, menu_name, min_level, max_level, expand=None):
menu_pages.extend(Page.objects.filter(tree_id=root_page.tree_id).filter(level__range=(min_level, max_level)))
"""
- Remove pages that the current user isn't supposed to see.
+ Remove pages that shouldn't be shown in the menu for the current user.
"""
- visible_pages_for_user = Page.objects.visible_pages_for_user(context['user'])
- menu_pages = list(set(menu_pages) & set(visible_pages_for_user))
+ shown_in_menu_for_user = Page.objects.shown_in_menu_for_user(context['user'])
+ menu_pages = list(set(menu_pages) & set(shown_in_menu_for_user))
"""
Order menu_pages for use with tree_info template tag.

0 comments on commit 74cabcf

Please sign in to comment.