Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
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
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
hemp
Maják
Commits
b5c39d4a
Commit
b5c39d4a
authored
4 years ago
by
jarmil
Committed by
jan.bednarik
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Strankovani projektu ve webu dary. Solves
#11
parent
a164985c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
donate/models.py
+16
-3
16 additions, 3 deletions
donate/models.py
donate/templates/donate/donate_project_index_page.html
+22
-11
22 additions, 11 deletions
donate/templates/donate/donate_project_index_page.html
with
38 additions
and
14 deletions
donate/models.py
+
16
−
3
View file @
b5c39d4a
from
django.core.paginator
import
EmptyPage
,
PageNotAnInteger
,
Paginator
from
django.db
import
models
from
django.shortcuts
import
redirect
from
django.utils.translation
import
gettext_lazy
...
...
@@ -61,7 +62,7 @@ class DonateFormMixin(models.Model):
def
get_url
(
page
,
dest_page_type
):
try
:
return
page
.
get_children
().
type
(
dest_page_type
).
live
().
first
().
get_url
()
except
Page
.
DoesNotExist
:
except
(
Page
.
DoesNotExist
,
AttributeError
)
:
return
"
#
"
...
...
@@ -323,9 +324,21 @@ class DonateProjectIndexPage(Page, SubpageMixin, MetadataPageMixin):
def
get_context
(
self
,
request
):
context
=
super
().
get_context
(
request
)
context
[
"
projects
"
]
=
(
self
.
get_children
().
live
().
specific
().
order_by
(
"
-donateprojectpage__date
"
)
paginator
=
Paginator
(
self
.
get_children
().
live
().
specific
().
order_by
(
"
-donateprojectpage__date
"
),
6
,
)
page
=
request
.
GET
.
get
(
"
page
"
)
try
:
projects
=
paginator
.
page
(
page
)
except
PageNotAnInteger
:
projects
=
paginator
.
page
(
1
)
except
EmptyPage
:
projects
=
paginator
.
page
(
paginator
.
num_pages
)
context
[
"
projects
"
]
=
projects
return
context
...
...
This diff is collapsed.
Click to expand it.
donate/templates/donate/donate_project_index_page.html
+
22
−
11
View file @
b5c39d4a
...
...
@@ -18,20 +18,31 @@
</div>
<!-- /row -->
{%
comment %} {# TODO #
}
<nav
aria-label=
"Stránkování
projektů
"
>
{%
if projects.paginator.num_pages > 1 %
}
<nav
aria-label=
"Stránkování
aktualit
"
>
<ul
class=
"pagination justify-content-center"
>
{% if projects.has_previous %}
<li
class=
"page-item"
><a
class=
"page-link"
href=
"?page={{ projects.previous_page_number }}"
>
Předchozí
</a></li>
{% endif %}
{% for page_num in projects.paginator.page_range %}
{% if page_num == projects.number %}
<li
class=
"page-item active"
>
<a
class=
"page-link"
href=
"#"
>
1
<span
class=
"sr-only"
>
(current)
</span></a>
</li>
<li
class=
"page-item"
><a
class=
"page-link"
href=
"#"
>
2
</a></li>
<li
class=
"page-item"
><a
class=
"page-link"
href=
"#"
>
3
</a></li>
<li
class=
"page-item"
>
<a
class=
"page-link"
href=
"#"
>
Další
</a>
<a
class=
"page-link"
href=
"#"
>
{{ page_num }}
<span
class=
"sr-only"
>
(current)
</span></a>
</li>
{% else %}
<li
class=
"page-item"
><a
class=
"page-link"
href=
"?page={{ page_num }}"
>
{{ page_num }}
</a></li>
{% endif %}
{% endfor %}
{% if projects.has_next %}
<li
class=
"page-item"
><a
class=
"page-link"
href=
"?page={{ projects.next_page_number }}"
>
Další
</a></li>
{% endif %}
</ul>
</nav>
{% end
comment
%}
{% end
if
%}
</div>
<!-- /container -->
</section>
...
...
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