Changeset 635:0f39a1e81b90
- Timestamp:
- 25/06/12 10:07:30 (11 months ago)
- Branch:
- default
- Files:
-
- 2 added
- 5 edited
-
cyclope/admin.py (modified) (1 diff)
-
cyclope/core/collections/templates/collections/category_contents_base.html (modified) (2 diffs)
-
cyclope/core/perms/migrations/0001_initial.py (added)
-
cyclope/core/perms/migrations/__init__.py (added)
-
cyclope/core/perms/models.py (modified) (1 diff)
-
cyclope/tests.py (modified) (1 diff)
-
demo/cyclope_project/db/site.db (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
cyclope/admin.py
r634 r635 107 107 category_slug = request.REQUEST['_from_category'] 108 108 category = Category.objects.get(slug=category_slug) 109 #extra_context['initial_category'] = category.id110 #extra_context['initial_collection'] = category.collection.id109 extra_context['initial_category'] = category.id 110 extra_context['initial_collection'] = category.collection.id 111 111 return super(BaseContentAdmin, self).add_view(request, form_url, extra_context) 112 112 -
cyclope/core/collections/templates/collections/category_contents_base.html
r634 r635 2 2 3 3 {% load i18n cyclope_utils fb_versions obj_perms %} 4 5 {% block extra_head %} 6 {{ block.super }} 7 <script type="text/javascript"> 8 var hide_children = function (el){ 9 $(el).children('ul').css('display', 'none'); 10 } 11 12 var show_children = function (el){ 13 $(el).children('ul').css('display', 'block'); 14 } 15 16 jQuery(document).ready(function(){ 17 $('.category_add_content').each(function(){ 18 hide_children($(this)); 19 }); 20 $('.category_add_content').each(function(){ 21 $(this).mouseenter(function(){ 22 show_children($(this)); 23 return false; 24 }) 25 $(this).mouseleave(function(){ 26 hide_children($(this)); 27 return false; 28 }); 29 }); 30 }); 31 </script> 32 {% endblock %} 4 33 5 34 {% block content %} … … 7 36 {% per_category_perms category as cat_perms %} 8 37 {% if cat_perms.add_content %} 9 10 38 <div class="category_add_content"> 11 <a href="{% url category-default category.slug %}"> Add content</a>39 <a href="{% url category-default category.slug %}">{% trans "Add content" %}</a> 12 40 <ul class="content_types"> 13 41 {% for c_type in category.collection.content_types.all %} -
cyclope/core/perms/models.py
r634 r635 27 27 from django.db import models 28 28 from django.contrib.auth.models import User 29 from django.utils.translation import ugettext_lazy as _ 30 29 31 from cyclope.core.collections.models import Category 30 32 31 33 32 34 class CategoryPermission(models.Model): 33 user = models.ForeignKey(User) 34 can_edit_content = models.BooleanField() 35 can_add_content = models.BooleanField() 36 category = models.ForeignKey(Category) 37 38 def _available_perms(self): 39 return [ f.name for f in self.fields if f.name.startswith('can_') ] 40 41 available_perms = property(_available_perms) 35 user = models.ForeignKey(User, verbose_name=_('user')) 36 can_edit_content = models.BooleanField(_('can edit content')) 37 can_add_content = models.BooleanField(_('can add content')) 38 category = models.ForeignKey(Category, verbose_name=_('category')) 42 39 43 40 class Meta: 44 41 unique_together = ('category', 'user') 45 42 verbose_name = _('category permission') 43 verbose_name_plural = _('category permissions') -
cyclope/tests.py
r634 r635 636 636 response = self.client.post(url, data={}) 637 637 self.assertEqual(response.status_code, 200) 638 print response639 638 self.assertTrue("This field is required" in response.content) 640 639
Note: See TracChangeset
for help on using the changeset viewer.

