# Path: ssheepdog/utils.py
# def add_permission(orm, codename, name, app_label='ssheepdog', model='login'):
#     ct, created = orm['contenttypes.ContentType'].objects.get_or_create(
#         model=model, app_label=app_label)
#     orm['auth.permission'].objects.get_or_create(
#         content_type=ct, codename=codename, defaults=dict(name=name))


import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from ssheepdog.utils import add_permission
# encoding: utf-8
PERMISSIONS = ( # Managed by South so added by data migration!
    ("can_view_access_summary", "Can view access summary"),
    ("can_sync", "Can sync login keys"),
    ("can_edit_own_public_key", "Can edit one's own public key"),
    )

class Migration(DataMigration):

    def forwards(self, orm):
        ct, created = orm['contenttypes.ContentType'].objects.get_or_create(
            model='login', app_label='ssheepdog')
        for codename, name in PERMISSIONS:
            add_permission(orm, codename, name)


# Path: ssheepdog/utils.py
# def add_permission(orm, codename, name, app_label='ssheepdog', model='login'):
#     ct, created = orm['contenttypes.ContentType'].objects.get_or_create(
#         model=model, app_label=app_label)
#     orm['auth.permission'].objects.get_or_create(
#         content_type=ct, codename=codename, defaults=dict(name=name))


# Path: ssheepdog/migrations/0008_add_permissions.py
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from ssheepdog.utils import add_permission

# encoding: utf-8
PERMISSIONS = ( # Managed by South so added by data migration!
    ("can_view_access_summary", "Can view access summary"),
    ("can_sync", "Can sync login keys"),
    ("can_edit_own_public_key", "Can edit one's own public key"),
    )

class Migration(DataMigration):

    def forwards(self, orm):
        ct, created = orm['contenttypes.ContentType'].objects.get_or_create(
            model='login', app_label='ssheepdog')
        for codename, name in PERMISSIONS:
            add_permission(orm, codename, name)


    def backwards(self, orm):