Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django object level permissions support #253

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/dist/
/django_scheduler.egg-info/
/docs/_build/
.idea/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this line? It looks unrelated to the PR of adding object level permissions.

39 changes: 39 additions & 0 deletions schedule/migrations/0004_auto_20161228_0745.py
Original file line number Diff line number Diff line change
@@ -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', '0003_auto_20160715_0028'),
]

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'},
),
]
6 changes: 6 additions & 0 deletions schedule/models/calendars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
9 changes: 9 additions & 0 deletions schedule/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class Meta(object):
verbose_name = _('event')
verbose_name_plural = _('events')
app_label = 'schedule'
permissions = (
('view_event', _('View Event')),
)
index_together = (
('start', 'end'),
)
Expand Down Expand Up @@ -538,6 +541,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)
Expand All @@ -560,6 +566,9 @@ class Meta(object):
verbose_name = _("occurrence")
verbose_name_plural = _("occurrences")
app_label = 'schedule'
permissions = (
('view_occurrence', _('View Occurrence')),
)
index_together = (
('start', 'end'),
)
Expand Down
3 changes: 3 additions & 0 deletions schedule/models/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down