Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Kontr 2.0
Portal API Backend
Commits
009498f8
Verified
Commit
009498f8
authored
Apr 07, 2019
by
Peter Stanko
Browse files
CHANGELOG; Versions
parent
5ae6d4de
Changes
2
Show whitespace changes
Inline
Side-by-side
portal/config.py
View file @
009498f8
...
...
@@ -31,6 +31,7 @@ class Config(object):
# FRONTEND
FRONTEND_URL
=
os
.
getenv
(
'FRONTEND_URL'
,
'http://localhost:4200'
)
FRONTEND_LOCAL_REPO
=
os
.
getenv
(
'FRONTEND_LOCAL_REPO'
,
PROJECT_ROOT
/
'..'
/
'portal-frontend'
)
# Secrets and JWT Config
SECRET_KEY
=
os
.
environ
.
get
(
'SECRET_KEY'
)
or
'you-will-never-guess'
...
...
portal/rest/management.py
View file @
009498f8
from
pathlib
import
Path
from
flask_restplus
import
Namespace
,
fields
from
portal
import
logger
from
portal.rest.custom_resource
import
CustomResource
from
portal.tools
import
paths
management_namespace
=
Namespace
(
'management'
)
log
=
logger
.
get_logger
(
__name__
)
...
...
@@ -10,9 +13,33 @@ status_schema = management_namespace.model('StatusSchema', {
'status'
:
fields
.
String
()
})
versions_schema
=
management_namespace
.
model
(
'VersionsSchema'
,
{
'status'
:
fields
.
String
()
})
@
management_namespace
.
route
(
'/status'
)
class
StatusReport
(
CustomResource
):
@
management_namespace
.
marshal_with
(
status_schema
)
def
get
(
self
):
return
dict
(
status
=
"works"
)
def
extract_version
(
path
):
import
git
repo
=
git
.
Repo
(
path
)
return
{
'commit_id'
:
repo
.
head
.
commit
.
commit_id
,
'commit_message'
:
repo
.
head
.
commit
.
message
,
}
@
management_namespace
.
route
(
'/versions'
)
class
VersionsReport
(
CustomResource
):
@
management_namespace
.
marshal_with
(
versions_schema
)
def
get
(
self
):
versions
=
dict
(
portal
=
extract_version
(
paths
.
ROOT_DIR
))
fe_path
=
self
.
flask_app
.
config
.
get
(
'FRONTEND_LOCAL_REPO'
)
if
fe_path
and
Path
(
fe_path
).
exists
():
versions
[
'frontend'
]
=
extract_version
(
fe_path
)
return
versions
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