0008-make-OzwilloInstance.domain_slug-non-unique-to-be-re.patch
hobo/contrib/ozwillo/migrations/0003_auto_20180524_0828.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
# Generated by Django 1.11.13 on 2018-05-24 08:28 |
|
3 |
from __future__ import unicode_literals |
|
4 | ||
5 |
from django.db import migrations, models |
|
6 | ||
7 | ||
8 |
class Migration(migrations.Migration): |
|
9 | ||
10 |
dependencies = [ |
|
11 |
('ozwillo', '0002_auto_20180517_1047'), |
|
12 |
] |
|
13 | ||
14 |
operations = [ |
|
15 |
migrations.AlterField( |
|
16 |
model_name='ozwilloinstance', |
|
17 |
name='domain_slug', |
|
18 |
field=models.CharField(max_length=250), |
|
19 |
), |
|
20 |
] |
hobo/contrib/ozwillo/models.py | ||
---|---|---|
54 | 54 |
state = models.CharField(max_length=16, default=STATE_NEW, choices=STATES) |
55 | 55 |
created = models.DateTimeField(auto_now_add=True) |
56 | 56 |
modified = models.DateTimeField(auto_now=True) |
57 |
domain_slug = models.CharField(max_length=250, unique=True)
|
|
57 |
domain_slug = models.CharField(max_length=250) |
|
58 | 58 |
external_ozwillo_id = models.CharField(max_length=450, unique=True) |
59 | 59 |
deploy_data = models.TextField(null=True) |
60 | 60 | |
... | ... | |
259 | 259 |
'delete_tenant', '--force-drop', tenant |
260 | 260 |
]) |
261 | 261 | |
262 |
self.delete() |
|
263 | 262 |
logger.info(u'ozwillo: destroy finished') |
263 |
self.state = self.STATE_DESTROYED |
|
264 |
self.save() |
|
264 | 265 | |
265 | 266 | |
266 | 267 |
def run_command(args): |
hobo/contrib/ozwillo/views.py | ||
---|---|---|
85 | 85 |
return HttpResponseBadRequest('missing parameter "organization_name"') |
86 | 86 | |
87 | 87 |
org_name = slugify(data['organization_name']) |
88 |
if OzwilloInstance.objects.filter(domain_slug=org_name): |
|
88 |
# forbid creation of an instance if a not destroyed previous one exists |
|
89 |
if OzwilloInstance.objects.exclude(state=OzwilloInstance.STATE_DESTROYED).filter(domain_slug=org_name): |
|
89 | 90 |
logger.warning(u'ozwillo: instance %s already exists', org_name) |
90 | 91 |
return HttpResponseBadRequest('instance %s already exists' % org_name) |
91 | 92 | |
92 |
- |