Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
5ded69c8
Commit
5ded69c8
authored
Aug 29, 2018
by
Florent Chehab
Browse files
Tag model added
parent
b8511f0e
Changes
7
Hide whitespace changes
Inline
Side-by-side
.vscode/settings.json
View file @
5ded69c8
...
...
@@ -6,11 +6,12 @@
"**/.hg"
:
true
,
"**/CVS"
:
true
,
"**/.DS_Store"
:
true
,
"**/__pycache__"
:
true
,
"**/*.pyc"
:
true
,
"htmlcov"
:
false
,
"env"
:
true
,
".coverage"
:
true
"**/__pycache__"
:
true
,
"**/*.pyc"
:
true
,
"htmlcov"
:
false
,
"env"
:
true
,
".coverage"
:
true
,
".pytest_cache"
:
true
,
},
"cSpell.language"
:
"en,fr-FR,fr"
,
"python.linting.flake8Enabled"
:
true
...
...
backend/admin.py
View file @
5ded69c8
...
...
@@ -50,6 +50,8 @@ from backend.models.user import PreviousDepartureFeedback
from
backend.models.user
import
UserData
from
backend.models.my_model
import
PendingModeration
from
backend.models.module
import
Tag
CLASSIC_MODELS
=
[
Country
,
...
...
@@ -65,7 +67,8 @@ CLASSIC_MODELS = [
PreviousDeparture
,
PreviousDepartureFeedback
,
UserData
,
PendingModeration
PendingModeration
,
Tag
]
VERSIONNED_MODELS
=
[
...
...
backend/generate/api_config.yml
View file @
5ded69c8
-
model
:
Tag
viewset
:
TagViewSet
import_location
:
module
api_end_point
:
tag
-
model
:
Country
viewset
:
CountryViewSet
import_location
:
location
...
...
backend/migrations/0022_tag.py
0 → 100644
View file @
5ded69c8
# Generated by Django 2.0.3 on 2018-08-29 16:06
from
django.conf
import
settings
import
django.contrib.postgres.fields.jsonb
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'backend'
,
'0021_auto_20180828_2128'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Tag'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'moderated_on'
,
models
.
DateTimeField
(
null
=
True
)),
(
'updated_on'
,
models
.
DateTimeField
(
null
=
True
)),
(
'name'
,
models
.
CharField
(
max_length
=
100
)),
(
'config'
,
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
()),
(
'moderated_by'
,
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
related_name
=
'+'
,
to
=
settings
.
AUTH_USER_MODEL
)),
(
'updated_by'
,
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
related_name
=
'+'
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
options
=
{
'abstract'
:
False
,
},
),
]
backend/migrations/0023_auto_20180829_1815.py
0 → 100644
View file @
5ded69c8
# Generated by Django 2.0.3 on 2018-08-29 16:15
import
django.contrib.postgres.fields.jsonb
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'backend'
,
'0022_tag'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'tag'
,
name
=
'config'
,
field
=
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
(
blank
=
True
,
default
=
dict
),
),
]
backend/models/module/__init__.py
View file @
5ded69c8
...
...
@@ -3,4 +3,4 @@ from .scholarship import Scholarship, ScholarshipSerializer, ScholarshipViewSet
from
.photo
import
Photo
,
PhotoSerializer
,
PhotoViewSet
# noqa: F401
from
.driRestrictedModule
import
DriRestrictedModule
,
DriRestrictedModuleSerializer
,
DriRestrictedModuleViewSet
# noqa: F401
from
.currency
import
Currency
,
CurrencyViewSet
,
CurrencySerializer
# noqa: F401
# MyModelVersionned, MyModelVersionnedSerializer
# noqa: F401
from
.tag
import
Tag
,
TagSerializer
,
TagViewSet
# noqa: F401
backend/models/module/tag.py
0 → 100644
View file @
5ded69c8
from
django.db
import
models
from
rest_framework
import
permissions
from
backend.models.my_model
import
MyModel
,
MyModelSerializer
,
MyModelViewSet
from
backend.models.tools
import
IsAdminOrReadOnly
from
django.contrib.postgres.fields
import
JSONField
class
Tag
(
MyModel
):
"""
TODO description
"""
name
=
models
.
CharField
(
max_length
=
100
)
config
=
JSONField
(
blank
=
True
,
default
=
dict
)
class
TagSerializer
(
MyModelSerializer
):
class
Meta
:
model
=
Tag
fields
=
'__all__'
class
TagViewSet
(
MyModelViewSet
):
permission_classes
=
(
permissions
.
IsAuthenticated
,
IsAdminOrReadOnly
)
queryset
=
Tag
.
objects
.
all
()
# pylint: disable=E1101
serializer_class
=
TagSerializer
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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