Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
bf06fff3
Verified
Commit
bf06fff3
authored
1 year ago
by
Pinguin
Committed by
Jonathan Weth
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add url prefix template filter
parent
5251ec39
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!1237
Release 3.0
,
!1233
Resolve "Links in object column of data check table is broken"
,
!1183
Release 3.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/templates/core/data_check/list.html
+2
-1
2 additions, 1 deletion
aleksis/core/templates/core/data_check/list.html
aleksis/core/templatetags/html_helpers.py
+20
-0
20 additions, 0 deletions
aleksis/core/templatetags/html_helpers.py
with
22 additions
and
1 deletion
aleksis/core/templates/core/data_check/list.html
+
2
−
1
View file @
bf06fff3
...
...
@@ -2,6 +2,7 @@
{% extends "core/base.html" %}
{% load data_helpers %}
{% load html_helpers %}
{% load i18n %}
{% load render_table from django_tables2 %}
...
...
@@ -59,7 +60,7 @@
<td>
{{ result.related_object }}
</td>
<td>
{{ result.related_check.problem_name }}
</td>
<td>
<a
class=
"btn-flat waves-effect waves-light"
href=
"{{ result.related_object.get_absolute_url }}"
target=
"blank"
>
<a
class=
"btn-flat waves-effect waves-light"
href=
"{{ result.related_object.get_absolute_url
|remove_prefix:"
/
django
/"
}}"
target=
"
_
blank"
>
{% trans "Show object" %}
</a>
</td>
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/templatetags/html_helpers.py
+
20
−
0
View file @
bf06fff3
import
random
import
string
from
urllib.parse
import
urlparse
from
django
import
template
from
django.shortcuts
import
reverse
...
...
@@ -28,6 +30,24 @@ def add_class_to_el(value: str, arg: str) -> str:
return
str
(
soup
)
@register.filter
def
remove_prefix
(
value
:
str
,
prefix
:
str
)
->
str
:
"""
Remove prefix of a url
:Example:
.. code-block::
{{ object.get_absolute_url|remove_prefix:
"
/django/
"
}}
"""
url
=
urlparse
(
value
)
if
url
.
path
.
startswith
(
prefix
):
url
=
url
.
_replace
(
path
=
url
.
path
[
len
(
prefix
):])
return
url
.
geturl
()
@register.simple_tag
def
generate_random_id
(
prefix
:
str
,
length
:
int
=
10
)
->
str
:
"""
Generate a random ID for templates.
...
...
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