Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
af96cbff
Commit
af96cbff
authored
Jan 10, 2013
by
Giorgos Korfiatis
Browse files
Add an id for a chain of applications; this is also the project id
parent
5006fe59
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
snf-astakos-app/astakos/im/migrations/0054_auto__add_chain__add_field_projectapplication_chain.py
0 → 100644
View file @
af96cbff
This diff is collapsed.
Click to expand it.
snf-astakos-app/astakos/im/models.py
View file @
af96cbff
...
...
@@ -1171,6 +1171,16 @@ USER_STATUS_DISPLAY = {
-
1
:
_
(
'Not a member'
),
}
class
Chain
(
models
.
Model
):
chain
=
models
.
AutoField
(
primary_key
=
True
)
def
new_chain
():
c
=
Chain
.
objects
.
create
()
chain
=
c
.
chain
c
.
delete
()
return
chain
class
ProjectApplication
(
models
.
Model
):
PENDING
,
APPROVED
,
REPLACED
,
UNKNOWN
=
'Pending'
,
'Approved'
,
'Replaced'
,
'Unknown'
applicant
=
models
.
ForeignKey
(
...
...
@@ -1186,6 +1196,7 @@ class ProjectApplication(models.Model):
related_name
=
'projects_owned'
,
db_index
=
True
)
chain
=
models
.
IntegerField
(
db_index
=
True
)
precursor_application
=
models
.
OneToOneField
(
'ProjectApplication'
,
null
=
True
,
blank
=
True
,
...
...
@@ -1287,17 +1298,12 @@ class ProjectApplication(models.Model):
return
None
def
_get_project_for_update
(
self
):
precursor
=
self
while
precursor
:
try
:
objects
=
Project
.
objects
.
select_for_update
()
project
=
objects
.
get
(
application
=
precursor
)
return
project
except
Project
.
DoesNotExist
:
pass
precursor
=
precursor
.
precursor_application
return
None
try
:
objects
=
Project
.
objects
.
select_for_update
()
project
=
objects
.
get
(
id
=
self
.
chain
)
return
project
except
Project
.
DoesNotExist
:
return
None
def
approve
(
self
,
approval_user
=
None
):
"""
...
...
@@ -1335,7 +1341,7 @@ class ProjectApplication(models.Model):
new_project
=
False
if
project
is
None
:
new_project
=
True
project
=
Project
(
creation_date
=
now
)
project
=
Project
(
id
=
self
.
chain
,
creation_date
=
now
)
project
.
name
=
new_project_name
project
.
application
=
self
...
...
@@ -1365,6 +1371,9 @@ def submit_application(**kw):
if
precursor
is
not
None
:
precursor
.
state
=
ProjectApplication
.
REPLACED
precursor
.
save
()
application
.
chain
=
precursor
.
chain
else
:
application
.
chain
=
new_chain
()
application
.
save
()
application
.
resource_policies
=
resource_policies
...
...
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