Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CoopStarter Data
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Startin blox
A
applications
Coop Starter
CoopStarter Data
Commits
c4c44503
Commit
c4c44503
authored
Oct 03, 2019
by
Benoit Alessandroni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding custom country field
parent
79dd84c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
7 deletions
+32
-7
coopstarter_data/fixtures/countries.json
coopstarter_data/fixtures/countries.json
+19
-0
coopstarter_data/models.py
coopstarter_data/models.py
+13
-7
No files found.
coopstarter_data/fixtures/countries.json
0 → 100644
View file @
c4c44503
[
{
"model"
:
"coopstarter_data.country"
,
"pk"
:
1
,
"fields"
:
{
"name"
:
"France"
,
"code"
:
"AF"
}
},
{
"model"
:
"coopstarter_data.country"
,
"pk"
:
2
,
"fields"
:
{
"name"
:
"United Kingdom"
,
"code"
:
"GB"
}
}
]
coopstarter_data/models.py
View file @
c4c44503
...
...
@@ -2,7 +2,6 @@ from django.db import models
from
django.core.mail
import
send_mail
from
djangoldp.models
import
Model
from
django.conf
import
settings
from
django_countries.fields
import
CountryField
from
django.contrib.auth
import
get_user_model
from
django.db.models.signals
import
post_save
,
m2m_changed
from
django.dispatch
import
receiver
...
...
@@ -12,6 +11,13 @@ from django.utils import timezone
from
django.template
import
loader
class
Country
(
Model
):
code
=
models
.
CharField
(
max_length
=
2
,
verbose_name
=
"ISO Code"
)
name
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"Country name"
)
def
__str__
(
self
):
return
self
.
name
class
Language
(
Model
):
code
=
models
.
CharField
(
max_length
=
2
,
verbose_name
=
"ISO Code"
)
name
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"Language name"
)
...
...
@@ -60,7 +66,7 @@ class Type (Model):
class
Entrepreneur
(
Model
):
user
=
models
.
OneToOneField
(
settings
.
AUTH_USER_MODEL
,
related_name
=
"entrepreneur_profile"
)
organisation
=
models
.
ForeignKey
(
Organisation
,
null
=
True
,
on_delete
=
models
.
CASCADE
)
organisation
=
models
.
ForeignKey
(
Organisation
,
null
=
True
,
on_delete
=
models
.
CASCADE
,
related_name
=
"entrepreneurs"
)
class
Meta
:
auto_author
=
'user'
...
...
@@ -79,8 +85,8 @@ class Entrepreneur(Model):
class
Mentor
(
Model
):
user
=
models
.
OneToOneField
(
settings
.
AUTH_USER_MODEL
,
related_name
=
"mentor_profile"
)
phone
=
models
.
CharField
(
max_length
=
25
,
null
=
True
,
blank
=
True
,
verbose_name
=
'Phone number'
)
organisation
=
models
.
ForeignKey
(
Organisation
,
null
=
True
,
on_delete
=
models
.
CASCADE
)
country
=
CountryField
(
blank
=
True
)
organisation
=
models
.
ForeignKey
(
Organisation
,
null
=
True
,
on_delete
=
models
.
CASCADE
,
related_name
=
"mentors"
)
country
=
models
.
ForeignKey
(
Country
,
null
=
True
,
related_name
=
"mentors"
)
languages
=
models
.
ManyToManyField
(
Language
,
blank
=
True
)
headline
=
models
.
CharField
(
max_length
=
256
,
blank
=
True
,
verbose_name
=
'Headline or current position'
)
...
...
@@ -112,7 +118,7 @@ class Mentor(Model):
class
Review
(
Model
):
comment
=
models
.
TextField
(
verbose_name
=
"Comment"
,
blank
=
True
)
status
=
models
.
CharField
(
max_length
=
32
,
choices
=
((
'pending'
,
'Pending'
),
(
'inappropriate'
,
'Inappropriate'
),
(
'validated'
,
'Validated'
),
(
'to_improve'
,
'Improvement required'
)),
verbose_name
=
"Resource status"
,
blank
=
True
,
null
=
True
)
reviewer
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
blank
=
True
,
null
=
True
,
on_delete
=
models
.
CASCADE
,
related_name
=
'reviews'
)
reviewer
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
null
=
True
,
on_delete
=
models
.
CASCADE
,
related_name
=
'reviews'
)
class
Meta
:
owner_field
=
'reviewer'
...
...
@@ -135,7 +141,7 @@ class Resource (Model):
publication_year
=
models
.
IntegerField
(
verbose_name
=
"Publication Year"
)
language
=
models
.
ForeignKey
(
Language
,
blank
=
True
,
verbose_name
=
"Language"
,
related_name
=
'resources'
)
fields
=
models
.
ManyToManyField
(
Field
,
blank
=
True
,
related_name
=
'resources'
)
country
=
CountryField
(
verbose_name
=
"Country of publication"
,
blank
=
True
)
country
=
models
.
ForeignKey
(
Country
,
null
=
True
)
uri
=
models
.
CharField
(
max_length
=
4086
,
verbose_name
=
"Location/weblink"
)
author
=
models
.
CharField
(
max_length
=
32
,
verbose_name
=
"Author"
)
skills
=
models
.
TextField
(
verbose_name
=
"Learning outcomes/skills"
)
...
...
@@ -188,7 +194,7 @@ class Request (Model):
language
=
models
.
ForeignKey
(
Language
,
blank
=
True
,
verbose_name
=
"Language"
)
fields
=
models
.
ManyToManyField
(
Field
,
blank
=
True
)
country
=
CountryField
(
verbose_name
=
"Country of publication"
,
blank
=
True
)
country
=
models
.
ForeignKey
(
Country
,
null
=
True
)
organisation
=
models
.
ForeignKey
(
Organisation
,
on_delete
=
models
.
CASCADE
,
related_name
=
"requests"
)
skills
=
models
.
TextField
(
verbose_name
=
"Learning outcomes/skills"
)
...
...
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