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
aa616a2a
Commit
aa616a2a
authored
Sep 11, 2018
by
Florent Chehab
Browse files
Corrected usefull => useful
and return model
parent
7768f71e
Changes
11
Hide whitespace changes
Inline
Side-by-side
backend/migrations/0009_auto_20180911_1622.py
0 → 100644
View file @
aa616a2a
# Generated by Django 2.0.3 on 2018-09-11 14:22
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'backend'
,
'0008_auto_20180911_1147'
),
]
operations
=
[
migrations
.
RenameField
(
model_name
=
'campus'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'campustaggeditem'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'citytaggeditem'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'countrydri'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'countryscholarship'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'countrytaggeditem'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'universitydri'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'universityinfo'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'universityscholarship'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'universitysemestersdates'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
migrations
.
RenameField
(
model_name
=
'universitytaggeditem'
,
old_name
=
'usefull_links'
,
new_name
=
'useful_links'
,
),
]
backend/models/abstract/basic_module/basicModule.py
View file @
aa616a2a
...
...
@@ -14,7 +14,7 @@ IMPORTANCE_LEVEL = (
class
BasicModule
(
MyModelVersionned
):
comment
=
models
.
TextField
(
blank
=
True
,
default
=
""
)
useful
l
_links
=
JSONField
(
default
=
list
)
useful_links
=
JSONField
(
default
=
list
)
importance_level
=
models
.
CharField
(
max_length
=
2
,
choices
=
IMPORTANCE_LEVEL
,
...
...
@@ -28,8 +28,8 @@ class BasicModule(MyModelVersionned):
class
BasicModuleSerializer
(
MyModelVersionnedSerializer
):
def
my_validate
(
self
,
attrs
):
content
=
{
'useful
l
_links'
:
attrs
[
'useful
l
_links'
]}
config
=
{
'useful
l
_links'
:
USEFULL_LINKS_CONFIG
}
content
=
{
'useful_links'
:
attrs
[
'useful_links'
]}
config
=
{
'useful_links'
:
USEFULL_LINKS_CONFIG
}
validate_content_against_config
(
config
,
content
)
return
attrs
...
...
backend/models/abstract/my_model/myModelSerializer.py
View file @
aa616a2a
...
...
@@ -34,7 +34,7 @@ class MyModelSerializer(MySerializerWithJSON):
model_config
=
serializers
.
SerializerMethodField
()
# For easier handling on the client side, we force an id field
# this is useful
l
when a model has a dedicated primary key
# this is useful when a model has a dedicated primary key
id
=
serializers
.
SerializerMethodField
()
def
get_model_config
(
self
,
obj
=
None
):
...
...
backend/models/user/previousDeparture.py
View file @
aa616a2a
...
...
@@ -15,7 +15,7 @@ class PreviousDeparture(MyModel):
university
=
models
.
ForeignKey
(
University
,
on_delete
=
models
.
PROTECT
)
specialty
=
models
.
ForeignKey
(
Specialty
,
on_delete
=
models
.
PROTECT
)
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
# Useful
l
to relink a departure with a user
# Useful to relink a departure with a user
Utc_departure_id
=
models
.
IntegerField
()
is_anonymous
=
models
.
BooleanField
()
...
...
backend/tests/test_moderation.py
View file @
aa616a2a
...
...
@@ -221,7 +221,7 @@ class ModerationTestCase(WithUserTestCase):
data
=
{
"comment"
:
""
,
"useful
l
_links"
:
[],
"useful_links"
:
[],
"universities"
:
[
c
.
pk
]
}
api_end_point
=
"/api/"
+
\
...
...
backend/tests/test_scholarhip_validate.py
View file @
aa616a2a
...
...
@@ -9,7 +9,7 @@ class ScholarshipTestCase(TestCase):
def
test_scholarhip_validation
(
self
):
ser
=
ScholarshipSerializer
()
attrs
=
{
'useful
l
_links'
:
[],
'useful_links'
:
[],
'comment'
:
''
}
with
pytest
.
raises
(
ValidationError
):
...
...
backend/tests/test_semester_dates_validate.py
View file @
aa616a2a
...
...
@@ -13,7 +13,7 @@ class SemesterDatesTestCase(TestCase):
def
build
(
l
):
tmp
=
{
sem
:
val
for
sem
,
val
in
zip
(
semesters
,
l
)}
tmp
[
'comment'
]
=
""
tmp
[
'useful
l
_links'
]
=
[]
tmp
[
'useful_links'
]
=
[]
return
tmp
def
_test_attrs_error
(
attrs
):
...
...
backend/utils/__get_model_config.py
View file @
aa616a2a
...
...
@@ -6,6 +6,9 @@ def get_model_config(model):
for
obj
in
api_config
:
if
obj
[
'model'
]
==
model
:
return
{
"moderation_level"
:
obj
[
"moderation_level"
]}
return
{
"moderation_level"
:
obj
[
"moderation_level"
],
"model"
:
model
}
raise
Exception
(
"Model not found in API configuraiton, cannot process !"
)
backend/validators/tag/tagged_item_validation.py
View file @
aa616a2a
...
...
@@ -36,7 +36,7 @@ def validate_content_against_config(config, content):
elif
field_type
==
'photos'
:
validate_content_against_config
({
"photos"
:
PHOTOS_TAG_CONFIG
},
{
"photos"
:
field_submitted
})
elif
field_type
==
'useful
l
_links'
:
elif
field_type
==
'useful_links'
:
validate_content_against_config
({
"ul"
:
USEFULL_LINKS_CONFIG
},
{
"ul"
:
field_submitted
})
elif
field_type
==
'array'
:
...
...
backend/validators/tag/tags_config/__init__.py
View file @
aa616a2a
from
.photos
import
PHOTOS_TAG_CONFIG
# noqa: F401
from
.useful
l
_links
import
USEFULL_LINKS_CONFIG
# noqa: F401
from
.useful_links
import
USEFULL_LINKS_CONFIG
# noqa: F401
backend/validators/tag/tags_config/useful
l
_links.py
→
backend/validators/tag/tags_config/useful_links.py
View file @
aa616a2a
File moved
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