Commit 78ed42fa authored by Michal Čihař's avatar Michal Čihař

Automatically add subscription to existing owners/ACL users

Fixes #1000
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 99b50819
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-03-03 09:34
from __future__ import unicode_literals
from django.db import migrations
def fill_in_subscriptions(apps, schema_editor):
"""Adds subscriptions to owners or ACL enabled users"""
Project = apps.get_model('trans', 'Project')
Group = apps.get_model('auth', 'Group')
for project in Project.objects.all():
for owner in project.owners.all():
owner.profile.subscriptions.add(project)
if project.enable_acl:
group = Group.objects.get(name=project.name)
for user in group.user_set.all():
user.profile.subscriptions.add(project)
class Migration(migrations.Migration):
dependencies = [
('trans', '0058_componentlist'),
]
operations = [
migrations.RunPython(
fill_in_subscriptions,
),
]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment