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
1f786c1c
Commit
1f786c1c
authored
7 years ago
by
Benjamin Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Refactor QR Codes page
parent
06693cea
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/main/views.py
+11
-10
11 additions, 10 deletions
app/main/views.py
app/templates/base.html
+1
-1
1 addition, 1 deletion
app/templates/base.html
app/templates/qrcodes.html
+10
-6
10 additions, 6 deletions
app/templates/qrcodes.html
with
22 additions
and
17 deletions
app/main/views.py
+
11
−
10
View file @
1f786c1c
...
...
@@ -102,17 +102,18 @@ def view_item(ics_id):
return
render_template
(
'
view_item.html
'
,
item
=
item
.
to_dict
(
long
=
True
))
@bp.route
(
'
/qrcodes
'
)
@bp.route
(
'
/qrcodes
/<kind>
'
)
@login_required
def
qrcodes
():
codes
=
{}
for
model
in
(
models
.
Action
,
models
.
Manufacturer
,
models
.
Model
,
models
.
Location
,
models
.
Status
):
items
=
db
.
session
.
query
(
model
).
order_by
(
model
.
name
)
images
=
[{
'
name
'
:
item
.
name
,
'
data
'
:
utils
.
image_to_base64
(
item
.
image
())}
for
item
in
items
]
codes
[
model
.
__name__
]
=
images
return
render_template
(
'
qrcodes.html
'
,
codes
=
codes
)
def
qrcodes
(
kind
=
'
Action
'
):
try
:
model
=
getattr
(
models
,
kind
)
except
AttributeError
:
raise
utils
.
CSEntryError
(
f
"
Unknown model
'
{
kind
}
'"
,
status_code
=
422
)
items
=
db
.
session
.
query
(
model
).
order_by
(
model
.
name
)
images
=
[{
'
name
'
:
item
.
name
,
'
data
'
:
utils
.
image_to_base64
(
item
.
image
())}
for
item
in
items
]
return
render_template
(
'
qrcodes.html
'
,
kind
=
kind
,
images
=
images
)
@bp.route
(
'
/attributes
'
,
methods
=
(
'
GET
'
,
'
POST
'
))
...
...
This diff is collapsed.
Click to expand it.
app/templates/base.html
+
1
−
1
View file @
1f786c1c
...
...
@@ -26,7 +26,7 @@
<a
class=
"nav-item nav-link {{ is_active(path.startswith("
/
items
"))
}}"
href=
"{{ url_for('main.list_items') }}"
>
Items
</a>
<a
class=
"nav-item nav-link {{ is_active(path.startswith("
/
hosts
"))
}}"
href=
"{{ url_for('main.list_hosts') }}"
>
Hosts
</a>
<a
class=
"nav-item nav-link {{ is_active(path.startswith("
/
attributes
"))
}}"
href=
"{{ url_for('main.attributes') }}"
>
Attributes
</a>
<a
class=
"nav-item nav-link {{ is_active(path.startswith("
/
qrcodes
"))
}}"
href=
"{{ url_for('main.qrcodes') }}"
>
QR Codes
</a>
<a
class=
"nav-item nav-link {{ is_active(path.startswith("
/
qrcodes
"))
}}"
href=
"{{ url_for('main.qrcodes'
, kind='Action'
) }}"
>
QR Codes
</a>
{% if current_user.is_authenticated and current_user.is_admin %}
<a
class=
"nav-item nav-link"
href=
"{{ url_for('admin.index') }}"
>
Admin
</a>
{% endif %}
...
...
This diff is collapsed.
Click to expand it.
app/templates/qrcodes.html
+
10
−
6
View file @
1f786c1c
...
...
@@ -3,10 +3,16 @@
{% block title %}QR Codes - CSEntry{% endblock %}
{% block main %}
{% for name, images in codes.items() %}
<div
class=
"row"
>
<h2>
{{ name }} codes
</h2>
</div>
<ul
class=
"nav nav-tabs"
>
{% for item in ('Action', 'Manufacturer', 'Model', 'Location', 'Status') %}
<li
class=
"nav-item"
>
<a
class=
"nav-link {% if kind == item %}active{% endif %}"
href=
"{{ url_for('main.qrcodes', kind=item) }}"
>
{{ item }}
</a>
</li>
{% endfor %}
</ul>
<br>
<div
class=
"row"
>
{% for image in images %}
<div
class=
"col-md-3"
>
...
...
@@ -19,6 +25,4 @@
</div>
{% endfor %}
</div>
<hr
class=
"separator"
>
{% endfor %}
{%- endblock %}
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