Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flamenco-worker-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
flamenco-worker-python
Commits
8b2c6571
Commit
8b2c6571
authored
9 years ago
by
Francesco Siddi
Browse files
Options
Downloads
Patches
Plain Diff
Server: minor cleanup for project module
parent
f36ec524
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flamenco/server/application/modules/projects/__init__.py
+10
-13
10 additions, 13 deletions
flamenco/server/application/modules/projects/__init__.py
with
10 additions
and
13 deletions
flamenco/server/application/modules/projects/__init__.py
+
10
−
13
View file @
8b2c6571
from
flask
import
jsonify
from
flask
import
request
from
flask.ext.restful
import
Resource
from
flask.ext.restful
import
Resource
from
flask.ext.restful
import
fields
from
flask.ext.restful
import
fields
from
flask.ext.restful
import
marshal_with
from
flask.ext.restful
import
marshal_with
...
@@ -10,10 +8,9 @@ from application.modules.settings.model import Setting
...
@@ -10,10 +8,9 @@ from application.modules.settings.model import Setting
from
application.modules.jobs.model
import
Job
from
application.modules.jobs.model
import
Job
parser
=
reqparse
.
RequestParser
()
parser_project
=
reqparse
.
RequestParser
()
parser
.
add_argument
(
'
name
'
,
type
=
str
)
parser_project
.
add_argument
(
'
name
'
,
type
=
str
)
parser
.
add_argument
(
'
is_active
'
,
type
=
bool
)
parser_project
.
add_argument
(
'
is_active
'
,
type
=
bool
)
project_fields
=
{
project_fields
=
{
'
id
'
:
fields
.
Integer
,
'
id
'
:
fields
.
Integer
,
...
@@ -34,11 +31,10 @@ class ProjectListApi(Resource):
...
@@ -34,11 +31,10 @@ class ProjectListApi(Resource):
for
project
in
Project
.
query
.
all
():
for
project
in
Project
.
query
.
all
():
projects
[
project
.
id
]
=
dict
(
projects
[
project
.
id
]
=
dict
(
name
=
project
.
name
)
name
=
project
.
name
)
return
jsonify
(
projects
)
@marshal_with
(
project_fields
)
@marshal_with
(
project_fields
)
def
post
(
self
):
def
post
(
self
):
args
=
parser
.
parse_args
()
args
=
parser
_project
.
parse_args
()
project
=
Project
(
project
=
Project
(
name
=
args
[
'
name
'
])
name
=
args
[
'
name
'
])
db
.
session
.
add
(
project
)
db
.
session
.
add
(
project
)
...
@@ -47,7 +43,8 @@ class ProjectListApi(Resource):
...
@@ -47,7 +43,8 @@ class ProjectListApi(Resource):
if
args
[
'
is_active
'
]
is
not
None
:
if
args
[
'
is_active
'
]
is
not
None
:
if
args
[
'
is_active
'
]
==
True
:
if
args
[
'
is_active
'
]
==
True
:
# Check if the setting already exists
# Check if the setting already exists
setting_active_project
=
Setting
.
query
.
filter_by
(
name
=
'
active_project
'
).
first
()
setting_active_project
=
Setting
.
query
.
filter_by
(
name
=
'
active_project
'
).
first
()
if
setting_active_project
:
if
setting_active_project
:
setting_active_project
.
value
=
project
.
id
setting_active_project
.
value
=
project
.
id
else
:
else
:
...
@@ -66,13 +63,13 @@ class ProjectApi(Resource):
...
@@ -66,13 +63,13 @@ class ProjectApi(Resource):
return
project
return
project
def
delete
(
self
,
project_id
):
def
delete
(
self
,
project_id
):
setting_active_project
=
Setting
.
query
.
filter_by
(
name
=
'
active_project
'
).
first
()
setting_active_project
=
Setting
.
query
.
filter_by
(
name
=
'
active_project
'
).
first
()
if
setting_active_project
:
if
setting_active_project
:
if
setting_active_project
.
value
==
str
(
project_id
):
if
setting_active_project
.
value
==
str
(
project_id
):
setting_active_project
.
value
=
None
setting_active_project
.
value
=
None
jobs_project
=
Job
.
query
.
filter_by
(
project_id
=
project_id
).
all
()
jobs_project
=
Job
.
query
.
filter_by
(
project_id
=
project_id
).
all
()
for
job_project
in
jobs_project
:
for
job_project
in
jobs_project
:
# print '[Debug] Deleting job (%s) for project %s ' % (job_project.job_name, job_project.project_id)
db
.
session
.
delete
(
job_project
)
db
.
session
.
delete
(
job_project
)
db
.
session
.
commit
()
db
.
session
.
commit
()
project
=
Project
.
query
.
get_or_404
(
project_id
)
project
=
Project
.
query
.
get_or_404
(
project_id
)
...
@@ -82,7 +79,7 @@ class ProjectApi(Resource):
...
@@ -82,7 +79,7 @@ class ProjectApi(Resource):
@marshal_with
(
project_fields
)
@marshal_with
(
project_fields
)
def
put
(
self
,
project_id
):
def
put
(
self
,
project_id
):
args
=
parser
.
parse_args
()
args
=
parser
_project
.
parse_args
()
project
=
Project
.
query
.
get_or_404
(
project_id
)
project
=
Project
.
query
.
get_or_404
(
project_id
)
if
args
[
'
name
'
]:
if
args
[
'
name
'
]:
project
.
name
=
args
[
'
name
'
]
project
.
name
=
args
[
'
name
'
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment