Skip to content
Snippets Groups Projects
Commit 72152916 authored by Julian's avatar Julian
Browse files

Merge remote-tracking branch 'origin/master'

parents 1b6e8994 f6625580
No related branches found
No related tags found
1 merge request!117Resolve "Use or create external library for template mailer"
from django.db import migrations, models
from datetime import date
def create_or_mark_current_term(apps, schema_editor):
db_alias = schema_editor.connection.alias
SchoolTerm = apps.get_model('core', 'SchoolTerm') # noqa
if not SchoolTerm.objects.filter(current=True).exists():
if SchoolTerm.objects.using(db_alias).exists():
term = SchoolTerm.objects.using(db_alias).latest('date_start')
term.current=True
term.save()
else:
SchoolTerm.objects.using(db_alias).create(date_start=date.today(), current=True)
class Migration(migrations.Migration):
dependencies = [
('core', '0005_add_verbose_names_meta'),
]
operations = [
migrations.RunPython(create_or_mark_current_term)
]
from django.contrib.auth import get_user_model
from django.db import migrations
def create_superuser(apps, schema_editor):
User = get_user_model()
if not User.objects.filter(is_superuser=True).exists():
User.objects.create_superuser(
username='admin',
email='root@example.com',
password='admin'
).save()
class Migration(migrations.Migration):
dependencies = [
('core', '0006_create_default_term'),
]
operations = [
migrations.RunPython(create_superuser)
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment