Commit edeaebfd authored by Florent Chehab's avatar Florent Chehab

More loading scripts

parent 77e71707
Pipeline #26802 passed with stages
in 2 minutes and 10 seconds
[
{
"name": "photos",
"config": {
"photos": {
"type": "list",
"content": {
"url": {
"type": "url",
"required": true,
"validators": {
"extension": [
"jpg",
"jpeg",
"png",
"svg"
]
}
},
"title": {
"type": "text",
"required": true,
"validators": {
"max_length": 200
}
},
"licence": {
"type": "text",
"required": false,
"validators": {
"max_length": 200
}
},
"description": {
"type": "text",
"required": false,
"validators": {
"max_length": 500
}
}
},
"required": true
}
}
}
]
\ No newline at end of file
from .loading_scripts import LoadAdminUser
from .loading_scripts import LoadCountries
from .loading_scripts import LoadUniversities
from .loading_scripts import LoadTags
def load_all():
admin = LoadAdminUser().get()
LoadCountries(admin).load()
LoadUniversities(admin).load()
LoadTags(admin).load()
from .loadAdminUser import LoadAdminUser # noqa: F401
from .loadCountries import LoadCountries # noqa: F401
from .loadUniversities import LoadUniversities # noqa: F401
from .loadTags import LoadTags # noqa: F401
from backend.models.tag import Tag
import os
import json
from .loadGeneric import LoadGeneric
class LoadTags(LoadGeneric):
def __init__(self, admin):
self.admin = admin
def load(self):
tmp = os.path.join(os.path.realpath(__file__),
'../../assets/tags.json')
tags_path = os.path.abspath(tmp)
with open(tags_path) as f:
tags = json.load(f)
for tag in tags:
t = Tag(name=tag['name'], config=tag['config'])
t.save()
self.add_info(t, self.admin)
# Generated by Django 2.0.3 on 2018-08-30 20:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('backend', '0002_auto_20180830_1623'),
]
operations = [
migrations.AlterUniqueTogether(
name='cityphoto',
unique_together=set(),
),
migrations.RemoveField(
model_name='cityphoto',
name='city',
),
migrations.RemoveField(
model_name='cityphoto',
name='moderated_by',
),
migrations.RemoveField(
model_name='cityphoto',
name='updated_by',
),
migrations.AlterUniqueTogether(
name='countryphoto',
unique_together=set(),
),
migrations.RemoveField(
model_name='countryphoto',
name='country',
),
migrations.RemoveField(
model_name='countryphoto',
name='moderated_by',
),
migrations.RemoveField(
model_name='countryphoto',
name='updated_by',
),
migrations.AlterUniqueTogether(
name='universityphoto',
unique_together=set(),
),
migrations.RemoveField(
model_name='universityphoto',
name='moderated_by',
),
migrations.RemoveField(
model_name='universityphoto',
name='university',
),
migrations.RemoveField(
model_name='universityphoto',
name='updated_by',
),
migrations.AlterField(
model_name='tag',
name='name',
field=models.CharField(max_length=100, unique=True),
),
migrations.DeleteModel(
name='CityPhoto',
),
migrations.DeleteModel(
name='CountryPhoto',
),
migrations.DeleteModel(
name='UniversityPhoto',
),
]
......@@ -9,7 +9,7 @@ class Tag(MyModel):
"""
TODO description
"""
name = models.CharField(max_length=100)
name = models.CharField(max_length=100, unique=True)
config = JSONField(blank=True, default=dict)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment