Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csentry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Anders Harrisson
csentry
Commits
68faf9f2
Commit
68faf9f2
authored
6 years ago
by
Benjamin Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Display host creation date and user
Add new jinja2 filter to format datetime
parent
a89deccd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/factory.py
+3
-0
3 additions, 0 deletions
app/factory.py
app/templates/network/view_host.html
+4
-0
4 additions, 0 deletions
app/templates/network/view_host.html
app/utils.py
+8
-0
8 additions, 0 deletions
app/utils.py
with
15 additions
and
0 deletions
app/factory.py
+
3
−
0
View file @
68faf9f2
...
@@ -27,6 +27,7 @@ from .api.user import bp as user_api
...
@@ -27,6 +27,7 @@ from .api.user import bp as user_api
from
.api.inventory
import
bp
as
inventory_api
from
.api.inventory
import
bp
as
inventory_api
from
.api.network
import
bp
as
network_api
from
.api.network
import
bp
as
network_api
from
.commands
import
register_cli
from
.commands
import
register_cli
from
.
import
utils
def
create_app
(
config
=
None
):
def
create_app
(
config
=
None
):
...
@@ -37,6 +38,8 @@ def create_app(config=None):
...
@@ -37,6 +38,8 @@ def create_app(config=None):
app
.
config
.
from_envvar
(
'
LOCAL_SETTINGS
'
,
silent
=
True
)
app
.
config
.
from_envvar
(
'
LOCAL_SETTINGS
'
,
silent
=
True
)
app
.
config
.
update
(
config
or
{})
app
.
config
.
update
(
config
or
{})
app
.
jinja_env
.
filters
[
'
datetimeformat
'
]
=
utils
.
format_datetime
if
not
app
.
debug
:
if
not
app
.
debug
:
import
logging
import
logging
# Send ERROR via mail
# Send ERROR via mail
...
...
This diff is collapsed.
Click to expand it.
app/templates/network/view_host.html
+
4
−
0
View file @
68faf9f2
...
@@ -34,6 +34,10 @@
...
@@ -34,6 +34,10 @@
{% endif %}
{% endif %}
<dt
class=
"col-sm-3"
>
Description
</dt>
<dt
class=
"col-sm-3"
>
Description
</dt>
<dd
class=
"col-sm-9"
>
{{ host.description }}
</dd>
<dd
class=
"col-sm-9"
>
{{ host.description }}
</dd>
<dt
class=
"col-sm-3"
>
Created by
</dt>
<dd
class=
"col-sm-9"
>
{{ host.user }}
</dd>
<dt
class=
"col-sm-3"
>
Created at
</dt>
<dd
class=
"col-sm-9"
>
{{ host.created_at | datetimeformat }}
</dd>
</dl>
</dl>
</div>
</div>
{% if host.device_type.name.startswith('Virtual') and current_user.is_admin %}
{% if host.device_type.name.startswith('Virtual') and current_user.is_admin %}
...
...
This diff is collapsed.
Click to expand it.
app/utils.py
+
8
−
0
View file @
68faf9f2
...
@@ -210,3 +210,11 @@ def pluralize(singular):
...
@@ -210,3 +210,11 @@ def pluralize(singular):
return
singular
+
'
s
'
return
singular
+
'
s
'
else
:
else
:
return
singular
+
'
es
'
return
singular
+
'
es
'
def
format_datetime
(
value
,
format
=
'
%Y-%m-%d %H:%M
'
):
"""
Format a datetime to string
Function used as a jinja2 filter
"""
return
value
.
strftime
(
format
)
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