Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Julien Jerphanion
Rex Dri
Commits
edeaebfd
Commit
edeaebfd
authored
Aug 30, 2018
by
Florent Chehab
Browse files
More loading scripts
parent
77e71707
Changes
6
Hide whitespace changes
Inline
Side-by-side
backend/load_data/assets/tags.json
0 → 100644
View file @
edeaebfd
[
{
"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
backend/load_data/load_all.py
View file @
edeaebfd
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
()
backend/load_data/loading_scripts/__init__.py
View file @
edeaebfd
from
.loadAdminUser
import
LoadAdminUser
# noqa: F401
from
.loadCountries
import
LoadCountries
# noqa: F401
from
.loadUniversities
import
LoadUniversities
# noqa: F401
from
.loadTags
import
LoadTags
# noqa: F401
backend/load_data/loading_scripts/loadTags.py
0 → 100644
View file @
edeaebfd
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
)
backend/migrations/0003_auto_20180830_2218.py
0 → 100644
View file @
edeaebfd
# 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'
,
),
]
backend/models/tag/tag.py
View file @
edeaebfd
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment