From e8c392aea1bdb465d073966a6462cd1c30cb6233 Mon Sep 17 00:00:00 2001 From: Dirk Moors Date: Wed, 21 Sep 2016 09:16:32 +0200 Subject: [PATCH 1/2] Added view permission to Meta classes for models --- .gitignore | 1 + .../migrations/0003_auto_20160921_0745.py | 39 +++++++++++++++++++ schedule/models/calendars.py | 6 +++ schedule/models/events.py | 9 +++++ schedule/models/rules.py | 3 ++ 5 files changed, 58 insertions(+) create mode 100644 schedule/migrations/0003_auto_20160921_0745.py diff --git a/.gitignore b/.gitignore index 74d6b881..fb0f181e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /dist/ /django_scheduler.egg-info/ /docs/_build/ +.idea/ diff --git a/schedule/migrations/0003_auto_20160921_0745.py b/schedule/migrations/0003_auto_20160921_0745.py new file mode 100644 index 00000000..f3202f98 --- /dev/null +++ b/schedule/migrations/0003_auto_20160921_0745.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.1 on 2016-09-21 07:45 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('schedule', '0002_event_color_event'), + ] + + operations = [ + migrations.AlterModelOptions( + name='calendar', + options={'permissions': (('view_calendar', 'View Calendar'),), 'verbose_name': 'calendar', 'verbose_name_plural': 'calendar'}, + ), + migrations.AlterModelOptions( + name='calendarrelation', + options={'permissions': (('view_calendar_relation', 'View Calendar Relation'),), 'verbose_name': 'calendar relation', 'verbose_name_plural': 'calendar relations'}, + ), + migrations.AlterModelOptions( + name='event', + options={'permissions': (('view_event', 'View Event'),), 'verbose_name': 'event', 'verbose_name_plural': 'events'}, + ), + migrations.AlterModelOptions( + name='eventrelation', + options={'permissions': (('view_event_relation', 'View Event Relation'),), 'verbose_name': 'event relation', 'verbose_name_plural': 'event relations'}, + ), + migrations.AlterModelOptions( + name='occurrence', + options={'permissions': (('view_occurrence', 'View Occurrence'),), 'verbose_name': 'occurrence', 'verbose_name_plural': 'occurrences'}, + ), + migrations.AlterModelOptions( + name='rule', + options={'permissions': (('view_occurrence', 'View Occurrence'),), 'verbose_name': 'rule', 'verbose_name_plural': 'rules'}, + ), + ] diff --git a/schedule/models/calendars.py b/schedule/models/calendars.py index 3e59a864..6bd4323e 100644 --- a/schedule/models/calendars.py +++ b/schedule/models/calendars.py @@ -149,6 +149,9 @@ class Meta(object): verbose_name = _('calendar') verbose_name_plural = _('calendar') app_label = 'schedule' + permissions = ( + ('view_calendar', _('View Calendar')), + ) def __str__(self): return self.name @@ -240,6 +243,9 @@ class Meta(object): verbose_name = _('calendar relation') verbose_name_plural = _('calendar relations') app_label = 'schedule' + permissions = ( + ('view_calendar_relation', _('View Calendar Relation')), + ) def __str__(self): return '%s - %s' % (self.calendar, self.content_object) diff --git a/schedule/models/events.py b/schedule/models/events.py index ebe58d91..2ca02305 100644 --- a/schedule/models/events.py +++ b/schedule/models/events.py @@ -88,6 +88,9 @@ class Meta(object): verbose_name = _('event') verbose_name_plural = _('events') app_label = 'schedule' + permissions = ( + ('view_event', _('View Event')), + ) def __str__(self): return ugettext('%(title)s: %(start)s - %(end)s') % { @@ -509,6 +512,9 @@ class Meta(object): verbose_name = _("event relation") verbose_name_plural = _("event relations") app_label = 'schedule' + permissions = ( + ('view_event_relation', _('View Event Relation')), + ) def __str__(self): return '%s(%s)-%s' % (self.event.title, self.distinction, self.content_object) @@ -531,6 +537,9 @@ class Meta(object): verbose_name = _("occurrence") verbose_name_plural = _("occurrences") app_label = 'schedule' + permissions = ( + ('view_occurrence', _('View Occurrence')), + ) def __init__(self, *args, **kwargs): super(Occurrence, self).__init__(*args, **kwargs) diff --git a/schedule/models/rules.py b/schedule/models/rules.py index 3e6f2a22..2ce90504 100644 --- a/schedule/models/rules.py +++ b/schedule/models/rules.py @@ -58,6 +58,9 @@ class Meta(object): verbose_name = _('rule') verbose_name_plural = _('rules') app_label = 'schedule' + permissions = ( + ('view_occurrence', _('View Occurrence')), + ) def rrule_frequency(self): compatibiliy_dict = { From f0c04a806a888f52726be334a225e8ce88138a35 Mon Sep 17 00:00:00 2001 From: Dirk Moors Date: Wed, 28 Dec 2016 15:18:13 +0100 Subject: [PATCH 2/2] Fixed migrations --- .../{0003_auto_20160921_0745.py => 0004_auto_20161228_0745.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename schedule/migrations/{0003_auto_20160921_0745.py => 0004_auto_20161228_0745.py} (97%) diff --git a/schedule/migrations/0003_auto_20160921_0745.py b/schedule/migrations/0004_auto_20161228_0745.py similarity index 97% rename from schedule/migrations/0003_auto_20160921_0745.py rename to schedule/migrations/0004_auto_20161228_0745.py index f3202f98..8a5a02a3 100644 --- a/schedule/migrations/0003_auto_20160921_0745.py +++ b/schedule/migrations/0004_auto_20161228_0745.py @@ -8,7 +8,7 @@ class Migration(migrations.Migration): dependencies = [ - ('schedule', '0002_event_color_event'), + ('schedule', '0003_auto_20160715_0028'), ] operations = [