summaryrefslogtreecommitdiff
path: root/yaksh/migrations/0013_release_0_9_0.py
blob: f18070dcf39e037fe87c1c69179bfc7610d6d091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2018-07-13 14:16
from __future__ import unicode_literals

from django.db import migrations, models
import yaksh.models

def set_is_moderator(apps, schema_editor):
    """ Set is_moderator to True for all users that belong
    to Moderator group """

    Profile = apps.get_model('yaksh', 'Profile')
    for prof in Profile.objects.all():
        user = prof.user
        if user.groups.filter(name='moderator').exists():
            prof.is_moderator = True
            prof.save()

class Migration(migrations.Migration):

    dependencies = [
        ('yaksh', '0012_release_0_8_1'),
    ]

    operations = [
        migrations.AddField(
            model_name='lesson',
            name='video_file',
            field=models.FileField(blank=True, default=None, help_text='Please upload video files in mp4, ogv, webm format', null=True, upload_to=yaksh.models.get_file_dir),
        ),
        migrations.AddField(
            model_name='profile',
            name='is_moderator',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterField(
            model_name='lessonfile',
            name='file',
            field=models.FileField(default=None, upload_to=yaksh.models.get_file_dir),
        ),
        migrations.RunPython(set_is_moderator),
    ]