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

Models #11

Merged
merged 6 commits into from Jun 19, 2017

feat(admin): Generate superuser programmatically

  • Loading branch information...
uttu357 committed Jun 16, 2017
commit 18ef267c7d8d7cb7c71d40113d99ac1dd8aa2e0d
No changes.
No changes.
@@ -0,0 +1,18 @@
import os
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User
class Command(BaseCommand):
help = 'Creates a superuser using the environment variables'
def handle(self, *args, **options):
username = os.environ.get('DJANGO_USERNAME', 'admin')
email = os.environ.get('DJANGO_EMAIL', 'admin@cloudcv.org')
password = os.environ.get('DJANGO_PASSWORD', 'pass')
try:
User.objects.create_superuser(username, email, password)
except:
raise CommandError('DB is not connected properly')
self.stdout.write(self.style.SUCCESS('Successfully created superuser'))
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-06-12 10:33
# Generated by Django 1.11.1 on 2017-06-16 08:36
from __future__ import unicode_literals
from django.db import migrations, models
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-06-12 10:33
# Generated by Django 1.11.1 on 2017-06-16 08:36
from __future__ import unicode_literals
import base.utils
from django.db import migrations, models
import django.db.models.deletion
@@ -21,21 +22,20 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('modified_at', models.DateTimeField(auto_now=True)),
('log_type', models.CharField(choices=[('Submission', 'Submission'),
('Break', 'Break')], max_length=30)),
('log_type', models.CharField(choices=[('Submission', 'Submission'), ('Break', 'Break')], max_length=30)),
('demo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='demos.Demo')),
],
options={
'db_table': 'demo_logs',
},
),
migrations.CreateModel(
name='LogImages',
name='LogImage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('modified_at', models.DateTimeField(auto_now=True)),
('image', models.ImageField(default=False, upload_to='demo_log_images')),
('image', models.ImageField(default=False, upload_to=base.utils.RandomFileName('demo_log_images'))),
('image_type', models.CharField(choices=[('Input', 'Input'), ('Output', 'Output')], max_length=10)),
('demo_log', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='logs.DemoLog')),
],
@@ -44,7 +44,7 @@ class Migration(migrations.Migration):
},
),
migrations.CreateModel(
name='LogTexts',
name='LogText',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-06-12 10:35
# Generated by Django 1.11.1 on 2017-06-16 08:36
from __future__ import unicode_literals
from django.db import migrations, models
@@ -37,16 +37,10 @@ class Migration(migrations.Migration):
('description', models.TextField(null=True)),
('image', models.ImageField(blank=True, null=True, upload_to='team')),
('visible', models.BooleanField(default=False)),
('github_url', models.CharField(blank=True, max_length=200, null=True)),
('linkedin_url', models.CharField(blank=True, max_length=200, null=True)),
('personal_website', models.CharField(blank=True, max_length=200, null=True)),
('team_type', models.CharField(
choices=[
('Team', 'Team'),
('GSoC Participants and Interns', 'GSoC Participants and Interns'),
('Contributors', 'Contributors')
],
max_length=50)),
('github_url', models.URLField(blank=True, null=True)),
('linkedin_url', models.URLField(blank=True, null=True)),
('personal_website', models.URLField(blank=True, null=True)),
('team_type', models.CharField(choices=[('Team', 'Team'), ('GSoC Participants and Interns', 'GSoC Participants and Interns'), ('Contributors', 'Contributors')], max_length=50)),
],
options={
'db_table': 'team',
@@ -21,7 +21,7 @@ COPY /requirements /code/requirements
RUN pip install -r requirements/dev.txt
COPY ./ /code/
COPY settings/dev.sample.py /code/settings/dev.py
COPY settings/dev/settings.sample.py /code/settings/dev/settings.py
CMD ["/bin/bash", "/code/docker/dev/django/container-start.sh"]
EXPOSE 8000
@@ -1,4 +1,5 @@
#!/bin/sh
cd /code && \
python manage.py migrate --noinput --settings=settings.dev.settings && \
python manage.py initsuperuser --settings=settings.dev.settings && \
python manage.py runserver --settings=settings.dev.settings 0.0.0.0:8000
@@ -1,4 +1,6 @@
#!/bin/sh
cd /code && \
python manage.py migrate --noinput --settings=settings.prod.settings && \
python manage.py initsuperuser --settings=settings.prod.settings && \
python manage.py collectstatic --noinput --settings.prod.settings && \
python manage.py runserver --settings=settings.prod.settings 0.0.0.0:8000
@@ -1,4 +1,6 @@
#!/bin/sh
cd /code && \
python manage.py migrate --noinput --settings=settings.staging.settings && \
python manage.py initsuperuser --settings=settings.staging.settings && \
python manage.py collectstatic --noinput --settings.staging.settings && \
python manage.py runserver --settings=settings.staging.settings 0.0.0.0:8000
ProTip! Use n and p to navigate between commits in a pull request.