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
Rex Dri
Rex Dri
Commits
97cab068
Commit
97cab068
authored
Aug 19, 2018
by
Florent Chehab
Browse files
Scholarship module added, not tested
parent
e7310329
Changes
3
Hide whitespace changes
Inline
Side-by-side
rex/admin.py
View file @
97cab068
...
...
@@ -4,11 +4,9 @@ from reversion_compare.admin import CompareVersionAdmin
from
rex.models.university
import
University
,
MainCampus
from
rex.models.location
import
Country
,
City
from
rex.models.module
import
BasicModule
admin
.
site
.
register
(
Country
)
admin
.
site
.
register
(
City
)
admin
.
site
.
register
(
BasicModule
)
admin
.
site
.
register
(
University
,
CompareVersionAdmin
)
admin
.
site
.
register
(
MainCampus
,
CompareVersionAdmin
)
rex/models/module/basicModule.py
View file @
97cab068
from
django.db
import
models
from
rex.models.tools
import
UsefullLinksField
from
rex.models.module
import
Module
class
BasicModule
(
models
.
Model
):
class
BasicModule
(
Module
):
comment
=
models
.
TextField
()
usefull_links
=
UsefullLinksField
()
#
class Meta:
#
abstract = True
class
Meta
:
abstract
=
True
rex/models/module/scholarship.py
0 → 100644
View file @
97cab068
from
django.db
import
models
from
rex.models.module
import
BasicModule
from
django.core.exceptions
import
ValidationError
from
django.core.validators
import
MinValueValidator
class
Scholarship
(
BasicModule
):
type
=
models
.
CharField
(
required
=
True
,
max_length
=
200
)
currency
=
models
.
CharField
(
required
=
True
,
max_length
=
50
)
amount_min
=
models
.
DecimalField
(
max_digits
=
20
,
decimal_places
=
2
,
validators
=
[
MinValueValidator
(
0
)]
)
amount_max
=
models
.
DecimalField
(
max_digits
=
20
,
decimal_places
=
2
,
validators
=
[
MinValueValidator
(
0
)]
)
# Need custom validation
def
clean
(
self
,
*
args
,
**
kwargs
):
if
self
.
amount_max
<
self
.
amount_min
:
raise
ValidationError
(
"Amount_max should be greater or equal than amount_min"
)
super
(
Scholarship
,
self
).
clean
(
*
args
,
**
kwargs
)
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
full_clean
()
super
(
Scholarship
,
self
).
save
(
*
args
,
**
kwargs
)
class
Meta
:
abstract
=
True
Write
Preview
Supports
Markdown
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