Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Public contract registry
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
TO
Public contract registry
Commits
1dc9d3f3
Commit
1dc9d3f3
authored
2 years ago
by
Tomáš Valenta
Browse files
Options
Downloads
Patches
Plain Diff
add searching
parent
a4365d58
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
contracts/templates/contracts/search.html
+36
-0
36 additions, 0 deletions
contracts/templates/contracts/search.html
contracts/views.py
+27
-0
27 additions, 0 deletions
contracts/views.py
with
63 additions
and
0 deletions
contracts/templates/contracts/search.html
0 → 100644
+
36
−
0
View file @
1dc9d3f3
{% extends "shared/includes/base.html" %}
{% load add %}
{% block content %}
{% include "contracts/includes/double_heading.html" with icon="ico--search" heading="Vyhledávání" subheading="dle názvu smlouvy" %}
<div
class=
"flex flex-row justify-center"
>
<form
method=
"post"
>
{% csrf_token %}
<input
class=
"bg-grey-150 w-56 h-10 px-4 text-lg xl:h-14 xl:px-5"
type=
"text"
value=
"{% if query %}{{ query }}{% endif %}"
placeholder=
"Hledaný název"
aria-label=
"Vyhledávací box"
>
<button
type=
"submit"
class=
"btn text-lg"
>
<div
class=
"btn__body"
>
<i
class=
"ico--search"
></i>
</div>
</button>
</form>
</div>
{% if query %}
<h2
class=
"text-lg font-bold mb-10"
>
Výsledky vyhledávání
</h2>
{% if page|length != 0 %}
{% include "contracts/includes/contract_list.html" with page=page paginator=paginator %}
{% else %}
<span
class=
"text-gray-300"
>
Žádné výsledky.
</span>
{% endif %}
{% endif %}
{% endblock %}
This diff is collapsed.
Click to expand it.
contracts/views.py
+
27
−
0
View file @
1dc9d3f3
...
@@ -119,6 +119,33 @@ def view_contract(request, id: int):
...
@@ -119,6 +119,33 @@ def view_contract(request, id: int):
)
)
def
search
(
request
):
query
=
request
.
GET
.
get
(
"
q
"
)
page
=
paginator
=
None
title
=
"
Vyhledávání
"
if
query
is
not
None
:
title
=
f
"
Vyhledávání -
{
query
}
"
# WARNING: PostgreSQL-dependent
page
,
paginator
=
get_paginated_contracts
(
request
,
models
.
Q
(
name__search
=
query
)
)
return
render
(
"
contracts/search.html
"
,
{
**
get_base_context
(
request
),
"
title
"
:
title
,
"
description
"
:
"
Vyhledávání smluv v registru České Pirátské Strany.
"
,
"
page
"
:
page
,
"
paginator
"
:
paginator
,
"
query
"
:
query
,
}
)
# BEGIN Filtered contract + submodel views
# BEGIN Filtered contract + submodel views
...
...
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