1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 15:45:23 +00:00

Added migration

This commit is contained in:
Retspen 2015-03-25 11:36:37 +02:00
parent 5ccc813336
commit 1f68e8c5ed
7 changed files with 71 additions and 40 deletions

View file

@ -0,0 +1,13 @@
[
{
"model": "auth.user",
"pk": 1,
"fields": {
"username": "admin",
"password": "pbkdf2_sha256$15000$Qkg4dizzDzpM$SRXEyTJR5d198JZes4LVhFXlWQYJGOAjQhnfhGXQLtc=",
"is_active": true,
"is_superuser": true,
"is_staff": true
}
}
]

View file

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.contrib.auth.models import User
def add_admin(apps, schema_editor):
add_user = User.objects.create_user("admin", None, "admin")
add_user.is_active = True
add_user.is_superuser = True
add_user.is_staff = True
add_user.save()
class Migration(migrations.Migration):
dependencies = [
('accounts', '0001_initial'),
]
operations = [
migrations.RunPython(add_admin),
]

View file

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('accounts', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='userinstance',
name='is_block',
field=models.BooleanField(default=False),
preserve_default=True,
),
]

View file

@ -1,18 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('accounts', '0002_userinstance_is_block'),
]
operations = [
migrations.RemoveField(
model_name='userinstance',
name='is_block',
),
]

View file

@ -31,6 +31,8 @@ def profile(request):
oldpasswd = request.POST.get('oldpasswd', '')
password1 = request.POST.get('passwd1', '')
password2 = request.POST.get('passwd2', '')
if not password1 or not password2:
error_messages.append("Passwords didn't enter")
if password1 and password2 and password1 != password2:
error_messages.append("Passwords don't match")
if not user.check_password(oldpasswd):
@ -74,7 +76,7 @@ def accounts(request):
user_id = request.POST.get('user_id', '')
user_pass = request.POST.get('user_pass', '')
user_edit = User.objects.get(id=user_id)
user.password = user_pass
user_edit.set_password(user_pass)
user_edit.save()
return HttpResponseRedirect(request.get_full_path())
if 'block' in request.POST:

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def add_favors(apps, schema_editor):
Flavor = apps.get_model("create", "Flavor")
add_flavor = Flavor(label="micro", vcpu="1", memory="512", disk="20")
add_flavor.save()
add_flavor = Flavor(label="mini", vcpu="2", memory="1024", disk="30")
add_flavor.save()
add_flavor = Flavor(label="small", vcpu="2", memory="2048", disk="40")
add_flavor.save()
add_flavor = Flavor(label="medium", vcpu="2", memory="4096", disk="60")
add_flavor.save()
add_flavor = Flavor(label="large", vcpu="4", memory="8192", disk="80")
add_flavor.save()
add_flavor = Flavor(label="xlarge", vcpu="8", memory="16384", disk="160")
add_flavor.save()
class Migration(migrations.Migration):
dependencies = [
('create', '0001_initial'),
]
operations = [
migrations.RunPython(add_favors),
]

View file

@ -2,11 +2,13 @@
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('instances', '0001_initial'),
]
@ -16,8 +18,9 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('message', models.CharField(max_length=255)),
('date', models.DateTimeField()),
('date', models.DateTimeField(auto_now=True)),
('instance', models.ForeignKey(to='instances.Instance')),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
options={
},