mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-08 03:08:29 +02:00
Merge siteroot application
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
# Include files required for build or at runtime
|
# Include files required for build or at runtime
|
||||||
!/bookmarks
|
!/bookmarks
|
||||||
!/siteroot
|
|
||||||
|
|
||||||
!/bootstrap.sh
|
!/bootstrap.sh
|
||||||
!/LICENSE.txt
|
!/LICENSE.txt
|
||||||
@@ -19,4 +18,4 @@
|
|||||||
!/version.txt
|
!/version.txt
|
||||||
|
|
||||||
# Remove dev settings
|
# Remove dev settings
|
||||||
/siteroot/settings/dev.py
|
/bookmarks/settings/dev.py
|
||||||
|
1
Makefile
1
Makefile
@@ -11,6 +11,5 @@ test:
|
|||||||
|
|
||||||
format:
|
format:
|
||||||
black bookmarks
|
black bookmarks
|
||||||
black siteroot
|
|
||||||
npx prettier bookmarks/frontend --write
|
npx prettier bookmarks/frontend --write
|
||||||
npx prettier bookmarks/styles --write
|
npx prettier bookmarks/styles --write
|
||||||
|
@@ -58,7 +58,7 @@ Small improvements, bugfixes and documentation improvements are always welcome.
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
The application is built using the Django web framework. You can get started by checking out the excellent [Django docs](https://docs.djangoproject.com/en/4.1/). The `bookmarks` folder contains the actual bookmark application, `siteroot` is the Django root application. Other than that the code should be self-explanatory / standard Django stuff 🙂.
|
The application is built using the Django web framework. You can get started by checking out the excellent [Django docs](https://docs.djangoproject.com/en/4.1/). The `bookmarks` folder contains the actual bookmark application. Other than that the code should be self-explanatory / standard Django stuff 🙂.
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
- Python 3.12
|
- Python 3.12
|
||||||
|
@@ -74,7 +74,7 @@ class AllBookmarksFeed(BaseBookmarksFeed):
|
|||||||
return queries.query_bookmarks(feed_token.user, feed_token.user.profile, search)
|
return queries.query_bookmarks(feed_token.user, feed_token.user.profile, search)
|
||||||
|
|
||||||
def link(self, context: FeedContext):
|
def link(self, context: FeedContext):
|
||||||
return reverse("bookmarks:feeds.all", args=[context.feed_token.key])
|
return reverse("linkding:feeds.all", args=[context.feed_token.key])
|
||||||
|
|
||||||
|
|
||||||
class UnreadBookmarksFeed(BaseBookmarksFeed):
|
class UnreadBookmarksFeed(BaseBookmarksFeed):
|
||||||
@@ -87,7 +87,7 @@ class UnreadBookmarksFeed(BaseBookmarksFeed):
|
|||||||
).filter(unread=True)
|
).filter(unread=True)
|
||||||
|
|
||||||
def link(self, context: FeedContext):
|
def link(self, context: FeedContext):
|
||||||
return reverse("bookmarks:feeds.unread", args=[context.feed_token.key])
|
return reverse("linkding:feeds.unread", args=[context.feed_token.key])
|
||||||
|
|
||||||
|
|
||||||
class SharedBookmarksFeed(BaseBookmarksFeed):
|
class SharedBookmarksFeed(BaseBookmarksFeed):
|
||||||
@@ -100,7 +100,7 @@ class SharedBookmarksFeed(BaseBookmarksFeed):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def link(self, context: FeedContext):
|
def link(self, context: FeedContext):
|
||||||
return reverse("bookmarks:feeds.shared", args=[context.feed_token.key])
|
return reverse("linkding:feeds.shared", args=[context.feed_token.key])
|
||||||
|
|
||||||
|
|
||||||
class PublicSharedBookmarksFeed(BaseBookmarksFeed):
|
class PublicSharedBookmarksFeed(BaseBookmarksFeed):
|
||||||
@@ -114,4 +114,4 @@ class PublicSharedBookmarksFeed(BaseBookmarksFeed):
|
|||||||
return queries.query_shared_bookmarks(None, UserProfile(), search, True)
|
return queries.query_shared_bookmarks(None, UserProfile(), search, True)
|
||||||
|
|
||||||
def link(self, context: FeedContext):
|
def link(self, context: FeedContext):
|
||||||
return reverse("bookmarks:feeds.public_shared")
|
return reverse("linkding:feeds.public_shared")
|
||||||
|
@@ -35,7 +35,7 @@ def append_bookmark(doc: BookmarkDocument, bookmark: Bookmark):
|
|||||||
desc += f"[linkding-notes]{html.escape(bookmark.notes)}[/linkding-notes]"
|
desc += f"[linkding-notes]{html.escape(bookmark.notes)}[/linkding-notes]"
|
||||||
tag_names = bookmark.tag_names
|
tag_names = bookmark.tag_names
|
||||||
if bookmark.is_archived:
|
if bookmark.is_archived:
|
||||||
tag_names.append("linkding:archived")
|
tag_names.append("linkding:bookmarks.archived")
|
||||||
tags = ",".join(tag_names)
|
tags = ",".join(tag_names)
|
||||||
toread = "1" if bookmark.unread else "0"
|
toread = "1" if bookmark.unread else "0"
|
||||||
private = "0" if bookmark.shared else "1"
|
private = "0" if bookmark.shared else "1"
|
||||||
|
@@ -62,9 +62,9 @@ class BookmarkParser(HTMLParser):
|
|||||||
def handle_start_a(self, attrs: Dict[str, str]):
|
def handle_start_a(self, attrs: Dict[str, str]):
|
||||||
vars(self).update(attrs)
|
vars(self).update(attrs)
|
||||||
tag_names = parse_tag_string(self.tags)
|
tag_names = parse_tag_string(self.tags)
|
||||||
archived = "linkding:archived" in self.tags
|
archived = "linkding:bookmarks.archived" in self.tags
|
||||||
try:
|
try:
|
||||||
tag_names.remove("linkding:archived")
|
tag_names.remove("linkding:bookmarks.archived")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@@ -58,7 +58,7 @@ MIDDLEWARE = [
|
|||||||
"django.middleware.locale.LocaleMiddleware",
|
"django.middleware.locale.LocaleMiddleware",
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = "siteroot.urls"
|
ROOT_URLCONF = "bookmarks.urls"
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
@@ -80,7 +80,7 @@ TEMPLATES = [
|
|||||||
|
|
||||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||||
|
|
||||||
WSGI_APPLICATION = "siteroot.wsgi.application"
|
WSGI_APPLICATION = "bookmarks.wsgi.application"
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
@@ -86,7 +86,7 @@
|
|||||||
{% if bookmark_item.is_editable %}
|
{% if bookmark_item.is_editable %}
|
||||||
{# Bookmark owner actions #}
|
{# Bookmark owner actions #}
|
||||||
{% if bookmark_list.show_edit_action %}
|
{% if bookmark_list.show_edit_action %}
|
||||||
<a href="{% url 'bookmarks:edit' bookmark_item.id %}?return_url={{ bookmark_list.return_url|urlencode }}">Edit</a>
|
<a href="{% url 'linkding:bookmarks.edit' bookmark_item.id %}?return_url={{ bookmark_list.return_url|urlencode }}">Edit</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if bookmark_list.show_archive_action %}
|
{% if bookmark_list.show_archive_action %}
|
||||||
{% if bookmark_item.is_archived %}
|
{% if bookmark_item.is_archived %}
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="asset-actions">
|
<div class="asset-actions">
|
||||||
{% if asset.file %}
|
{% if asset.file %}
|
||||||
<a class="btn btn-link" href="{% url 'bookmarks:assets.view' asset.id %}" target="_blank">View</a>
|
<a class="btn btn-link" href="{% url 'linkding:assets.view' asset.id %}" target="_blank">View</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if details.is_editable %}
|
{% if details.is_editable %}
|
||||||
<button ld-confirm-button type="submit" name="remove_asset" value="{{ asset.id }}" class="btn btn-link">
|
<button ld-confirm-button type="submit" name="remove_asset" value="{{ asset.id }}" class="btn btn-link">
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
<span>{{ details.bookmark.url }}</span>
|
<span>{{ details.bookmark.url }}</span>
|
||||||
</a>
|
</a>
|
||||||
{% if details.latest_snapshot %}
|
{% if details.latest_snapshot %}
|
||||||
<a class="weblink" href="{% url 'bookmarks:assets.read' details.latest_snapshot.id %}"
|
<a class="weblink" href="{% url 'linkding:assets.read' details.latest_snapshot.id %}"
|
||||||
target="{{ details.profile.bookmark_link_target }}">
|
target="{{ details.profile.bookmark_link_target }}">
|
||||||
{% if details.show_link_icons %}
|
{% if details.show_link_icons %}
|
||||||
<svg class="favicon" xmlns="http://www.w3.org/2000/svg">
|
<svg class="favicon" xmlns="http://www.w3.org/2000/svg">
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
<h3 id="details-modal-tags-title">Tags</h3>
|
<h3 id="details-modal-tags-title">Tags</h3>
|
||||||
<div>
|
<div>
|
||||||
{% for tag_name in details.bookmark.tag_names %}
|
{% for tag_name in details.bookmark.tag_names %}
|
||||||
<a href="{% url 'bookmarks:index' %}?{% add_tag_to_query tag_name %}">{{ tag_name|hash_tag }}</a>
|
<a href="{% url 'linkding:bookmarks.index' %}?{% add_tag_to_query tag_name %}">{{ tag_name|hash_tag }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
<div class="actions">
|
<div class="actions">
|
||||||
<div class="left-actions">
|
<div class="left-actions">
|
||||||
<a class="btn btn-wide"
|
<a class="btn btn-wide"
|
||||||
href="{% url 'bookmarks:edit' details.bookmark.id %}?return_url={{ details.edit_return_url|urlencode }}">Edit</a>
|
href="{% url 'linkding:bookmarks.edit' details.bookmark.id %}?return_url={{ details.edit_return_url|urlencode }}">Edit</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="right-actions">
|
<div class="right-actions">
|
||||||
<form action="{{ details.delete_url }}" method="post" data-turbo-action="replace">
|
<form action="{{ details.delete_url }}" method="post" data-turbo-action="replace">
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<div class="content-area-header">
|
<div class="content-area-header">
|
||||||
<h2>Edit bookmark</h2>
|
<h2>Edit bookmark</h2>
|
||||||
</div>
|
</div>
|
||||||
<form action="{% url 'bookmarks:edit' bookmark_id %}?return_url={{ return_url|urlencode }}" method="post"
|
<form action="{% url 'linkding:bookmarks.edit' bookmark_id %}?return_url={{ return_url|urlencode }}" method="post"
|
||||||
novalidate>
|
novalidate>
|
||||||
{% bookmark_form form return_url bookmark_id %}
|
{% bookmark_form form return_url bookmark_id %}
|
||||||
</form>
|
</form>
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
<div class="empty">
|
<div class="empty">
|
||||||
<p class="empty-title h5">You have no bookmarks yet</p>
|
<p class="empty-title h5">You have no bookmarks yet</p>
|
||||||
<p class="empty-subtitle">
|
<p class="empty-subtitle">
|
||||||
You can get started by <a href="{% url 'bookmarks:new' %}">adding</a> bookmarks,
|
You can get started by <a href="{% url 'linkding:bookmarks.new' %}">adding</a> bookmarks,
|
||||||
<a href="{% url 'bookmarks:settings.general' %}">importing</a> your existing bookmarks or configuring the
|
<a href="{% url 'linkding:settings.general' %}">importing</a> your existing bookmarks or configuring the
|
||||||
<a href="{% url 'bookmarks:settings.integrations' %}">browser extension</a> or the <a
|
<a href="{% url 'linkding:settings.integrations' %}">browser extension</a> or the <a
|
||||||
href="{% url 'bookmarks:settings.integrations' %}">bookmarklet</a>.
|
href="{% url 'linkding:settings.integrations' %}">bookmarklet</a>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -144,7 +144,7 @@
|
|||||||
toggleLoadingIcon(urlInput, true);
|
toggleLoadingIcon(urlInput, true);
|
||||||
|
|
||||||
const websiteUrl = encodeURIComponent(urlInput.value);
|
const websiteUrl = encodeURIComponent(urlInput.value);
|
||||||
const requestUrl = `{% url 'bookmarks:api-root' %}bookmarks/check?url=${websiteUrl}`;
|
const requestUrl = `{% url 'linkding:api-root' %}bookmarks/check?url=${websiteUrl}`;
|
||||||
fetch(requestUrl)
|
fetch(requestUrl)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
<link rel="icon" href="{% static 'favicon.svg' %}" sizes="any" type="image/svg+xml">
|
<link rel="icon" href="{% static 'favicon.svg' %}" sizes="any" type="image/svg+xml">
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'apple-touch-icon.png' %}">
|
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'apple-touch-icon.png' %}">
|
||||||
<link rel="mask-icon" href="{% static 'safari-pinned-tab.svg' %}" color="#5856e0">
|
<link rel="mask-icon" href="{% static 'safari-pinned-tab.svg' %}" color="#5856e0">
|
||||||
<link rel="manifest" href="{% url 'bookmarks:manifest' %}">
|
<link rel="manifest" href="{% url 'linkding:manifest' %}">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">
|
||||||
<meta name="description" content="Self-hosted bookmark service">
|
<meta name="description" content="Self-hosted bookmark service">
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#5856e0">
|
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#5856e0">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if request.user_profile.custom_css %}
|
{% if request.user_profile.custom_css %}
|
||||||
<link href="{% url 'bookmarks:custom_css' %}?hash={{ request.user_profile.custom_css_hash }}" rel="stylesheet" type="text/css"/>
|
<link href="{% url 'linkding:custom_css' %}?hash={{ request.user_profile.custom_css_hash }}" rel="stylesheet" type="text/css"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<meta name="turbo-cache-control" content="no-preview">
|
<meta name="turbo-cache-control" content="no-preview">
|
||||||
{% if not request.global_settings.enable_link_prefetch %}
|
{% if not request.global_settings.enable_link_prefetch %}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
{# Use data attributes as storage for access in static scripts #}
|
{# Use data attributes as storage for access in static scripts #}
|
||||||
<html lang="en" data-api-base-url="{% url 'bookmarks:api-root' %}">
|
<html lang="en" data-api-base-url="{% url 'linkding:api-root' %}">
|
||||||
{% include 'bookmarks/head.html' %}
|
{% include 'bookmarks/head.html' %}
|
||||||
<body ld-global-shortcuts>
|
<body ld-global-shortcuts>
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
<header class="container">
|
<header class="container">
|
||||||
{% if has_toasts %}
|
{% if has_toasts %}
|
||||||
<div class="toasts">
|
<div class="toasts">
|
||||||
<form action="{% url 'bookmarks:toasts.acknowledge' %}?return_url={{ request.path | urlencode }}" method="post">
|
<form action="{% url 'linkding:toasts.acknowledge' %}?return_url={{ request.path | urlencode }}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% for toast in toast_messages %}
|
{% for toast in toast_messages %}
|
||||||
<div class="toast d-flex">
|
<div class="toast d-flex">
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="d-flex justify-between">
|
<div class="d-flex justify-between">
|
||||||
<a href="{% url 'bookmarks:root' %}" class="d-flex align-center">
|
<a href="{% url 'linkding:root' %}" class="d-flex align-center">
|
||||||
<img class="logo" src="{% static 'logo.png' %}" alt="Application logo">
|
<img class="logo" src="{% static 'logo.png' %}" alt="Application logo">
|
||||||
<h1>LINKDING</h1>
|
<h1>LINKDING</h1>
|
||||||
</a>
|
</a>
|
||||||
|
@@ -2,32 +2,32 @@
|
|||||||
{% htmlmin %}
|
{% htmlmin %}
|
||||||
{# Basic menu list #}
|
{# Basic menu list #}
|
||||||
<div class="hide-md">
|
<div class="hide-md">
|
||||||
<a href="{% url 'bookmarks:new' %}" class="btn btn-primary mr-2">Add bookmark</a>
|
<a href="{% url 'linkding:bookmarks.new' %}" class="btn btn-primary mr-2">Add bookmark</a>
|
||||||
<div ld-dropdown class="dropdown">
|
<div ld-dropdown class="dropdown">
|
||||||
<button class="btn btn-link dropdown-toggle" tabindex="0">
|
<button class="btn btn-link dropdown-toggle" tabindex="0">
|
||||||
Bookmarks
|
Bookmarks
|
||||||
</button>
|
</button>
|
||||||
<ul class="menu" role="list" tabindex="-1">
|
<ul class="menu" role="list" tabindex="-1">
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:index' %}" class="menu-link">Active</a>
|
<a href="{% url 'linkding:bookmarks.index' %}" class="menu-link">Active</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:archived' %}" class="menu-link">Archived</a>
|
<a href="{% url 'linkding:bookmarks.archived' %}" class="menu-link">Archived</a>
|
||||||
</li>
|
</li>
|
||||||
{% if request.user_profile.enable_sharing %}
|
{% if request.user_profile.enable_sharing %}
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:shared' %}" class="menu-link">Shared</a>
|
<a href="{% url 'linkding:bookmarks.shared' %}" class="menu-link">Shared</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:index' %}?unread=yes" class="menu-link">Unread</a>
|
<a href="{% url 'linkding:bookmarks.index' %}?unread=yes" class="menu-link">Unread</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:index' %}?q=!untagged" class="menu-link">Untagged</a>
|
<a href="{% url 'linkding:bookmarks.index' %}?q=!untagged" class="menu-link">Untagged</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<a href="{% url 'bookmarks:settings.index' %}" class="btn btn-link">Settings</a>
|
<a href="{% url 'linkding:settings.index' %}" class="btn btn-link">Settings</a>
|
||||||
<form class="d-inline" action="{% url 'logout' %}" method="post" data-turbo="false">
|
<form class="d-inline" action="{% url 'logout' %}" method="post" data-turbo="false">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button type="submit" class="btn btn-link">Logout</button>
|
<button type="submit" class="btn btn-link">Logout</button>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{# Menu drop-down for smaller devices #}
|
{# Menu drop-down for smaller devices #}
|
||||||
<div class="show-md">
|
<div class="show-md">
|
||||||
<a href="{% url 'bookmarks:new' %}" aria-label="Add bookmark" class="btn btn-primary">
|
<a href="{% url 'linkding:bookmarks.new' %}" aria-label="Add bookmark" class="btn btn-primary">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"
|
||||||
style="width: 24px; height: 24px">
|
style="width: 24px; height: 24px">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
|
||||||
@@ -51,25 +51,25 @@
|
|||||||
<!-- menu component -->
|
<!-- menu component -->
|
||||||
<ul class="menu" role="list" tabindex="-1">
|
<ul class="menu" role="list" tabindex="-1">
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:index' %}" class="menu-link">Bookmarks</a>
|
<a href="{% url 'linkding:bookmarks.index' %}" class="menu-link">Bookmarks</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:archived' %}" class="menu-link">Archived</a>
|
<a href="{% url 'linkding:bookmarks.archived' %}" class="menu-link">Archived</a>
|
||||||
</li>
|
</li>
|
||||||
{% if request.user_profile.enable_sharing %}
|
{% if request.user_profile.enable_sharing %}
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:shared' %}" class="menu-link">Shared</a>
|
<a href="{% url 'linkding:bookmarks.shared' %}" class="menu-link">Shared</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:index' %}?unread=yes" class="menu-link">Unread</a>
|
<a href="{% url 'linkding:bookmarks.index' %}?unread=yes" class="menu-link">Unread</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:index' %}?q=!untagged" class="menu-link">Untagged</a>
|
<a href="{% url 'linkding:bookmarks.index' %}?q=!untagged" class="menu-link">Untagged</a>
|
||||||
</li>
|
</li>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="{% url 'bookmarks:settings.index' %}" class="menu-link">Settings</a>
|
<a href="{% url 'linkding:settings.index' %}" class="menu-link">Settings</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<form class="d-inline" action="{% url 'logout' %}" method="post" data-turbo="false">
|
<form class="d-inline" action="{% url 'logout' %}" method="post" data-turbo="false">
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<div class="content-area-header">
|
<div class="content-area-header">
|
||||||
<h2>New bookmark</h2>
|
<h2>New bookmark</h2>
|
||||||
</div>
|
</div>
|
||||||
<form action="{% url 'bookmarks:new' %}" method="post" novalidate>
|
<form action="{% url 'linkding:bookmarks.new' %}" method="post" novalidate>
|
||||||
{% bookmark_form form return_url auto_close=auto_close %}
|
{% bookmark_form form return_url auto_close=auto_close %}
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<a href="{% url 'change_password' %}">Change password</a>
|
<a href="{% url 'change_password' %}">Change password</a>
|
||||||
</p>
|
</p>
|
||||||
<form action="{% url 'bookmarks:settings.update' %}" method="post" novalidate data-turbo="false">
|
<form action="{% url 'linkding:settings.update' %}" method="post" novalidate data-turbo="false">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="{{ form.theme.id_for_label }}" class="form-label">Theme</label>
|
<label for="{{ form.theme.id_for_label }}" class="form-label">Theme</label>
|
||||||
@@ -229,7 +229,7 @@ reddit.com/r/Music music reddit</pre>
|
|||||||
<div class="form-input-hint">
|
<div class="form-input-hint">
|
||||||
Makes shared bookmarks publicly accessible, without requiring a login.
|
Makes shared bookmarks publicly accessible, without requiring a login.
|
||||||
That means that anyone with a link to this instance can view shared bookmarks via the <a
|
That means that anyone with a link to this instance can view shared bookmarks via the <a
|
||||||
href="{% url 'bookmarks:shared' %}">shared bookmarks page</a>.
|
href="{% url 'linkding:bookmarks.shared' %}">shared bookmarks page</a>.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if has_snapshot_support %}
|
{% if has_snapshot_support %}
|
||||||
@@ -280,7 +280,7 @@ reddit.com/r/Music music reddit</pre>
|
|||||||
{% if global_settings_form %}
|
{% if global_settings_form %}
|
||||||
<section class="content-area">
|
<section class="content-area">
|
||||||
<h2>Global settings</h2>
|
<h2>Global settings</h2>
|
||||||
<form action="{% url 'bookmarks:settings.update' %}" method="post" novalidate data-turbo="false">
|
<form action="{% url 'linkding:settings.update' %}" method="post" novalidate data-turbo="false">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="{{ global_settings_form.landing_page.id_for_label }}" class="form-label">Landing page</label>
|
<label for="{{ global_settings_form.landing_page.id_for_label }}" class="form-label">Landing page</label>
|
||||||
@@ -322,7 +322,7 @@ reddit.com/r/Music music reddit</pre>
|
|||||||
<h2>Import</h2>
|
<h2>Import</h2>
|
||||||
<p>Import bookmarks and tags in the Netscape HTML format. This will execute a sync where new bookmarks are
|
<p>Import bookmarks and tags in the Netscape HTML format. This will execute a sync where new bookmarks are
|
||||||
added and existing ones are updated.</p>
|
added and existing ones are updated.</p>
|
||||||
<form method="post" enctype="multipart/form-data" action="{% url 'bookmarks:settings.import' %}">
|
<form method="post" enctype="multipart/form-data" action="{% url 'linkding:settings.import' %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="import_map_private_flag" class="form-checkbox">
|
<label for="import_map_private_flag" class="form-checkbox">
|
||||||
@@ -349,7 +349,7 @@ reddit.com/r/Music music reddit</pre>
|
|||||||
<section class="content-area">
|
<section class="content-area">
|
||||||
<h2>Export</h2>
|
<h2>Export</h2>
|
||||||
<p>Export all bookmarks in Netscape HTML format.</p>
|
<p>Export all bookmarks in Netscape HTML format.</p>
|
||||||
<a class="btn btn-primary" target="_blank" href="{% url 'bookmarks:settings.export' %}">Download (.html)</a>
|
<a class="btn btn-primary" target="_blank" href="{% url 'linkding:settings.export' %}">Download (.html)</a>
|
||||||
{% if export_error %}
|
{% if export_error %}
|
||||||
<div class="has-error">
|
<div class="has-error">
|
||||||
<p class="form-input-hint">
|
<p class="form-input-hint">
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
{% url 'bookmarks:settings.index' as index_url %}
|
{% url 'linkding:settings.index' as index_url %}
|
||||||
{% url 'bookmarks:settings.general' as general_url %}
|
{% url 'linkding:settings.general' as general_url %}
|
||||||
{% url 'bookmarks:settings.integrations' as integrations_url %}
|
{% url 'linkding:settings.integrations' as integrations_url %}
|
||||||
|
|
||||||
<ul class="tab tab-block">
|
<ul class="tab tab-block">
|
||||||
<li class="tab-item {% if request.get_full_path == index_url or request.get_full_path == general_url%}active{% endif %}">
|
<li class="tab-item {% if request.get_full_path == index_url or request.get_full_path == general_url%}active{% endif %}">
|
||||||
<a href="{% url 'bookmarks:settings.general' %}">General</a>
|
<a href="{% url 'linkding:settings.general' %}">General</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="tab-item {% if request.get_full_path == integrations_url %}active{% endif %}">
|
<li class="tab-item {% if request.get_full_path == integrations_url %}active{% endif %}">
|
||||||
<a href="{% url 'bookmarks:settings.integrations' %}">Integrations</a>
|
<a href="{% url 'linkding:settings.integrations' %}">Integrations</a>
|
||||||
</li>
|
</li>
|
||||||
{% if request.user.is_superuser %}
|
{% if request.user.is_superuser %}
|
||||||
<li class="tab-item">
|
<li class="tab-item">
|
||||||
|
@@ -7,7 +7,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
class AppOptionsTestCase(TestCase):
|
class AppOptionsTestCase(TestCase):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
self.settings_module = importlib.import_module("siteroot.settings.base")
|
self.settings_module = importlib.import_module("bookmarks.settings.base")
|
||||||
|
|
||||||
def test_empty_csrf_trusted_origins(self):
|
def test_empty_csrf_trusted_origins(self):
|
||||||
module = importlib.reload(self.settings_module)
|
module = importlib.reload(self.settings_module)
|
||||||
|
@@ -16,17 +16,17 @@ class AuthApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
def test_auth_with_token_keyword(self):
|
def test_auth_with_token_keyword(self):
|
||||||
self.authenticate("Token")
|
self.authenticate("Token")
|
||||||
|
|
||||||
url = reverse("bookmarks:user-profile")
|
url = reverse("linkding:user-profile")
|
||||||
self.get(url, expected_status_code=status.HTTP_200_OK)
|
self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
|
|
||||||
def test_auth_with_bearer_keyword(self):
|
def test_auth_with_bearer_keyword(self):
|
||||||
self.authenticate("Bearer")
|
self.authenticate("Bearer")
|
||||||
|
|
||||||
url = reverse("bookmarks:user-profile")
|
url = reverse("linkding:user-profile")
|
||||||
self.get(url, expected_status_code=status.HTTP_200_OK)
|
self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
|
|
||||||
def test_auth_with_unknown_keyword(self):
|
def test_auth_with_unknown_keyword(self):
|
||||||
self.authenticate("Key")
|
self.authenticate("Key")
|
||||||
|
|
||||||
url = reverse("bookmarks:user-profile")
|
url = reverse("linkding:user-profile")
|
||||||
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
@@ -21,7 +21,7 @@ class AuthProxySupportTest(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
headers = {"REMOTE_USER": user.username}
|
headers = {"REMOTE_USER": user.username}
|
||||||
response = self.client.get(reverse("bookmarks:index"), **headers)
|
response = self.client.get(reverse("linkding:bookmarks.index"), **headers)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ class AuthProxySupportTest(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
headers = {"Custom-User": user.username}
|
headers = {"Custom-User": user.username}
|
||||||
response = self.client.get(reverse("bookmarks:index"), **headers)
|
response = self.client.get(reverse("linkding:bookmarks.index"), **headers)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -53,6 +53,8 @@ class AuthProxySupportTest(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
headers = {"REMOTE_USER": user.username}
|
headers = {"REMOTE_USER": user.username}
|
||||||
response = self.client.get(reverse("bookmarks:index"), **headers, follow=True)
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.index"), **headers, follow=True
|
||||||
|
)
|
||||||
|
|
||||||
self.assertRedirects(response, "/login/?next=%2Fbookmarks")
|
self.assertRedirects(response, "/login/?next=%2Fbookmarks")
|
||||||
|
@@ -37,7 +37,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"archive": [bookmark.id],
|
"archive": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -54,7 +54,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"archive": [bookmark.id],
|
"archive": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -69,7 +69,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(is_archived=True)
|
bookmark = self.setup_bookmark(is_archived=True)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"unarchive": [bookmark.id],
|
"unarchive": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -85,7 +85,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(is_archived=True, user=other_user)
|
bookmark = self.setup_bookmark(is_archived=True, user=other_user)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"unarchive": [bookmark.id],
|
"unarchive": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -99,7 +99,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"remove": [bookmark.id],
|
"remove": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -114,7 +114,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"remove": [bookmark.id],
|
"remove": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -126,7 +126,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(unread=True)
|
bookmark = self.setup_bookmark(unread=True)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"mark_as_read": [bookmark.id],
|
"mark_as_read": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -139,7 +139,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(shared=True)
|
bookmark = self.setup_bookmark(shared=True)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"unshare": [bookmark.id],
|
"unshare": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -156,7 +156,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(user=other_user, shared=True)
|
bookmark = self.setup_bookmark(user=other_user, shared=True)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"unshare": [bookmark.id],
|
"unshare": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -172,7 +172,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
with patch.object(tasks, "_create_html_snapshot_task"):
|
with patch.object(tasks, "_create_html_snapshot_task"):
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"create_html_snapshot": [bookmark.id],
|
"create_html_snapshot": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -187,7 +187,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
with patch.object(tasks, "_create_html_snapshot_task"):
|
with patch.object(tasks, "_create_html_snapshot_task"):
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"create_html_snapshot": [bookmark.id],
|
"create_html_snapshot": [bookmark.id],
|
||||||
},
|
},
|
||||||
@@ -202,7 +202,7 @@ class BookmarkActionViewTestCase(
|
|||||||
|
|
||||||
with patch.object(assets, "upload_asset") as mock_upload_asset:
|
with patch.object(assets, "upload_asset") as mock_upload_asset:
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{"upload_asset": bookmark.id, "upload_asset_file": upload_file},
|
{"upload_asset": bookmark.id, "upload_asset_file": upload_file},
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
@@ -223,7 +223,7 @@ class BookmarkActionViewTestCase(
|
|||||||
|
|
||||||
with patch.object(assets, "upload_asset") as mock_upload_asset:
|
with patch.object(assets, "upload_asset") as mock_upload_asset:
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{"upload_asset": bookmark.id, "upload_asset_file": upload_file},
|
{"upload_asset": bookmark.id, "upload_asset_file": upload_file},
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
@@ -237,7 +237,7 @@ class BookmarkActionViewTestCase(
|
|||||||
upload_file = SimpleUploadedFile("test.txt", file_content)
|
upload_file = SimpleUploadedFile("test.txt", file_content)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{"upload_asset": bookmark.id, "upload_asset_file": upload_file},
|
{"upload_asset": bookmark.id, "upload_asset_file": upload_file},
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 403)
|
self.assertEqual(response.status_code, 403)
|
||||||
@@ -246,7 +246,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{"upload_asset": bookmark.id},
|
{"upload_asset": bookmark.id},
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 400)
|
self.assertEqual(response.status_code, 400)
|
||||||
@@ -256,7 +256,7 @@ class BookmarkActionViewTestCase(
|
|||||||
asset = self.setup_asset(bookmark)
|
asset = self.setup_asset(bookmark)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"), {"remove_asset": asset.id}
|
reverse("linkding:bookmarks.index.action"), {"remove_asset": asset.id}
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertFalse(BookmarkAsset.objects.filter(id=asset.id).exists())
|
self.assertFalse(BookmarkAsset.objects.filter(id=asset.id).exists())
|
||||||
@@ -267,7 +267,7 @@ class BookmarkActionViewTestCase(
|
|||||||
asset = self.setup_asset(bookmark)
|
asset = self.setup_asset(bookmark)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"), {"remove_asset": asset.id}
|
reverse("linkding:bookmarks.index.action"), {"remove_asset": asset.id}
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
self.assertTrue(BookmarkAsset.objects.filter(id=asset.id).exists())
|
self.assertTrue(BookmarkAsset.objects.filter(id=asset.id).exists())
|
||||||
@@ -276,7 +276,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"update_state": bookmark.id,
|
"update_state": bookmark.id,
|
||||||
"is_archived": "on",
|
"is_archived": "on",
|
||||||
@@ -296,7 +296,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"update_state": bookmark.id,
|
"update_state": bookmark.id,
|
||||||
"is_archived": "on",
|
"is_archived": "on",
|
||||||
@@ -317,7 +317,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark()
|
bookmark3 = self.setup_bookmark()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_archive"],
|
"bulk_action": ["bulk_archive"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -342,7 +342,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(user=other_user)
|
bookmark3 = self.setup_bookmark(user=other_user)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_archive"],
|
"bulk_action": ["bulk_archive"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -364,7 +364,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(is_archived=True)
|
bookmark3 = self.setup_bookmark(is_archived=True)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived.action"),
|
reverse("linkding:bookmarks.archived.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_unarchive"],
|
"bulk_action": ["bulk_unarchive"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -389,7 +389,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(is_archived=True, user=other_user)
|
bookmark3 = self.setup_bookmark(is_archived=True, user=other_user)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived.action"),
|
reverse("linkding:bookmarks.archived.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_unarchive"],
|
"bulk_action": ["bulk_unarchive"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -411,7 +411,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark()
|
bookmark3 = self.setup_bookmark()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_delete"],
|
"bulk_action": ["bulk_delete"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -436,7 +436,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(user=other_user)
|
bookmark3 = self.setup_bookmark(user=other_user)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_delete"],
|
"bulk_action": ["bulk_delete"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -460,7 +460,7 @@ class BookmarkActionViewTestCase(
|
|||||||
tag2 = self.setup_tag()
|
tag2 = self.setup_tag()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_tag"],
|
"bulk_action": ["bulk_tag"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -492,7 +492,7 @@ class BookmarkActionViewTestCase(
|
|||||||
tag2 = self.setup_tag()
|
tag2 = self.setup_tag()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_tag"],
|
"bulk_action": ["bulk_tag"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -521,7 +521,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(tags=[tag1, tag2])
|
bookmark3 = self.setup_bookmark(tags=[tag1, tag2])
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_untag"],
|
"bulk_action": ["bulk_untag"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -553,7 +553,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(tags=[tag1, tag2], user=other_user)
|
bookmark3 = self.setup_bookmark(tags=[tag1, tag2], user=other_user)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_untag"],
|
"bulk_action": ["bulk_untag"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -580,7 +580,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(unread=True)
|
bookmark3 = self.setup_bookmark(unread=True)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_read"],
|
"bulk_action": ["bulk_read"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -605,7 +605,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(unread=True, user=other_user)
|
bookmark3 = self.setup_bookmark(unread=True, user=other_user)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_read"],
|
"bulk_action": ["bulk_read"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -627,7 +627,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(unread=False)
|
bookmark3 = self.setup_bookmark(unread=False)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_unread"],
|
"bulk_action": ["bulk_unread"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -652,7 +652,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(unread=False, user=other_user)
|
bookmark3 = self.setup_bookmark(unread=False, user=other_user)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_unread"],
|
"bulk_action": ["bulk_unread"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -674,7 +674,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(shared=False)
|
bookmark3 = self.setup_bookmark(shared=False)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_share"],
|
"bulk_action": ["bulk_share"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -699,7 +699,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(shared=False, user=other_user)
|
bookmark3 = self.setup_bookmark(shared=False, user=other_user)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_share"],
|
"bulk_action": ["bulk_share"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -721,7 +721,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(shared=True)
|
bookmark3 = self.setup_bookmark(shared=True)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_unshare"],
|
"bulk_action": ["bulk_unshare"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -746,7 +746,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark(shared=True, user=other_user)
|
bookmark3 = self.setup_bookmark(shared=True, user=other_user)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_unshare"],
|
"bulk_action": ["bulk_unshare"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -768,7 +768,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark()
|
bookmark3 = self.setup_bookmark()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_archive"],
|
"bulk_action": ["bulk_archive"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -784,7 +784,7 @@ class BookmarkActionViewTestCase(
|
|||||||
self.setup_numbered_bookmarks(100)
|
self.setup_numbered_bookmarks(100)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action") + "?page=2",
|
reverse("linkding:bookmarks.index.action") + "?page=2",
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_delete"],
|
"bulk_action": ["bulk_delete"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -813,7 +813,7 @@ class BookmarkActionViewTestCase(
|
|||||||
self.assertIsNotNone(Bookmark.objects.filter(title="Bookmark 3").first())
|
self.assertIsNotNone(Bookmark.objects.filter(title="Bookmark 3").first())
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_delete"],
|
"bulk_action": ["bulk_delete"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -833,7 +833,7 @@ class BookmarkActionViewTestCase(
|
|||||||
self.assertEqual(3, Bookmark.objects.filter(title__startswith="foo").count())
|
self.assertEqual(3, Bookmark.objects.filter(title__startswith="foo").count())
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action") + "?q=foo",
|
reverse("linkding:bookmarks.index.action") + "?q=foo",
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_delete"],
|
"bulk_action": ["bulk_delete"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -858,7 +858,7 @@ class BookmarkActionViewTestCase(
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived.action"),
|
reverse("linkding:bookmarks.archived.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_delete"],
|
"bulk_action": ["bulk_delete"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -878,7 +878,7 @@ class BookmarkActionViewTestCase(
|
|||||||
self.assertEqual(3, Bookmark.objects.filter(title__startswith="foo").count())
|
self.assertEqual(3, Bookmark.objects.filter(title__startswith="foo").count())
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived.action") + "?q=foo",
|
reverse("linkding:bookmarks.archived.action") + "?q=foo",
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_delete"],
|
"bulk_action": ["bulk_delete"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -893,7 +893,7 @@ class BookmarkActionViewTestCase(
|
|||||||
self.setup_bulk_edit_scope_test_data()
|
self.setup_bulk_edit_scope_test_data()
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:shared.action"),
|
reverse("linkding:bookmarks.shared.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_delete"],
|
"bulk_action": ["bulk_delete"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -908,7 +908,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark()
|
bookmark3 = self.setup_bookmark()
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_archive"],
|
"bulk_action": ["bulk_archive"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -917,7 +917,7 @@ class BookmarkActionViewTestCase(
|
|||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bulk_action": ["bulk_archive"],
|
"bulk_action": ["bulk_archive"],
|
||||||
"bulk_execute": [""],
|
"bulk_execute": [""],
|
||||||
@@ -934,7 +934,7 @@ class BookmarkActionViewTestCase(
|
|||||||
bookmark3 = self.setup_bookmark()
|
bookmark3 = self.setup_bookmark()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
{
|
{
|
||||||
"bookmark_id": [
|
"bookmark_id": [
|
||||||
str(bookmark1.id),
|
str(bookmark1.id),
|
||||||
@@ -947,22 +947,22 @@ class BookmarkActionViewTestCase(
|
|||||||
self.assertBookmarksAreUnmodified([bookmark1, bookmark2, bookmark3])
|
self.assertBookmarksAreUnmodified([bookmark1, bookmark2, bookmark3])
|
||||||
|
|
||||||
def test_index_action_redirects_to_index_with_query_params(self):
|
def test_index_action_redirects_to_index_with_query_params(self):
|
||||||
url = reverse("bookmarks:index.action") + "?q=foo&page=2"
|
url = reverse("linkding:bookmarks.index.action") + "?q=foo&page=2"
|
||||||
redirect_url = reverse("bookmarks:index") + "?q=foo&page=2"
|
redirect_url = reverse("linkding:bookmarks.index") + "?q=foo&page=2"
|
||||||
response = self.client.post(url)
|
response = self.client.post(url)
|
||||||
|
|
||||||
self.assertRedirects(response, redirect_url)
|
self.assertRedirects(response, redirect_url)
|
||||||
|
|
||||||
def test_archived_action_redirects_to_archived_with_query_params(self):
|
def test_archived_action_redirects_to_archived_with_query_params(self):
|
||||||
url = reverse("bookmarks:archived.action") + "?q=foo&page=2"
|
url = reverse("linkding:bookmarks.archived.action") + "?q=foo&page=2"
|
||||||
redirect_url = reverse("bookmarks:archived") + "?q=foo&page=2"
|
redirect_url = reverse("linkding:bookmarks.archived") + "?q=foo&page=2"
|
||||||
response = self.client.post(url)
|
response = self.client.post(url)
|
||||||
|
|
||||||
self.assertRedirects(response, redirect_url)
|
self.assertRedirects(response, redirect_url)
|
||||||
|
|
||||||
def test_shared_action_redirects_to_shared_with_query_params(self):
|
def test_shared_action_redirects_to_shared_with_query_params(self):
|
||||||
url = reverse("bookmarks:shared.action") + "?q=foo&page=2"
|
url = reverse("linkding:bookmarks.shared.action") + "?q=foo&page=2"
|
||||||
redirect_url = reverse("bookmarks:shared") + "?q=foo&page=2"
|
redirect_url = reverse("linkding:bookmarks.shared") + "?q=foo&page=2"
|
||||||
response = self.client.post(url)
|
response = self.client.post(url)
|
||||||
|
|
||||||
self.assertRedirects(response, redirect_url)
|
self.assertRedirects(response, redirect_url)
|
||||||
@@ -1012,7 +1012,7 @@ class BookmarkActionViewTestCase(
|
|||||||
def test_index_action_with_turbo_returns_bookmark_update(self):
|
def test_index_action_with_turbo_returns_bookmark_update(self):
|
||||||
fixture = self.bookmark_update_fixture()
|
fixture = self.bookmark_update_fixture()
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index.action"),
|
reverse("linkding:bookmarks.index.action"),
|
||||||
HTTP_ACCEPT="text/vnd.turbo-stream.html",
|
HTTP_ACCEPT="text/vnd.turbo-stream.html",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1030,7 +1030,7 @@ class BookmarkActionViewTestCase(
|
|||||||
def test_archived_action_with_turbo_returns_bookmark_update(self):
|
def test_archived_action_with_turbo_returns_bookmark_update(self):
|
||||||
fixture = self.bookmark_update_fixture()
|
fixture = self.bookmark_update_fixture()
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:archived.action"),
|
reverse("linkding:bookmarks.archived.action"),
|
||||||
HTTP_ACCEPT="text/vnd.turbo-stream.html",
|
HTTP_ACCEPT="text/vnd.turbo-stream.html",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1048,7 +1048,7 @@ class BookmarkActionViewTestCase(
|
|||||||
def test_shared_action_with_turbo_returns_bookmark_update(self):
|
def test_shared_action_with_turbo_returns_bookmark_update(self):
|
||||||
fixture = self.bookmark_update_fixture()
|
fixture = self.bookmark_update_fixture()
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:shared.action"),
|
reverse("linkding:bookmarks.shared.action"),
|
||||||
HTTP_ACCEPT="text/vnd.turbo-stream.html",
|
HTTP_ACCEPT="text/vnd.turbo-stream.html",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
self.setup_bookmark(is_archived=True, user=other_user),
|
self.setup_bookmark(is_archived=True, user=other_user),
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:archived"))
|
response = self.client.get(reverse("linkding:bookmarks.archived"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks)
|
self.assertVisibleBookmarks(response, visible_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
||||||
@@ -59,7 +59,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
3, prefix="bar", archived=True
|
3, prefix="bar", archived=True
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:archived") + "?q=foo")
|
response = self.client.get(reverse("linkding:bookmarks.archived") + "?q=foo")
|
||||||
html = collapse_whitespace(response.content.decode())
|
html = collapse_whitespace(response.content.decode())
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks)
|
self.assertVisibleBookmarks(response, visible_bookmarks)
|
||||||
@@ -84,7 +84,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
unarchived_bookmarks + other_user_bookmarks
|
unarchived_bookmarks + other_user_bookmarks
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:archived"))
|
response = self.client.get(reverse("linkding:bookmarks.archived"))
|
||||||
|
|
||||||
self.assertVisibleTags(response, visible_tags)
|
self.assertVisibleTags(response, visible_tags)
|
||||||
self.assertInvisibleTags(response, invisible_tags)
|
self.assertInvisibleTags(response, invisible_tags)
|
||||||
@@ -100,7 +100,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
visible_tags = self.get_tags_from_bookmarks(visible_bookmarks)
|
visible_tags = self.get_tags_from_bookmarks(visible_bookmarks)
|
||||||
invisible_tags = self.get_tags_from_bookmarks(invisible_bookmarks)
|
invisible_tags = self.get_tags_from_bookmarks(invisible_bookmarks)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:archived") + "?q=foo")
|
response = self.client.get(reverse("linkding:bookmarks.archived") + "?q=foo")
|
||||||
|
|
||||||
self.assertVisibleTags(response, visible_tags)
|
self.assertVisibleTags(response, visible_tags)
|
||||||
self.assertInvisibleTags(response, invisible_tags)
|
self.assertInvisibleTags(response, invisible_tags)
|
||||||
@@ -132,7 +132,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
unread_tags = self.get_tags_from_bookmarks(unread_bookmarks)
|
unread_tags = self.get_tags_from_bookmarks(unread_bookmarks)
|
||||||
read_tags = self.get_tags_from_bookmarks(read_bookmarks)
|
read_tags = self.get_tags_from_bookmarks(read_bookmarks)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:archived"))
|
response = self.client.get(reverse("linkding:bookmarks.archived"))
|
||||||
self.assertVisibleBookmarks(response, unread_bookmarks)
|
self.assertVisibleBookmarks(response, unread_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, read_bookmarks)
|
self.assertInvisibleBookmarks(response, read_bookmarks)
|
||||||
self.assertVisibleTags(response, unread_tags)
|
self.assertVisibleTags(response, unread_tags)
|
||||||
@@ -149,7 +149,8 @@ class BookmarkArchivedViewTestCase(
|
|||||||
self.setup_bookmark(is_archived=True, tags=tags)
|
self.setup_bookmark(is_archived=True, tags=tags)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:archived") + f"?q=%23{tags[0].name}+%23{tags[1].name}"
|
reverse("linkding:bookmarks.archived")
|
||||||
|
+ f"?q=%23{tags[0].name}+%23{tags[1].name}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertSelectedTags(response, [tags[0], tags[1]])
|
self.assertSelectedTags(response, [tags[0], tags[1]])
|
||||||
@@ -167,7 +168,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
self.setup_bookmark(title=tags[0].name, tags=tags, is_archived=True)
|
self.setup_bookmark(title=tags[0].name, tags=tags, is_archived=True)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:archived")
|
reverse("linkding:bookmarks.archived")
|
||||||
+ f"?q={tags[0].name}+%23{tags[1].name.upper()}"
|
+ f"?q={tags[0].name}+%23{tags[1].name.upper()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
self.setup_bookmark(tags=tags, is_archived=True)
|
self.setup_bookmark(tags=tags, is_archived=True)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:archived")
|
reverse("linkding:bookmarks.archived")
|
||||||
+ f"?q={tags[0].name}+%23{tags[1].name.upper()}"
|
+ f"?q={tags[0].name}+%23{tags[1].name.upper()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
def test_should_open_bookmarks_in_new_page_by_default(self):
|
def test_should_open_bookmarks_in_new_page_by_default(self):
|
||||||
visible_bookmarks = self.setup_numbered_bookmarks(3, archived=True)
|
visible_bookmarks = self.setup_numbered_bookmarks(3, archived=True)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:archived"))
|
response = self.client.get(reverse("linkding:bookmarks.archived"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks, "_blank")
|
self.assertVisibleBookmarks(response, visible_bookmarks, "_blank")
|
||||||
|
|
||||||
@@ -207,14 +208,14 @@ class BookmarkArchivedViewTestCase(
|
|||||||
|
|
||||||
visible_bookmarks = self.setup_numbered_bookmarks(3, archived=True)
|
visible_bookmarks = self.setup_numbered_bookmarks(3, archived=True)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:archived"))
|
response = self.client.get(reverse("linkding:bookmarks.archived"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks, "_self")
|
self.assertVisibleBookmarks(response, visible_bookmarks, "_self")
|
||||||
|
|
||||||
def test_edit_link_return_url_respects_search_options(self):
|
def test_edit_link_return_url_respects_search_options(self):
|
||||||
bookmark = self.setup_bookmark(title="foo", is_archived=True)
|
bookmark = self.setup_bookmark(title="foo", is_archived=True)
|
||||||
edit_url = reverse("bookmarks:edit", args=[bookmark.id])
|
edit_url = reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
base_url = reverse("bookmarks:archived")
|
base_url = reverse("linkding:bookmarks.archived")
|
||||||
|
|
||||||
# without query params
|
# without query params
|
||||||
return_url = urllib.parse.quote(base_url)
|
return_url = urllib.parse.quote(base_url)
|
||||||
@@ -240,8 +241,8 @@ class BookmarkArchivedViewTestCase(
|
|||||||
self.assertEditLink(response, url)
|
self.assertEditLink(response, url)
|
||||||
|
|
||||||
def test_bulk_edit_respects_search_options(self):
|
def test_bulk_edit_respects_search_options(self):
|
||||||
action_url = reverse("bookmarks:archived.action")
|
action_url = reverse("linkding:bookmarks.archived.action")
|
||||||
base_url = reverse("bookmarks:archived")
|
base_url = reverse("linkding:bookmarks.archived")
|
||||||
|
|
||||||
# without params
|
# without params
|
||||||
url = f"{action_url}"
|
url = f"{action_url}"
|
||||||
@@ -264,7 +265,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
self.assertBulkActionForm(response, url)
|
self.assertBulkActionForm(response, url)
|
||||||
|
|
||||||
def test_allowed_bulk_actions(self):
|
def test_allowed_bulk_actions(self):
|
||||||
url = reverse("bookmarks:archived")
|
url = reverse("linkding:bookmarks.archived")
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -287,7 +288,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
user_profile.enable_sharing = True
|
user_profile.enable_sharing = True
|
||||||
user_profile.save()
|
user_profile.save()
|
||||||
|
|
||||||
url = reverse("bookmarks:archived")
|
url = reverse("linkding:bookmarks.archived")
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -309,13 +310,13 @@ class BookmarkArchivedViewTestCase(
|
|||||||
|
|
||||||
def test_apply_search_preferences(self):
|
def test_apply_search_preferences(self):
|
||||||
# no params
|
# no params
|
||||||
response = self.client.post(reverse("bookmarks:archived"))
|
response = self.client.post(reverse("linkding:bookmarks.archived"))
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(response.url, reverse("bookmarks:archived"))
|
self.assertEqual(response.url, reverse("linkding:bookmarks.archived"))
|
||||||
|
|
||||||
# some params
|
# some params
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:archived"),
|
reverse("linkding:bookmarks.archived"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -323,12 +324,13 @@ class BookmarkArchivedViewTestCase(
|
|||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.url, reverse("bookmarks:archived") + "?q=foo&sort=title_asc"
|
response.url,
|
||||||
|
reverse("linkding:bookmarks.archived") + "?q=foo&sort=title_asc",
|
||||||
)
|
)
|
||||||
|
|
||||||
# params with default value are removed
|
# params with default value are removed
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:archived"),
|
reverse("linkding:bookmarks.archived"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"user": "",
|
"user": "",
|
||||||
@@ -339,12 +341,12 @@ class BookmarkArchivedViewTestCase(
|
|||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.url, reverse("bookmarks:archived") + "?q=foo&unread=yes"
|
response.url, reverse("linkding:bookmarks.archived") + "?q=foo&unread=yes"
|
||||||
)
|
)
|
||||||
|
|
||||||
# page is removed
|
# page is removed
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:archived"),
|
reverse("linkding:bookmarks.archived"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"page": "2",
|
"page": "2",
|
||||||
@@ -353,7 +355,8 @@ class BookmarkArchivedViewTestCase(
|
|||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.url, reverse("bookmarks:archived") + "?q=foo&sort=title_asc"
|
response.url,
|
||||||
|
reverse("linkding:bookmarks.archived") + "?q=foo&sort=title_asc",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_save_search_preferences(self):
|
def test_save_search_preferences(self):
|
||||||
@@ -361,7 +364,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
|
|
||||||
# no params
|
# no params
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived"),
|
reverse("linkding:bookmarks.archived"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
},
|
},
|
||||||
@@ -378,7 +381,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
|
|
||||||
# with param
|
# with param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived"),
|
reverse("linkding:bookmarks.archived"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -396,7 +399,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
|
|
||||||
# add a param
|
# add a param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived"),
|
reverse("linkding:bookmarks.archived"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -415,7 +418,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
|
|
||||||
# remove a param
|
# remove a param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived"),
|
reverse("linkding:bookmarks.archived"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"unread": BookmarkSearch.FILTER_UNREAD_YES,
|
"unread": BookmarkSearch.FILTER_UNREAD_YES,
|
||||||
@@ -433,7 +436,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
|
|
||||||
# ignores non-preferences
|
# ignores non-preferences
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:archived"),
|
reverse("linkding:bookmarks.archived"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
@@ -453,7 +456,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_url_encode_bookmark_actions_url(self):
|
def test_url_encode_bookmark_actions_url(self):
|
||||||
url = reverse("bookmarks:archived") + "?q=%23foo"
|
url = reverse("linkding:bookmarks.archived") + "?q=%23foo"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
@@ -467,34 +470,34 @@ class BookmarkArchivedViewTestCase(
|
|||||||
def test_encode_search_params(self):
|
def test_encode_search_params(self):
|
||||||
bookmark = self.setup_bookmark(description="alert('xss')", is_archived=True)
|
bookmark = self.setup_bookmark(description="alert('xss')", is_archived=True)
|
||||||
|
|
||||||
url = reverse("bookmarks:archived") + "?q=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.archived") + "?q=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
self.assertContains(response, bookmark.url)
|
self.assertContains(response, bookmark.url)
|
||||||
|
|
||||||
url = reverse("bookmarks:archived") + "?sort=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.archived") + "?sort=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:archived") + "?unread=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.archived") + "?unread=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:archived") + "?shared=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.archived") + "?shared=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:archived") + "?user=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.archived") + "?user=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:archived") + "?page=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.archived") + "?page=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
def test_turbo_frame_details_modal_renders_details_modal_update(self):
|
def test_turbo_frame_details_modal_renders_details_modal_update(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse("bookmarks:archived") + f"?bookmark_id={bookmark.id}"
|
url = reverse("linkding:bookmarks.archived") + f"?bookmark_id={bookmark.id}"
|
||||||
response = self.client.get(url, headers={"Turbo-Frame": "details-modal"})
|
response = self.client.get(url, headers={"Turbo-Frame": "details-modal"})
|
||||||
|
|
||||||
self.assertEqual(200, response.status_code)
|
self.assertEqual(200, response.status_code)
|
||||||
@@ -505,7 +508,7 @@ class BookmarkArchivedViewTestCase(
|
|||||||
self.assertIsNone(soup.select_one("#tag-cloud-container"))
|
self.assertIsNone(soup.select_one("#tag-cloud-container"))
|
||||||
|
|
||||||
def test_does_not_include_rss_feed(self):
|
def test_does_not_include_rss_feed(self):
|
||||||
response = self.client.get(reverse("bookmarks:archived"))
|
response = self.client.get(reverse("linkding:bookmarks.archived"))
|
||||||
soup = self.make_soup(response.content.decode())
|
soup = self.make_soup(response.content.decode())
|
||||||
|
|
||||||
feed = soup.select_one('head link[type="application/rss+xml"]')
|
feed = soup.select_one('head link[type="application/rss+xml"]')
|
||||||
|
@@ -31,7 +31,7 @@ class BookmarkArchivedViewPerformanceTestCase(
|
|||||||
# capture number of queries
|
# capture number of queries
|
||||||
context = CaptureQueriesContext(self.get_connection())
|
context = CaptureQueriesContext(self.get_connection())
|
||||||
with context:
|
with context:
|
||||||
response = self.client.get(reverse("bookmarks:archived"))
|
response = self.client.get(reverse("linkding:bookmarks.archived"))
|
||||||
html = response.content.decode("utf-8")
|
html = response.content.decode("utf-8")
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
list_items = soup.select("li[ld-bookmark-item]")
|
list_items = soup.select("li[ld-bookmark-item]")
|
||||||
@@ -46,7 +46,7 @@ class BookmarkArchivedViewPerformanceTestCase(
|
|||||||
|
|
||||||
# assert num queries doesn't increase
|
# assert num queries doesn't increase
|
||||||
with self.assertNumQueries(number_of_queries):
|
with self.assertNumQueries(number_of_queries):
|
||||||
response = self.client.get(reverse("bookmarks:archived"))
|
response = self.client.get(reverse("linkding:bookmarks.archived"))
|
||||||
html = response.content.decode("utf-8")
|
html = response.content.decode("utf-8")
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
list_items = soup.select("li[ld-bookmark-item]")
|
list_items = soup.select("li[ld-bookmark-item]")
|
||||||
|
@@ -117,13 +117,13 @@ class BookmarkAssetViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_view_access(self):
|
def test_view_access(self):
|
||||||
self.view_access_test("bookmarks:assets.view")
|
self.view_access_test("linkding:assets.view")
|
||||||
|
|
||||||
def test_view_access_guest_user(self):
|
def test_view_access_guest_user(self):
|
||||||
self.view_access_guest_user_test("bookmarks:assets.view")
|
self.view_access_guest_user_test("linkding:assets.view")
|
||||||
|
|
||||||
def test_reader_view_access(self):
|
def test_reader_view_access(self):
|
||||||
self.view_access_test("bookmarks:assets.read")
|
self.view_access_test("linkding:assets.read")
|
||||||
|
|
||||||
def test_reader_view_access_guest_user(self):
|
def test_reader_view_access_guest_user(self):
|
||||||
self.view_access_guest_user_test("bookmarks:assets.read")
|
self.view_access_guest_user_test("linkding:assets.read")
|
||||||
|
@@ -43,7 +43,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-list", kwargs={"bookmark_id": bookmark1.id}
|
"linkding:bookmark_asset-list", kwargs={"bookmark_id": bookmark1.id}
|
||||||
)
|
)
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
self.assertEqual(len(response.data["results"]), 3)
|
self.assertEqual(len(response.data["results"]), 3)
|
||||||
@@ -52,7 +52,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.assertAsset(bookmark1_assets[2], response.data["results"][2])
|
self.assertAsset(bookmark1_assets[2], response.data["results"][2])
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-list", kwargs={"bookmark_id": bookmark2.id}
|
"linkding:bookmark_asset-list", kwargs={"bookmark_id": bookmark2.id}
|
||||||
)
|
)
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
self.assertEqual(len(response.data["results"]), 3)
|
self.assertEqual(len(response.data["results"]), 3)
|
||||||
@@ -68,14 +68,14 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_asset(bookmark=bookmark)
|
self.setup_asset(bookmark=bookmark)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-list", kwargs={"bookmark_id": bookmark.id}
|
"linkding:bookmark_asset-list", kwargs={"bookmark_id": bookmark.id}
|
||||||
)
|
)
|
||||||
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
def test_asset_list_requires_authentication(self):
|
def test_asset_list_requires_authentication(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-list", kwargs={"bookmark_id": bookmark.id}
|
"linkding:bookmark_asset-list", kwargs={"bookmark_id": bookmark.id}
|
||||||
)
|
)
|
||||||
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
gzip=False,
|
gzip=False,
|
||||||
)
|
)
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-detail",
|
"linkding:bookmark_asset-detail",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
@@ -108,7 +108,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
asset = self.setup_asset(bookmark=bookmark)
|
asset = self.setup_asset(bookmark=bookmark)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-detail",
|
"linkding:bookmark_asset-detail",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
@@ -117,7 +117,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
asset = self.setup_asset(bookmark=bookmark)
|
asset = self.setup_asset(bookmark=bookmark)
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-detail",
|
"linkding:bookmark_asset-detail",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
@@ -145,7 +145,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_asset_file(asset=asset, file_content=file_content)
|
self.setup_asset_file(asset=asset, file_content=file_content)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-download",
|
"linkding:bookmark_asset-download",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
@@ -173,7 +173,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_asset_file(asset=asset, file_content=file_content)
|
self.setup_asset_file(asset=asset, file_content=file_content)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-download",
|
"linkding:bookmark_asset-download",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
@@ -199,7 +199,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-download",
|
"linkding:bookmark_asset-download",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
@@ -212,7 +212,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
asset = self.setup_asset(bookmark=bookmark)
|
asset = self.setup_asset(bookmark=bookmark)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-download",
|
"linkding:bookmark_asset-download",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
@@ -221,7 +221,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
asset = self.setup_asset(bookmark=bookmark)
|
asset = self.setup_asset(bookmark=bookmark)
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-download",
|
"linkding:bookmark_asset-download",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
@@ -239,7 +239,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
"linkding:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
||||||
)
|
)
|
||||||
file_content = b"test file content"
|
file_content = b"test file content"
|
||||||
file_name = "test.txt"
|
file_name = "test.txt"
|
||||||
@@ -264,7 +264,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
"linkding:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.post(url, {}, format="multipart")
|
response = self.client.post(url, {}, format="multipart")
|
||||||
@@ -276,7 +276,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
other_user = self.setup_user()
|
other_user = self.setup_user()
|
||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
"linkding:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.post(url, {}, format="multipart")
|
response = self.client.post(url, {}, format="multipart")
|
||||||
@@ -285,7 +285,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
def test_upload_asset_requires_authentication(self):
|
def test_upload_asset_requires_authentication(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
"linkding:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.post(url, {}, format="multipart")
|
response = self.client.post(url, {}, format="multipart")
|
||||||
@@ -296,7 +296,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
"linkding:bookmark_asset-upload", kwargs={"bookmark_id": bookmark.id}
|
||||||
)
|
)
|
||||||
response = self.client.post(url, {}, format="multipart")
|
response = self.client.post(url, {}, format="multipart")
|
||||||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
|
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
|
||||||
@@ -309,7 +309,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_asset_file(asset=asset)
|
self.setup_asset_file(asset=asset)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-detail",
|
"linkding:bookmark_asset-detail",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
self.delete(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
self.delete(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
||||||
@@ -325,7 +325,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
asset = self.setup_asset(bookmark=bookmark)
|
asset = self.setup_asset(bookmark=bookmark)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-detail",
|
"linkding:bookmark_asset-detail",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
self.delete(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.delete(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
@@ -334,7 +334,7 @@ class BookmarkAssetsApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
asset = self.setup_asset(bookmark=bookmark)
|
asset = self.setup_asset(bookmark=bookmark)
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark_asset-detail",
|
"linkding:bookmark_asset-detail",
|
||||||
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
kwargs={"bookmark_id": asset.bookmark.id, "pk": asset.id},
|
||||||
)
|
)
|
||||||
self.delete(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.delete(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
@@ -15,18 +15,20 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
self.client.force_login(user)
|
self.client.force_login(user)
|
||||||
|
|
||||||
def get_details_form(self, soup, bookmark):
|
def get_details_form(self, soup, bookmark):
|
||||||
form_url = reverse("bookmarks:index.action") + f"?details={bookmark.id}"
|
form_url = (
|
||||||
|
reverse("linkding:bookmarks.index.action") + f"?details={bookmark.id}"
|
||||||
|
)
|
||||||
return soup.find("form", {"action": form_url, "enctype": "multipart/form-data"})
|
return soup.find("form", {"action": form_url, "enctype": "multipart/form-data"})
|
||||||
|
|
||||||
def get_index_details_modal(self, bookmark):
|
def get_index_details_modal(self, bookmark):
|
||||||
url = reverse("bookmarks:index") + f"?details={bookmark.id}"
|
url = reverse("linkding:bookmarks.index") + f"?details={bookmark.id}"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
soup = self.make_soup(response.content)
|
soup = self.make_soup(response.content)
|
||||||
modal = soup.find("turbo-frame", {"id": "details-modal"})
|
modal = soup.find("turbo-frame", {"id": "details-modal"})
|
||||||
return modal
|
return modal
|
||||||
|
|
||||||
def get_shared_details_modal(self, bookmark):
|
def get_shared_details_modal(self, bookmark):
|
||||||
url = reverse("bookmarks:shared") + f"?details={bookmark.id}"
|
url = reverse("linkding:bookmarks.shared") + f"?details={bookmark.id}"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
soup = self.make_soup(response.content)
|
soup = self.make_soup(response.content)
|
||||||
modal = soup.find("turbo-frame", {"id": "details-modal"})
|
modal = soup.find("turbo-frame", {"id": "details-modal"})
|
||||||
@@ -55,7 +57,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
# own bookmark
|
# own bookmark
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:index") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.index") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -63,18 +65,20 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
other_user = self.setup_user()
|
other_user = self.setup_user()
|
||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:index") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.index") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
# non-existent bookmark - just returns without modal in response
|
# non-existent bookmark - just returns without modal in response
|
||||||
response = self.client.get(reverse("bookmarks:index") + "?details=9999")
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.index") + "?details=9999"
|
||||||
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
# guest user
|
# guest user
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:shared") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.shared") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
@@ -82,7 +86,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
# own bookmark
|
# own bookmark
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:index") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.index") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -90,18 +94,20 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
other_user = self.setup_user()
|
other_user = self.setup_user()
|
||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:index") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.index") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
# non-existent bookmark - just returns without modal in response
|
# non-existent bookmark - just returns without modal in response
|
||||||
response = self.client.get(reverse("bookmarks:index") + "?details=9999")
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.index") + "?details=9999"
|
||||||
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
# guest user
|
# guest user
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:shared") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.shared") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
@@ -111,7 +117,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
bookmark = self.setup_bookmark(shared=True, user=other_user)
|
bookmark = self.setup_bookmark(shared=True, user=other_user)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:shared") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.shared") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
@@ -121,14 +127,14 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:shared") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.shared") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
# shared bookmark, guest user, no public sharing
|
# shared bookmark, guest user, no public sharing
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:shared") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.shared") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
@@ -137,7 +143,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:shared") + f"?details={bookmark.id}"
|
reverse("linkding:bookmarks.shared") + f"?details={bookmark.id}"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -231,7 +237,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
soup = self.get_index_details_modal(bookmark)
|
soup = self.get_index_details_modal(bookmark)
|
||||||
self.assertEqual(self.count_weblinks(soup), 3)
|
self.assertEqual(self.count_weblinks(soup), 3)
|
||||||
|
|
||||||
reader_mode_url = reverse("bookmarks:assets.read", args=[asset.id])
|
reader_mode_url = reverse("linkding:assets.read", args=[asset.id])
|
||||||
link = self.find_weblink(soup, reader_mode_url)
|
link = self.find_weblink(soup, reader_mode_url)
|
||||||
self.assertIsNotNone(link)
|
self.assertIsNotNone(link)
|
||||||
|
|
||||||
@@ -465,7 +471,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
for tag in bookmark.tags.all():
|
for tag in bookmark.tags.all():
|
||||||
tag_link = section.find("a", string=f"#{tag.name}")
|
tag_link = section.find("a", string=f"#{tag.name}")
|
||||||
self.assertIsNotNone(tag_link)
|
self.assertIsNotNone(tag_link)
|
||||||
expected_url = reverse("bookmarks:index") + f"?q=%23{tag.name}"
|
expected_url = reverse("linkding:bookmarks.index") + f"?q=%23{tag.name}"
|
||||||
self.assertEqual(tag_link["href"], expected_url)
|
self.assertEqual(tag_link["href"], expected_url)
|
||||||
|
|
||||||
def test_description(self):
|
def test_description(self):
|
||||||
@@ -519,7 +525,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
|
|
||||||
form = delete_button.find_parent("form")
|
form = delete_button.find_parent("form")
|
||||||
self.assertIsNotNone(form)
|
self.assertIsNotNone(form)
|
||||||
expected_url = reverse("bookmarks:index.action")
|
expected_url = reverse("linkding:bookmarks.index.action")
|
||||||
self.assertEqual(expected_url, form["action"])
|
self.assertEqual(expected_url, form["action"])
|
||||||
|
|
||||||
def test_actions_visibility(self):
|
def test_actions_visibility(self):
|
||||||
@@ -605,7 +611,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
self.assertIsNotNone(asset_text)
|
self.assertIsNotNone(asset_text)
|
||||||
self.assertIn(asset.display_name, asset_text.text)
|
self.assertIn(asset.display_name, asset_text.text)
|
||||||
|
|
||||||
view_url = reverse("bookmarks:assets.view", args=[asset.id])
|
view_url = reverse("linkding:assets.view", args=[asset.id])
|
||||||
view_link = asset_item.find("a", {"href": view_url})
|
view_link = asset_item.find("a", {"href": view_url})
|
||||||
self.assertIsNotNone(view_link)
|
self.assertIsNotNone(view_link)
|
||||||
|
|
||||||
@@ -688,7 +694,7 @@ class BookmarkDetailsModalTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||||||
|
|
||||||
soup = self.get_index_details_modal(bookmark)
|
soup = self.get_index_details_modal(bookmark)
|
||||||
asset_item = self.find_asset(soup, asset)
|
asset_item = self.find_asset(soup, asset)
|
||||||
view_url = reverse("bookmarks:assets.view", args=[asset.id])
|
view_url = reverse("linkding:assets.view", args=[asset.id])
|
||||||
view_link = asset_item.find("a", {"href": view_url})
|
view_link = asset_item.find("a", {"href": view_url})
|
||||||
self.assertIsNone(view_link)
|
self.assertIsNone(view_link)
|
||||||
|
|
||||||
|
@@ -28,14 +28,18 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_should_render_successfully(self):
|
def test_should_render_successfully(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
response = self.client.get(reverse("bookmarks:edit", args=[bookmark.id]))
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_should_edit_bookmark(self):
|
def test_should_edit_bookmark(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
form_data = self.create_form_data({"id": bookmark.id})
|
form_data = self.create_form_data({"id": bookmark.id})
|
||||||
|
|
||||||
self.client.post(reverse("bookmarks:edit", args=[bookmark.id]), form_data)
|
self.client.post(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id]), form_data
|
||||||
|
)
|
||||||
|
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
|
|
||||||
@@ -55,7 +59,7 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
form_data = self.create_form_data({"id": bookmark.id, "url": ""})
|
form_data = self.create_form_data({"id": bookmark.id, "url": ""})
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:edit", args=[bookmark.id]), form_data
|
reverse("linkding:bookmarks.edit", args=[bookmark.id]), form_data
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 422)
|
self.assertEqual(response.status_code, 422)
|
||||||
|
|
||||||
@@ -63,12 +67,16 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
form_data = self.create_form_data({"id": bookmark.id, "unread": True})
|
form_data = self.create_form_data({"id": bookmark.id, "unread": True})
|
||||||
self.client.post(reverse("bookmarks:edit", args=[bookmark.id]), form_data)
|
self.client.post(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id]), form_data
|
||||||
|
)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertTrue(bookmark.unread)
|
self.assertTrue(bookmark.unread)
|
||||||
|
|
||||||
form_data = self.create_form_data({"id": bookmark.id, "unread": False})
|
form_data = self.create_form_data({"id": bookmark.id, "unread": False})
|
||||||
self.client.post(reverse("bookmarks:edit", args=[bookmark.id]), form_data)
|
self.client.post(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id]), form_data
|
||||||
|
)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertFalse(bookmark.unread)
|
self.assertFalse(bookmark.unread)
|
||||||
|
|
||||||
@@ -76,12 +84,16 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
form_data = self.create_form_data({"id": bookmark.id, "shared": True})
|
form_data = self.create_form_data({"id": bookmark.id, "shared": True})
|
||||||
self.client.post(reverse("bookmarks:edit", args=[bookmark.id]), form_data)
|
self.client.post(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id]), form_data
|
||||||
|
)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertTrue(bookmark.shared)
|
self.assertTrue(bookmark.shared)
|
||||||
|
|
||||||
form_data = self.create_form_data({"id": bookmark.id, "shared": False})
|
form_data = self.create_form_data({"id": bookmark.id, "shared": False})
|
||||||
self.client.post(reverse("bookmarks:edit", args=[bookmark.id]), form_data)
|
self.client.post(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id]), form_data
|
||||||
|
)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertFalse(bookmark.shared)
|
self.assertFalse(bookmark.shared)
|
||||||
|
|
||||||
@@ -95,7 +107,9 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
notes="edited notes",
|
notes="edited notes",
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:edit", args=[bookmark.id]))
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -151,21 +165,21 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
# if the URL isn't modified it's not a duplicate
|
# if the URL isn't modified it's not a duplicate
|
||||||
form_data = self.create_form_data({"url": edited_bookmark.url})
|
form_data = self.create_form_data({"url": edited_bookmark.url})
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:edit", args=[edited_bookmark.id]), form_data
|
reverse("linkding:bookmarks.edit", args=[edited_bookmark.id]), form_data
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
|
|
||||||
# if the URL is already bookmarked by another user, it's not a duplicate
|
# if the URL is already bookmarked by another user, it's not a duplicate
|
||||||
form_data = self.create_form_data({"url": other_user_bookmark.url})
|
form_data = self.create_form_data({"url": other_user_bookmark.url})
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:edit", args=[edited_bookmark.id]), form_data
|
reverse("linkding:bookmarks.edit", args=[edited_bookmark.id]), form_data
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
|
|
||||||
# if the URL is already bookmarked by the same user, it's a duplicate
|
# if the URL is already bookmarked by the same user, it's a duplicate
|
||||||
form_data = self.create_form_data({"url": existing_bookmark.url})
|
form_data = self.create_form_data({"url": existing_bookmark.url})
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:edit", args=[edited_bookmark.id]), form_data
|
reverse("linkding:bookmarks.edit", args=[edited_bookmark.id]), form_data
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 422)
|
self.assertEqual(response.status_code, 422)
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -180,23 +194,23 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
form_data = self.create_form_data()
|
form_data = self.create_form_data()
|
||||||
|
|
||||||
url = (
|
url = (
|
||||||
reverse("bookmarks:edit", args=[bookmark.id])
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
+ "?return_url="
|
+ "?return_url="
|
||||||
+ reverse("bookmarks:close")
|
+ reverse("linkding:bookmarks.close")
|
||||||
)
|
)
|
||||||
response = self.client.post(url, form_data)
|
response = self.client.post(url, form_data)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:close"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.close"))
|
||||||
|
|
||||||
def test_should_redirect_to_bookmark_index_by_default(self):
|
def test_should_redirect_to_bookmark_index_by_default(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
form_data = self.create_form_data()
|
form_data = self.create_form_data()
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:edit", args=[bookmark.id]), form_data
|
reverse("linkding:bookmarks.edit", args=[bookmark.id]), form_data
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
def test_should_not_redirect_to_external_url(self):
|
def test_should_not_redirect_to_external_url(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
@@ -204,17 +218,17 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
def post_with(return_url, follow=None):
|
def post_with(return_url, follow=None):
|
||||||
form_data = self.create_form_data()
|
form_data = self.create_form_data()
|
||||||
url = (
|
url = (
|
||||||
reverse("bookmarks:edit", args=[bookmark.id])
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
+ f"?return_url={return_url}"
|
+ f"?return_url={return_url}"
|
||||||
)
|
)
|
||||||
return self.client.post(url, form_data, follow=follow)
|
return self.client.post(url, form_data, follow=follow)
|
||||||
|
|
||||||
response = post_with("https://example.com")
|
response = post_with("https://example.com")
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
response = post_with("//example.com")
|
response = post_with("//example.com")
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
response = post_with("://example.com")
|
response = post_with("://example.com")
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
response = post_with("/foo//example.com", follow=True)
|
response = post_with("/foo//example.com", follow=True)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
@@ -227,7 +241,7 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
form_data = self.create_form_data({"id": bookmark.id})
|
form_data = self.create_form_data({"id": bookmark.id})
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:edit", args=[bookmark.id]), form_data
|
reverse("linkding:bookmarks.edit", args=[bookmark.id]), form_data
|
||||||
)
|
)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertNotEqual(bookmark.url, form_data["url"])
|
self.assertNotEqual(bookmark.url, form_data["url"])
|
||||||
@@ -238,7 +252,9 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
self.user.profile.enable_sharing = False
|
self.user.profile.enable_sharing = False
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
response = self.client.get(reverse("bookmarks:edit", args=[bookmark.id]))
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -255,7 +271,9 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
self.user.profile.enable_sharing = True
|
self.user.profile.enable_sharing = True
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
response = self.client.get(reverse("bookmarks:edit", args=[bookmark.id]))
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -272,12 +290,16 @@ class BookmarkEditViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_should_hide_notes_if_there_are_no_notes(self):
|
def test_should_hide_notes_if_there_are_no_notes(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
response = self.client.get(reverse("bookmarks:edit", args=[bookmark.id]))
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
|
)
|
||||||
|
|
||||||
self.assertContains(response, '<details class="notes">', count=1)
|
self.assertContains(response, '<details class="notes">', count=1)
|
||||||
|
|
||||||
def test_should_show_notes_if_there_are_notes(self):
|
def test_should_show_notes_if_there_are_notes(self):
|
||||||
bookmark = self.setup_bookmark(notes="test notes")
|
bookmark = self.setup_bookmark(notes="test notes")
|
||||||
response = self.client.get(reverse("bookmarks:edit", args=[bookmark.id]))
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
|
)
|
||||||
|
|
||||||
self.assertContains(response, '<details class="notes" open>', count=1)
|
self.assertContains(response, '<details class="notes" open>', count=1)
|
||||||
|
@@ -44,7 +44,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
self.setup_bookmark(user=other_user),
|
self.setup_bookmark(user=other_user),
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks)
|
self.assertVisibleBookmarks(response, visible_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
||||||
@@ -53,7 +53,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
visible_bookmarks = self.setup_numbered_bookmarks(3, prefix="foo")
|
visible_bookmarks = self.setup_numbered_bookmarks(3, prefix="foo")
|
||||||
invisible_bookmarks = self.setup_numbered_bookmarks(3, prefix="bar")
|
invisible_bookmarks = self.setup_numbered_bookmarks(3, prefix="bar")
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index") + "?q=foo")
|
response = self.client.get(reverse("linkding:bookmarks.index") + "?q=foo")
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks)
|
self.assertVisibleBookmarks(response, visible_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
||||||
@@ -75,7 +75,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
archived_bookmarks + other_user_bookmarks
|
archived_bookmarks + other_user_bookmarks
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
self.assertVisibleTags(response, visible_tags)
|
self.assertVisibleTags(response, visible_tags)
|
||||||
self.assertInvisibleTags(response, invisible_tags)
|
self.assertInvisibleTags(response, invisible_tags)
|
||||||
@@ -91,7 +91,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
visible_tags = self.get_tags_from_bookmarks(visible_bookmarks)
|
visible_tags = self.get_tags_from_bookmarks(visible_bookmarks)
|
||||||
invisible_tags = self.get_tags_from_bookmarks(invisible_bookmarks)
|
invisible_tags = self.get_tags_from_bookmarks(invisible_bookmarks)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index") + "?q=foo")
|
response = self.client.get(reverse("linkding:bookmarks.index") + "?q=foo")
|
||||||
|
|
||||||
self.assertVisibleTags(response, visible_tags)
|
self.assertVisibleTags(response, visible_tags)
|
||||||
self.assertInvisibleTags(response, invisible_tags)
|
self.assertInvisibleTags(response, invisible_tags)
|
||||||
@@ -113,7 +113,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
unread_tags = self.get_tags_from_bookmarks(unread_bookmarks)
|
unread_tags = self.get_tags_from_bookmarks(unread_bookmarks)
|
||||||
read_tags = self.get_tags_from_bookmarks(read_bookmarks)
|
read_tags = self.get_tags_from_bookmarks(read_bookmarks)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
self.assertVisibleBookmarks(response, unread_bookmarks)
|
self.assertVisibleBookmarks(response, unread_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, read_bookmarks)
|
self.assertInvisibleBookmarks(response, read_bookmarks)
|
||||||
self.assertVisibleTags(response, unread_tags)
|
self.assertVisibleTags(response, unread_tags)
|
||||||
@@ -130,7 +130,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
self.setup_bookmark(tags=tags)
|
self.setup_bookmark(tags=tags)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:index")
|
reverse("linkding:bookmarks.index")
|
||||||
+ f"?q=%23{tags[0].name}+%23{tags[1].name.upper()}"
|
+ f"?q=%23{tags[0].name}+%23{tags[1].name.upper()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -149,7 +149,8 @@ class BookmarkIndexViewTestCase(
|
|||||||
self.setup_bookmark(title=tags[0].name, tags=tags)
|
self.setup_bookmark(title=tags[0].name, tags=tags)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:index") + f"?q={tags[0].name}+%23{tags[1].name.upper()}"
|
reverse("linkding:bookmarks.index")
|
||||||
|
+ f"?q={tags[0].name}+%23{tags[1].name.upper()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertSelectedTags(response, [tags[1]])
|
self.assertSelectedTags(response, [tags[1]])
|
||||||
@@ -168,7 +169,8 @@ class BookmarkIndexViewTestCase(
|
|||||||
self.setup_bookmark(tags=tags)
|
self.setup_bookmark(tags=tags)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:index") + f"?q={tags[0].name}+%23{tags[1].name.upper()}"
|
reverse("linkding:bookmarks.index")
|
||||||
|
+ f"?q={tags[0].name}+%23{tags[1].name.upper()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertSelectedTags(response, [tags[0], tags[1]])
|
self.assertSelectedTags(response, [tags[0], tags[1]])
|
||||||
@@ -176,7 +178,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
def test_should_open_bookmarks_in_new_page_by_default(self):
|
def test_should_open_bookmarks_in_new_page_by_default(self):
|
||||||
visible_bookmarks = self.setup_numbered_bookmarks(3)
|
visible_bookmarks = self.setup_numbered_bookmarks(3)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks, "_blank")
|
self.assertVisibleBookmarks(response, visible_bookmarks, "_blank")
|
||||||
|
|
||||||
@@ -187,14 +189,14 @@ class BookmarkIndexViewTestCase(
|
|||||||
|
|
||||||
visible_bookmarks = self.setup_numbered_bookmarks(3)
|
visible_bookmarks = self.setup_numbered_bookmarks(3)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks, "_self")
|
self.assertVisibleBookmarks(response, visible_bookmarks, "_self")
|
||||||
|
|
||||||
def test_edit_link_return_url_respects_search_options(self):
|
def test_edit_link_return_url_respects_search_options(self):
|
||||||
bookmark = self.setup_bookmark(title="foo")
|
bookmark = self.setup_bookmark(title="foo")
|
||||||
edit_url = reverse("bookmarks:edit", args=[bookmark.id])
|
edit_url = reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
base_url = reverse("bookmarks:index")
|
base_url = reverse("linkding:bookmarks.index")
|
||||||
|
|
||||||
# without query params
|
# without query params
|
||||||
return_url = urllib.parse.quote(base_url)
|
return_url = urllib.parse.quote(base_url)
|
||||||
@@ -220,8 +222,8 @@ class BookmarkIndexViewTestCase(
|
|||||||
self.assertEditLink(response, url)
|
self.assertEditLink(response, url)
|
||||||
|
|
||||||
def test_bulk_edit_respects_search_options(self):
|
def test_bulk_edit_respects_search_options(self):
|
||||||
action_url = reverse("bookmarks:index.action")
|
action_url = reverse("linkding:bookmarks.index.action")
|
||||||
base_url = reverse("bookmarks:index")
|
base_url = reverse("linkding:bookmarks.index")
|
||||||
|
|
||||||
# without params
|
# without params
|
||||||
url = f"{action_url}"
|
url = f"{action_url}"
|
||||||
@@ -244,7 +246,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
self.assertBulkActionForm(response, url)
|
self.assertBulkActionForm(response, url)
|
||||||
|
|
||||||
def test_allowed_bulk_actions(self):
|
def test_allowed_bulk_actions(self):
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -267,7 +269,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
user_profile.enable_sharing = True
|
user_profile.enable_sharing = True
|
||||||
user_profile.save()
|
user_profile.save()
|
||||||
|
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -289,13 +291,13 @@ class BookmarkIndexViewTestCase(
|
|||||||
|
|
||||||
def test_apply_search_preferences(self):
|
def test_apply_search_preferences(self):
|
||||||
# no params
|
# no params
|
||||||
response = self.client.post(reverse("bookmarks:index"))
|
response = self.client.post(reverse("linkding:bookmarks.index"))
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(response.url, reverse("bookmarks:index"))
|
self.assertEqual(response.url, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
# some params
|
# some params
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index"),
|
reverse("linkding:bookmarks.index"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -303,12 +305,12 @@ class BookmarkIndexViewTestCase(
|
|||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.url, reverse("bookmarks:index") + "?q=foo&sort=title_asc"
|
response.url, reverse("linkding:bookmarks.index") + "?q=foo&sort=title_asc"
|
||||||
)
|
)
|
||||||
|
|
||||||
# params with default value are removed
|
# params with default value are removed
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index"),
|
reverse("linkding:bookmarks.index"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"user": "",
|
"user": "",
|
||||||
@@ -318,11 +320,13 @@ class BookmarkIndexViewTestCase(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(response.url, reverse("bookmarks:index") + "?q=foo&unread=yes")
|
self.assertEqual(
|
||||||
|
response.url, reverse("linkding:bookmarks.index") + "?q=foo&unread=yes"
|
||||||
|
)
|
||||||
|
|
||||||
# page is removed
|
# page is removed
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:index"),
|
reverse("linkding:bookmarks.index"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"page": "2",
|
"page": "2",
|
||||||
@@ -331,7 +335,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.url, reverse("bookmarks:index") + "?q=foo&sort=title_asc"
|
response.url, reverse("linkding:bookmarks.index") + "?q=foo&sort=title_asc"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_save_search_preferences(self):
|
def test_save_search_preferences(self):
|
||||||
@@ -339,7 +343,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
|
|
||||||
# no params
|
# no params
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index"),
|
reverse("linkding:bookmarks.index"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
},
|
},
|
||||||
@@ -356,7 +360,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
|
|
||||||
# with param
|
# with param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index"),
|
reverse("linkding:bookmarks.index"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -374,7 +378,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
|
|
||||||
# add a param
|
# add a param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index"),
|
reverse("linkding:bookmarks.index"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -393,7 +397,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
|
|
||||||
# remove a param
|
# remove a param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index"),
|
reverse("linkding:bookmarks.index"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"unread": BookmarkSearch.FILTER_UNREAD_YES,
|
"unread": BookmarkSearch.FILTER_UNREAD_YES,
|
||||||
@@ -411,7 +415,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
|
|
||||||
# ignores non-preferences
|
# ignores non-preferences
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:index"),
|
reverse("linkding:bookmarks.index"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
@@ -431,7 +435,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_url_encode_bookmark_actions_url(self):
|
def test_url_encode_bookmark_actions_url(self):
|
||||||
url = reverse("bookmarks:index") + "?q=%23foo"
|
url = reverse("linkding:bookmarks.index") + "?q=%23foo"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
@@ -445,34 +449,34 @@ class BookmarkIndexViewTestCase(
|
|||||||
def test_encode_search_params(self):
|
def test_encode_search_params(self):
|
||||||
bookmark = self.setup_bookmark(description="alert('xss')")
|
bookmark = self.setup_bookmark(description="alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:index") + "?q=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.index") + "?q=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
self.assertContains(response, bookmark.url)
|
self.assertContains(response, bookmark.url)
|
||||||
|
|
||||||
url = reverse("bookmarks:index") + "?sort=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.index") + "?sort=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:index") + "?unread=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.index") + "?unread=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:index") + "?shared=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.index") + "?shared=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:index") + "?user=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.index") + "?user=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:index") + "?page=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.index") + "?page=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
def test_turbo_frame_details_modal_renders_details_modal_update(self):
|
def test_turbo_frame_details_modal_renders_details_modal_update(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse("bookmarks:index") + f"?bookmark_id={bookmark.id}"
|
url = reverse("linkding:bookmarks.index") + f"?bookmark_id={bookmark.id}"
|
||||||
response = self.client.get(url, headers={"Turbo-Frame": "details-modal"})
|
response = self.client.get(url, headers={"Turbo-Frame": "details-modal"})
|
||||||
|
|
||||||
self.assertEqual(200, response.status_code)
|
self.assertEqual(200, response.status_code)
|
||||||
@@ -483,7 +487,7 @@ class BookmarkIndexViewTestCase(
|
|||||||
self.assertIsNone(soup.select_one("#tag-cloud-container"))
|
self.assertIsNone(soup.select_one("#tag-cloud-container"))
|
||||||
|
|
||||||
def test_does_not_include_rss_feed(self):
|
def test_does_not_include_rss_feed(self):
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
soup = self.make_soup(response.content.decode())
|
soup = self.make_soup(response.content.decode())
|
||||||
|
|
||||||
feed = soup.select_one('head link[type="application/rss+xml"]')
|
feed = soup.select_one('head link[type="application/rss+xml"]')
|
||||||
|
@@ -31,7 +31,7 @@ class BookmarkIndexViewPerformanceTestCase(
|
|||||||
# capture number of queries
|
# capture number of queries
|
||||||
context = CaptureQueriesContext(self.get_connection())
|
context = CaptureQueriesContext(self.get_connection())
|
||||||
with context:
|
with context:
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode("utf-8")
|
html = response.content.decode("utf-8")
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
list_items = soup.select("li[ld-bookmark-item]")
|
list_items = soup.select("li[ld-bookmark-item]")
|
||||||
@@ -46,7 +46,7 @@ class BookmarkIndexViewPerformanceTestCase(
|
|||||||
|
|
||||||
# assert num queries doesn't increase
|
# assert num queries doesn't increase
|
||||||
with self.assertNumQueries(number_of_queries):
|
with self.assertNumQueries(number_of_queries):
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode("utf-8")
|
html = response.content.decode("utf-8")
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
list_items = soup.select("li[ld-bookmark-item]")
|
list_items = soup.select("li[ld-bookmark-item]")
|
||||||
|
@@ -29,7 +29,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
def test_should_create_new_bookmark(self):
|
def test_should_create_new_bookmark(self):
|
||||||
form_data = self.create_form_data()
|
form_data = self.create_form_data()
|
||||||
|
|
||||||
self.client.post(reverse("bookmarks:new"), form_data)
|
self.client.post(reverse("linkding:bookmarks.new"), form_data)
|
||||||
|
|
||||||
self.assertEqual(Bookmark.objects.count(), 1)
|
self.assertEqual(Bookmark.objects.count(), 1)
|
||||||
|
|
||||||
@@ -48,13 +48,13 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_should_return_422_with_invalid_form(self):
|
def test_should_return_422_with_invalid_form(self):
|
||||||
form_data = self.create_form_data({"url": ""})
|
form_data = self.create_form_data({"url": ""})
|
||||||
response = self.client.post(reverse("bookmarks:new"), form_data)
|
response = self.client.post(reverse("linkding:bookmarks.new"), form_data)
|
||||||
self.assertEqual(response.status_code, 422)
|
self.assertEqual(response.status_code, 422)
|
||||||
|
|
||||||
def test_should_create_new_unread_bookmark(self):
|
def test_should_create_new_unread_bookmark(self):
|
||||||
form_data = self.create_form_data({"unread": True})
|
form_data = self.create_form_data({"unread": True})
|
||||||
|
|
||||||
self.client.post(reverse("bookmarks:new"), form_data)
|
self.client.post(reverse("linkding:bookmarks.new"), form_data)
|
||||||
|
|
||||||
self.assertEqual(Bookmark.objects.count(), 1)
|
self.assertEqual(Bookmark.objects.count(), 1)
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
def test_should_create_new_shared_bookmark(self):
|
def test_should_create_new_shared_bookmark(self):
|
||||||
form_data = self.create_form_data({"shared": True})
|
form_data = self.create_form_data({"shared": True})
|
||||||
|
|
||||||
self.client.post(reverse("bookmarks:new"), form_data)
|
self.client.post(reverse("linkding:bookmarks.new"), form_data)
|
||||||
|
|
||||||
self.assertEqual(Bookmark.objects.count(), 1)
|
self.assertEqual(Bookmark.objects.count(), 1)
|
||||||
|
|
||||||
@@ -72,7 +72,9 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.assertTrue(bookmark.shared)
|
self.assertTrue(bookmark.shared)
|
||||||
|
|
||||||
def test_should_prefill_url_from_url_parameter(self):
|
def test_should_prefill_url_from_url_parameter(self):
|
||||||
response = self.client.get(reverse("bookmarks:new") + "?url=http://example.com")
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.new") + "?url=http://example.com"
|
||||||
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -83,7 +85,9 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_should_prefill_title_from_url_parameter(self):
|
def test_should_prefill_title_from_url_parameter(self):
|
||||||
response = self.client.get(reverse("bookmarks:new") + "?title=Example%20Title")
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.new") + "?title=Example%20Title"
|
||||||
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -95,7 +99,8 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_should_prefill_description_from_url_parameter(self):
|
def test_should_prefill_description_from_url_parameter(self):
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:new") + "?description=Example%20Site%20Description"
|
reverse("linkding:bookmarks.new")
|
||||||
|
+ "?description=Example%20Site%20Description"
|
||||||
)
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -107,7 +112,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_should_prefill_notes_from_url_parameter(self):
|
def test_should_prefill_notes_from_url_parameter(self):
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:new")
|
reverse("linkding:bookmarks.new")
|
||||||
+ "?notes=%2A%2AFind%2A%2A%20more%20info%20%5Bhere%5D%28http%3A%2F%2Fexample.com%29"
|
+ "?notes=%2A%2AFind%2A%2A%20more%20info%20%5Bhere%5D%28http%3A%2F%2Fexample.com%29"
|
||||||
)
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
@@ -129,7 +134,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_should_enable_auto_close_when_specified_in_url_parameter(self):
|
def test_should_enable_auto_close_when_specified_in_url_parameter(self):
|
||||||
response = self.client.get(reverse("bookmarks:new") + "?auto_close")
|
response = self.client.get(reverse("linkding:bookmarks.new") + "?auto_close")
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -139,7 +144,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_should_not_enable_auto_close_when_not_specified_in_url_parameter(self):
|
def test_should_not_enable_auto_close_when_not_specified_in_url_parameter(self):
|
||||||
response = self.client.get(reverse("bookmarks:new"))
|
response = self.client.get(reverse("linkding:bookmarks.new"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -149,30 +154,31 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
def test_should_redirect_to_index_view(self):
|
def test_should_redirect_to_index_view(self):
|
||||||
form_data = self.create_form_data()
|
form_data = self.create_form_data()
|
||||||
|
|
||||||
response = self.client.post(reverse("bookmarks:new"), form_data)
|
response = self.client.post(reverse("linkding:bookmarks.new"), form_data)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
def test_should_not_redirect_to_external_url(self):
|
def test_should_not_redirect_to_external_url(self):
|
||||||
form_data = self.create_form_data()
|
form_data = self.create_form_data()
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:new") + "?return_url=https://example.com", form_data
|
reverse("linkding:bookmarks.new") + "?return_url=https://example.com",
|
||||||
|
form_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
def test_auto_close_should_redirect_to_close_view(self):
|
def test_auto_close_should_redirect_to_close_view(self):
|
||||||
form_data = self.create_form_data({"auto_close": "true"})
|
form_data = self.create_form_data({"auto_close": "true"})
|
||||||
|
|
||||||
response = self.client.post(reverse("bookmarks:new"), form_data)
|
response = self.client.post(reverse("linkding:bookmarks.new"), form_data)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:close"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.close"))
|
||||||
|
|
||||||
def test_should_respect_share_profile_setting(self):
|
def test_should_respect_share_profile_setting(self):
|
||||||
self.user.profile.enable_sharing = False
|
self.user.profile.enable_sharing = False
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
response = self.client.get(reverse("bookmarks:new"))
|
response = self.client.get(reverse("linkding:bookmarks.new"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -189,7 +195,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
self.user.profile.enable_sharing = True
|
self.user.profile.enable_sharing = True
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
response = self.client.get(reverse("bookmarks:new"))
|
response = self.client.get(reverse("linkding:bookmarks.new"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -208,7 +214,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.user.profile.enable_sharing = True
|
self.user.profile.enable_sharing = True
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:new"))
|
response = self.client.get(reverse("linkding:bookmarks.new"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
"""
|
"""
|
||||||
@@ -222,7 +228,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.user.profile.enable_public_sharing = True
|
self.user.profile.enable_public_sharing = True
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:new"))
|
response = self.client.get(reverse("linkding:bookmarks.new"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
"""
|
"""
|
||||||
@@ -235,12 +241,14 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_should_hide_notes_if_there_are_no_notes(self):
|
def test_should_hide_notes_if_there_are_no_notes(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
response = self.client.get(reverse("bookmarks:edit", args=[bookmark.id]))
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
|
)
|
||||||
|
|
||||||
self.assertContains(response, '<details class="notes">', count=1)
|
self.assertContains(response, '<details class="notes">', count=1)
|
||||||
|
|
||||||
def test_should_not_check_unread_by_default(self):
|
def test_should_not_check_unread_by_default(self):
|
||||||
response = self.client.get(reverse("bookmarks:new"))
|
response = self.client.get(reverse("linkding:bookmarks.new"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -252,7 +260,7 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.user.profile.default_mark_unread = True
|
self.user.profile.default_mark_unread = True
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:new"))
|
response = self.client.get(reverse("linkding:bookmarks.new"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
|
@@ -75,7 +75,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=True, user=user4),
|
self.setup_bookmark(shared=True, user=user4),
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks)
|
self.assertVisibleBookmarks(response, visible_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
||||||
@@ -94,7 +94,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=True, user=user3),
|
self.setup_bookmark(shared=True, user=user3),
|
||||||
]
|
]
|
||||||
|
|
||||||
url = reverse("bookmarks:shared") + "?user=" + user1.username
|
url = reverse("linkding:bookmarks.shared") + "?user=" + user1.username
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks)
|
self.assertVisibleBookmarks(response, visible_bookmarks)
|
||||||
@@ -109,7 +109,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
)
|
)
|
||||||
invisible_bookmarks = self.setup_numbered_bookmarks(3, shared=True, user=user)
|
invisible_bookmarks = self.setup_numbered_bookmarks(3, shared=True, user=user)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared") + "?q=foo")
|
response = self.client.get(reverse("linkding:bookmarks.shared") + "?q=foo")
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks)
|
self.assertVisibleBookmarks(response, visible_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
||||||
@@ -125,7 +125,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
3, shared=True, user=user2, prefix="user2"
|
3, shared=True, user=user2, prefix="user2"
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks)
|
self.assertVisibleBookmarks(response, visible_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
self.assertInvisibleBookmarks(response, invisible_bookmarks)
|
||||||
@@ -159,7 +159,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=False, user=user3, tags=[invisible_tags[2]])
|
self.setup_bookmark(shared=False, user=user3, tags=[invisible_tags[2]])
|
||||||
self.setup_bookmark(shared=True, user=user4, tags=[invisible_tags[3]])
|
self.setup_bookmark(shared=True, user=user4, tags=[invisible_tags[3]])
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
self.assertVisibleTags(response, visible_tags)
|
self.assertVisibleTags(response, visible_tags)
|
||||||
self.assertInvisibleTags(response, invisible_tags)
|
self.assertInvisibleTags(response, invisible_tags)
|
||||||
@@ -181,7 +181,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=True, user=user2, tags=[invisible_tags[0]])
|
self.setup_bookmark(shared=True, user=user2, tags=[invisible_tags[0]])
|
||||||
self.setup_bookmark(shared=True, user=user3, tags=[invisible_tags[1]])
|
self.setup_bookmark(shared=True, user=user3, tags=[invisible_tags[1]])
|
||||||
|
|
||||||
url = reverse("bookmarks:shared") + "?user=" + user1.username
|
url = reverse("linkding:bookmarks.shared") + "?user=" + user1.username
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
|
|
||||||
self.assertVisibleTags(response, visible_tags)
|
self.assertVisibleTags(response, visible_tags)
|
||||||
@@ -217,7 +217,9 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=True, user=user2, tags=[invisible_tags[1]])
|
self.setup_bookmark(shared=True, user=user2, tags=[invisible_tags[1]])
|
||||||
self.setup_bookmark(shared=True, user=user3, tags=[invisible_tags[2]])
|
self.setup_bookmark(shared=True, user=user3, tags=[invisible_tags[2]])
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared") + "?q=searchvalue")
|
response = self.client.get(
|
||||||
|
reverse("linkding:bookmarks.shared") + "?q=searchvalue"
|
||||||
|
)
|
||||||
|
|
||||||
self.assertVisibleTags(response, visible_tags)
|
self.assertVisibleTags(response, visible_tags)
|
||||||
self.assertInvisibleTags(response, invisible_tags)
|
self.assertInvisibleTags(response, invisible_tags)
|
||||||
@@ -241,7 +243,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=True, user=user2, tags=[invisible_tags[0]])
|
self.setup_bookmark(shared=True, user=user2, tags=[invisible_tags[0]])
|
||||||
self.setup_bookmark(shared=True, user=user2, tags=[invisible_tags[1]])
|
self.setup_bookmark(shared=True, user=user2, tags=[invisible_tags[1]])
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
self.assertVisibleTags(response, visible_tags)
|
self.assertVisibleTags(response, visible_tags)
|
||||||
self.assertInvisibleTags(response, invisible_tags)
|
self.assertInvisibleTags(response, invisible_tags)
|
||||||
@@ -258,7 +260,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=False, user=self.setup_user(enable_sharing=True))
|
self.setup_bookmark(shared=False, user=self.setup_user(enable_sharing=True))
|
||||||
self.setup_bookmark(shared=True, user=self.setup_user(enable_sharing=False))
|
self.setup_bookmark(shared=True, user=self.setup_user(enable_sharing=False))
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
self.assertVisibleUserOptions(response, expected_visible_users)
|
self.assertVisibleUserOptions(response, expected_visible_users)
|
||||||
|
|
||||||
def test_should_list_only_users_with_publicly_shared_bookmarks_without_login(self):
|
def test_should_list_only_users_with_publicly_shared_bookmarks_without_login(self):
|
||||||
@@ -278,7 +280,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=True, user=self.setup_user(enable_sharing=True))
|
self.setup_bookmark(shared=True, user=self.setup_user(enable_sharing=True))
|
||||||
self.setup_bookmark(shared=True, user=self.setup_user(enable_sharing=True))
|
self.setup_bookmark(shared=True, user=self.setup_user(enable_sharing=True))
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
self.assertVisibleUserOptions(response, expected_visible_users)
|
self.assertVisibleUserOptions(response, expected_visible_users)
|
||||||
|
|
||||||
def test_should_list_bookmarks_and_tags_for_search_preferences(self):
|
def test_should_list_bookmarks_and_tags_for_search_preferences(self):
|
||||||
@@ -313,7 +315,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
unread_tags = self.get_tags_from_bookmarks(unread_bookmarks)
|
unread_tags = self.get_tags_from_bookmarks(unread_bookmarks)
|
||||||
read_tags = self.get_tags_from_bookmarks(read_bookmarks)
|
read_tags = self.get_tags_from_bookmarks(read_bookmarks)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
self.assertVisibleBookmarks(response, unread_bookmarks)
|
self.assertVisibleBookmarks(response, unread_bookmarks)
|
||||||
self.assertInvisibleBookmarks(response, read_bookmarks)
|
self.assertInvisibleBookmarks(response, read_bookmarks)
|
||||||
self.assertVisibleTags(response, unread_tags)
|
self.assertVisibleTags(response, unread_tags)
|
||||||
@@ -330,7 +332,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=True),
|
self.setup_bookmark(shared=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks, "_blank")
|
self.assertVisibleBookmarks(response, visible_bookmarks, "_blank")
|
||||||
|
|
||||||
@@ -347,7 +349,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.setup_bookmark(shared=True),
|
self.setup_bookmark(shared=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
self.assertVisibleBookmarks(response, visible_bookmarks, "_self")
|
self.assertVisibleBookmarks(response, visible_bookmarks, "_self")
|
||||||
|
|
||||||
@@ -358,8 +360,8 @@ class BookmarkSharedViewTestCase(
|
|||||||
user.profile.save()
|
user.profile.save()
|
||||||
|
|
||||||
bookmark = self.setup_bookmark(title="foo", shared=True, user=user)
|
bookmark = self.setup_bookmark(title="foo", shared=True, user=user)
|
||||||
edit_url = reverse("bookmarks:edit", args=[bookmark.id])
|
edit_url = reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
base_url = reverse("bookmarks:shared")
|
base_url = reverse("linkding:bookmarks.shared")
|
||||||
|
|
||||||
# without query params
|
# without query params
|
||||||
return_url = urllib.parse.quote(base_url)
|
return_url = urllib.parse.quote(base_url)
|
||||||
@@ -394,13 +396,13 @@ class BookmarkSharedViewTestCase(
|
|||||||
|
|
||||||
def test_apply_search_preferences(self):
|
def test_apply_search_preferences(self):
|
||||||
# no params
|
# no params
|
||||||
response = self.client.post(reverse("bookmarks:shared"))
|
response = self.client.post(reverse("linkding:bookmarks.shared"))
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(response.url, reverse("bookmarks:shared"))
|
self.assertEqual(response.url, reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
# some params
|
# some params
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:shared"),
|
reverse("linkding:bookmarks.shared"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -408,12 +410,12 @@ class BookmarkSharedViewTestCase(
|
|||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.url, reverse("bookmarks:shared") + "?q=foo&sort=title_asc"
|
response.url, reverse("linkding:bookmarks.shared") + "?q=foo&sort=title_asc"
|
||||||
)
|
)
|
||||||
|
|
||||||
# params with default value are removed
|
# params with default value are removed
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:shared"),
|
reverse("linkding:bookmarks.shared"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"user": "",
|
"user": "",
|
||||||
@@ -424,12 +426,12 @@ class BookmarkSharedViewTestCase(
|
|||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.url, reverse("bookmarks:shared") + "?q=foo&unread=yes"
|
response.url, reverse("linkding:bookmarks.shared") + "?q=foo&unread=yes"
|
||||||
)
|
)
|
||||||
|
|
||||||
# page is removed
|
# page is removed
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:shared"),
|
reverse("linkding:bookmarks.shared"),
|
||||||
{
|
{
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
"page": "2",
|
"page": "2",
|
||||||
@@ -438,7 +440,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.url, reverse("bookmarks:shared") + "?q=foo&sort=title_asc"
|
response.url, reverse("linkding:bookmarks.shared") + "?q=foo&sort=title_asc"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_save_search_preferences(self):
|
def test_save_search_preferences(self):
|
||||||
@@ -447,7 +449,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
|
|
||||||
# no params
|
# no params
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:shared"),
|
reverse("linkding:bookmarks.shared"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
},
|
},
|
||||||
@@ -464,7 +466,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
|
|
||||||
# with param
|
# with param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:shared"),
|
reverse("linkding:bookmarks.shared"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -482,7 +484,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
|
|
||||||
# add a param
|
# add a param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:shared"),
|
reverse("linkding:bookmarks.shared"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
"sort": BookmarkSearch.SORT_TITLE_ASC,
|
||||||
@@ -501,7 +503,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
|
|
||||||
# remove a param
|
# remove a param
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:shared"),
|
reverse("linkding:bookmarks.shared"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"unread": BookmarkSearch.FILTER_UNREAD_YES,
|
"unread": BookmarkSearch.FILTER_UNREAD_YES,
|
||||||
@@ -519,7 +521,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
|
|
||||||
# ignores non-preferences
|
# ignores non-preferences
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:shared"),
|
reverse("linkding:bookmarks.shared"),
|
||||||
{
|
{
|
||||||
"save": "",
|
"save": "",
|
||||||
"q": "foo",
|
"q": "foo",
|
||||||
@@ -539,7 +541,7 @@ class BookmarkSharedViewTestCase(
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_url_encode_bookmark_actions_url(self):
|
def test_url_encode_bookmark_actions_url(self):
|
||||||
url = reverse("bookmarks:shared") + "?q=%23foo"
|
url = reverse("linkding:bookmarks.shared") + "?q=%23foo"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
@@ -557,34 +559,34 @@ class BookmarkSharedViewTestCase(
|
|||||||
user.profile.save()
|
user.profile.save()
|
||||||
bookmark = self.setup_bookmark(description="alert('xss')", shared=True)
|
bookmark = self.setup_bookmark(description="alert('xss')", shared=True)
|
||||||
|
|
||||||
url = reverse("bookmarks:shared") + "?q=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.shared") + "?q=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
self.assertContains(response, bookmark.url)
|
self.assertContains(response, bookmark.url)
|
||||||
|
|
||||||
url = reverse("bookmarks:shared") + "?sort=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.shared") + "?sort=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:shared") + "?unread=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.shared") + "?unread=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:shared") + "?shared=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.shared") + "?shared=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:shared") + "?user=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.shared") + "?user=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
url = reverse("bookmarks:shared") + "?page=alert(%27xss%27)"
|
url = reverse("linkding:bookmarks.shared") + "?page=alert(%27xss%27)"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, "alert('xss')")
|
self.assertNotContains(response, "alert('xss')")
|
||||||
|
|
||||||
def test_turbo_frame_details_modal_renders_details_modal_update(self):
|
def test_turbo_frame_details_modal_renders_details_modal_update(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse("bookmarks:shared") + f"?bookmark_id={bookmark.id}"
|
url = reverse("linkding:bookmarks.shared") + f"?bookmark_id={bookmark.id}"
|
||||||
response = self.client.get(url, headers={"Turbo-Frame": "details-modal"})
|
response = self.client.get(url, headers={"Turbo-Frame": "details-modal"})
|
||||||
|
|
||||||
self.assertEqual(200, response.status_code)
|
self.assertEqual(200, response.status_code)
|
||||||
@@ -595,9 +597,9 @@ class BookmarkSharedViewTestCase(
|
|||||||
self.assertIsNone(soup.select_one("#tag-cloud-container"))
|
self.assertIsNone(soup.select_one("#tag-cloud-container"))
|
||||||
|
|
||||||
def test_includes_public_shared_rss_feed(self):
|
def test_includes_public_shared_rss_feed(self):
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
soup = self.make_soup(response.content.decode())
|
soup = self.make_soup(response.content.decode())
|
||||||
|
|
||||||
feed = soup.select_one('head link[type="application/rss+xml"]')
|
feed = soup.select_one('head link[type="application/rss+xml"]')
|
||||||
self.assertIsNotNone(feed)
|
self.assertIsNotNone(feed)
|
||||||
self.assertEqual(feed.attrs["href"], reverse("bookmarks:feeds.public_shared"))
|
self.assertEqual(feed.attrs["href"], reverse("linkding:feeds.public_shared"))
|
||||||
|
@@ -32,7 +32,7 @@ class BookmarkSharedViewPerformanceTestCase(
|
|||||||
# capture number of queries
|
# capture number of queries
|
||||||
context = CaptureQueriesContext(self.get_connection())
|
context = CaptureQueriesContext(self.get_connection())
|
||||||
with context:
|
with context:
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
html = response.content.decode("utf-8")
|
html = response.content.decode("utf-8")
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
list_items = soup.select("li[ld-bookmark-item]")
|
list_items = soup.select("li[ld-bookmark-item]")
|
||||||
@@ -48,7 +48,7 @@ class BookmarkSharedViewPerformanceTestCase(
|
|||||||
|
|
||||||
# assert num queries doesn't increase
|
# assert num queries doesn't increase
|
||||||
with self.assertNumQueries(number_of_queries):
|
with self.assertNumQueries(number_of_queries):
|
||||||
response = self.client.get(reverse("bookmarks:shared"))
|
response = self.client.get(reverse("linkding:bookmarks.shared"))
|
||||||
html = response.content.decode("utf-8")
|
html = response.content.decode("utf-8")
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
list_items = soup.select("li[ld-bookmark-item]")
|
list_items = soup.select("li[ld-bookmark-item]")
|
||||||
|
@@ -89,7 +89,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmarks = self.setup_numbered_bookmarks(5)
|
bookmarks = self.setup_numbered_bookmarks(5)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
reverse("linkding:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
reverse("linkding:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark.save()
|
bookmark.save()
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
reverse("linkding:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
||||||
)
|
)
|
||||||
self.assertIsNone(response.data["results"][0]["website_title"])
|
self.assertIsNone(response.data["results"][0]["website_title"])
|
||||||
self.assertIsNone(response.data["results"][0]["website_description"])
|
self.assertIsNone(response.data["results"][0]["website_description"])
|
||||||
@@ -127,7 +127,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_numbered_bookmarks(5, archived=True)
|
self.setup_numbered_bookmarks(5, archived=True)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
reverse("linkding:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_numbered_bookmarks(5)
|
self.setup_numbered_bookmarks(5)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list") + "?q=" + search_value,
|
reverse("linkding:bookmark-list") + "?q=" + search_value,
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
||||||
@@ -150,7 +150,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
# Filter off
|
# Filter off
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
reverse("linkding:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(
|
self.assertBookmarkListEqual(
|
||||||
response.data["results"], unread_bookmarks + read_bookmarks
|
response.data["results"], unread_bookmarks + read_bookmarks
|
||||||
@@ -158,14 +158,14 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
# Filter shared
|
# Filter shared
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list") + "?unread=yes",
|
reverse("linkding:bookmark-list") + "?unread=yes",
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], unread_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], unread_bookmarks)
|
||||||
|
|
||||||
# Filter unshared
|
# Filter unshared
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list") + "?unread=no",
|
reverse("linkding:bookmark-list") + "?unread=no",
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], read_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], read_bookmarks)
|
||||||
@@ -177,7 +177,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
# Filter off
|
# Filter off
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
reverse("linkding:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(
|
self.assertBookmarkListEqual(
|
||||||
response.data["results"], unshared_bookmarks + shared_bookmarks
|
response.data["results"], unshared_bookmarks + shared_bookmarks
|
||||||
@@ -185,14 +185,14 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
# Filter shared
|
# Filter shared
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list") + "?shared=yes",
|
reverse("linkding:bookmark-list") + "?shared=yes",
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], shared_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], shared_bookmarks)
|
||||||
|
|
||||||
# Filter unshared
|
# Filter unshared
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list") + "?shared=no",
|
reverse("linkding:bookmark-list") + "?shared=no",
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], unshared_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], unshared_bookmarks)
|
||||||
@@ -203,7 +203,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmarks.reverse()
|
bookmarks.reverse()
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-list") + "?sort=title_desc",
|
reverse("linkding:bookmark-list") + "?sort=title_desc",
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
||||||
@@ -214,7 +214,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
archived_bookmarks = self.setup_numbered_bookmarks(5, archived=True)
|
archived_bookmarks = self.setup_numbered_bookmarks(5, archived=True)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-archived"),
|
reverse("linkding:bookmark-archived"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], archived_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], archived_bookmarks)
|
||||||
@@ -231,7 +231,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-archived"),
|
reverse("linkding:bookmark-archived"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], archived_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], archived_bookmarks)
|
||||||
@@ -245,7 +245,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_numbered_bookmarks(5, archived=True)
|
self.setup_numbered_bookmarks(5, archived=True)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-archived") + "?q=" + search_value,
|
reverse("linkding:bookmark-archived") + "?q=" + search_value,
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], archived_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], archived_bookmarks)
|
||||||
@@ -256,7 +256,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmarks.reverse()
|
bookmarks.reverse()
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-archived") + "?sort=title_desc",
|
reverse("linkding:bookmark-archived") + "?sort=title_desc",
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
||||||
@@ -280,7 +280,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(shared=True, user=user4)
|
self.setup_bookmark(shared=True, user=user4)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-shared"),
|
reverse("linkding:bookmark-shared"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], shared_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], shared_bookmarks)
|
||||||
@@ -300,7 +300,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-shared"),
|
reverse("linkding:bookmark-shared"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], shared_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], shared_bookmarks)
|
||||||
@@ -317,7 +317,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(shared=True, user=user2)
|
self.setup_bookmark(shared=True, user=user2)
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-shared"),
|
reverse("linkding:bookmark-shared"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], shared_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], shared_bookmarks)
|
||||||
@@ -339,7 +339,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(shared=True, user=user3),
|
self.setup_bookmark(shared=True, user=user3),
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-shared") + "?q=searchvalue",
|
reverse("linkding:bookmark-shared") + "?q=searchvalue",
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], expected_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], expected_bookmarks)
|
||||||
@@ -352,7 +352,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(shared=True, user=user_search_user),
|
self.setup_bookmark(shared=True, user=user_search_user),
|
||||||
]
|
]
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-shared") + "?user=" + user_search_user.username,
|
reverse("linkding:bookmark-shared") + "?user=" + user_search_user.username,
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], expected_bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], expected_bookmarks)
|
||||||
@@ -371,7 +371,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-shared")
|
reverse("linkding:bookmark-shared")
|
||||||
+ "?q=searchvalue&user="
|
+ "?q=searchvalue&user="
|
||||||
+ combined_search_user.username,
|
+ combined_search_user.username,
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
@@ -385,7 +385,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmarks.reverse()
|
bookmarks.reverse()
|
||||||
|
|
||||||
response = self.get(
|
response = self.get(
|
||||||
reverse("bookmarks:bookmark-shared") + "?sort=title_desc",
|
reverse("linkding:bookmark-shared") + "?sort=title_desc",
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
self.assertBookmarkListEqual(response.data["results"], bookmarks)
|
||||||
@@ -403,7 +403,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
"shared": False,
|
"shared": False,
|
||||||
"tag_names": ["tag1", "tag2"],
|
"tag_names": ["tag1", "tag2"],
|
||||||
}
|
}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertEqual(bookmark.url, data["url"])
|
self.assertEqual(bookmark.url, data["url"])
|
||||||
self.assertEqual(bookmark.title, data["title"])
|
self.assertEqual(bookmark.title, data["title"])
|
||||||
@@ -427,7 +427,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
description="Website description",
|
description="Website description",
|
||||||
preview_image=None,
|
preview_image=None,
|
||||||
)
|
)
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertEqual(bookmark.title, "Website title")
|
self.assertEqual(bookmark.title, "Website title")
|
||||||
self.assertEqual(bookmark.description, "Website description")
|
self.assertEqual(bookmark.description, "Website description")
|
||||||
@@ -446,7 +446,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
preview_image=None,
|
preview_image=None,
|
||||||
)
|
)
|
||||||
self.post(
|
self.post(
|
||||||
reverse("bookmarks:bookmark-list") + "?disable_scraping",
|
reverse("linkding:bookmark-list") + "?disable_scraping",
|
||||||
data,
|
data,
|
||||||
status.HTTP_201_CREATED,
|
status.HTTP_201_CREATED,
|
||||||
)
|
)
|
||||||
@@ -463,7 +463,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
wraps=bookmarks.services.bookmarks.create_bookmark,
|
wraps=bookmarks.services.bookmarks.create_bookmark,
|
||||||
) as mock_create_bookmark:
|
) as mock_create_bookmark:
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
mock_create_bookmark.assert_called_with(
|
mock_create_bookmark.assert_called_with(
|
||||||
ANY, "", self.get_or_create_test_user(), disable_html_snapshot=False
|
ANY, "", self.get_or_create_test_user(), disable_html_snapshot=False
|
||||||
@@ -479,7 +479,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
) as mock_create_bookmark:
|
) as mock_create_bookmark:
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
self.post(
|
self.post(
|
||||||
reverse("bookmarks:bookmark-list") + "?disable_html_snapshot",
|
reverse("linkding:bookmark-list") + "?disable_html_snapshot",
|
||||||
data,
|
data,
|
||||||
status.HTTP_201_CREATED,
|
status.HTTP_201_CREATED,
|
||||||
)
|
)
|
||||||
@@ -502,7 +502,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
"is_archived": True,
|
"is_archived": True,
|
||||||
"tag_names": ["tag1", "tag2"],
|
"tag_names": ["tag1", "tag2"],
|
||||||
}
|
}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertEqual(bookmark.id, original_bookmark.id)
|
self.assertEqual(bookmark.id, original_bookmark.id)
|
||||||
self.assertEqual(bookmark.url, data["url"])
|
self.assertEqual(bookmark.url, data["url"])
|
||||||
@@ -526,7 +526,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
"description": "Test description",
|
"description": "Test description",
|
||||||
"tag_names": ["tag 1", "tag 2"],
|
"tag_names": ["tag 1", "tag 2"],
|
||||||
}
|
}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
tag_names = [tag.name for tag in bookmark.tags.all()]
|
tag_names = [tag.name for tag in bookmark.tags.all()]
|
||||||
self.assertListEqual(tag_names, ["tag-1", "tag-2"])
|
self.assertListEqual(tag_names, ["tag-1", "tag-2"])
|
||||||
@@ -536,7 +536,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
self.post(
|
self.post(
|
||||||
reverse("bookmarks:bookmark-list") + "?disable_scraping",
|
reverse("linkding:bookmark-list") + "?disable_scraping",
|
||||||
data,
|
data,
|
||||||
status.HTTP_201_CREATED,
|
status.HTTP_201_CREATED,
|
||||||
)
|
)
|
||||||
@@ -561,7 +561,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
"is_archived": True,
|
"is_archived": True,
|
||||||
"tag_names": ["tag1", "tag2"],
|
"tag_names": ["tag1", "tag2"],
|
||||||
}
|
}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertEqual(bookmark.url, data["url"])
|
self.assertEqual(bookmark.url, data["url"])
|
||||||
self.assertEqual(bookmark.title, data["title"])
|
self.assertEqual(bookmark.title, data["title"])
|
||||||
@@ -575,7 +575,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertFalse(bookmark.is_archived)
|
self.assertFalse(bookmark.is_archived)
|
||||||
|
|
||||||
@@ -583,7 +583,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
data = {"url": "https://example.com/", "unread": True}
|
data = {"url": "https://example.com/", "unread": True}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertTrue(bookmark.unread)
|
self.assertTrue(bookmark.unread)
|
||||||
|
|
||||||
@@ -591,7 +591,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertFalse(bookmark.unread)
|
self.assertFalse(bookmark.unread)
|
||||||
|
|
||||||
@@ -599,7 +599,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
data = {"url": "https://example.com/", "shared": True}
|
data = {"url": "https://example.com/", "shared": True}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertTrue(bookmark.shared)
|
self.assertTrue(bookmark.shared)
|
||||||
|
|
||||||
@@ -607,7 +607,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertFalse(bookmark.shared)
|
self.assertFalse(bookmark.shared)
|
||||||
|
|
||||||
@@ -621,7 +621,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
data = {"url": "https://example.com/", "tag_names": [tag1.name]}
|
data = {"url": "https://example.com/", "tag_names": [tag1.name]}
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
bookmark = Bookmark.objects.get(url=data["url"])
|
bookmark = Bookmark.objects.get(url=data["url"])
|
||||||
self.assertCountEqual(bookmark.tags.all(), [tag1, tag2])
|
self.assertCountEqual(bookmark.tags.all(), [tag1, tag2])
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
self.assertBookmarkListEqual([response.data], [bookmark])
|
self.assertBookmarkListEqual([response.data], [bookmark])
|
||||||
|
|
||||||
@@ -641,7 +641,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
tags=[tag1],
|
tags=[tag1],
|
||||||
)
|
)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
self.assertBookmarkListEqual([response.data], [bookmark])
|
self.assertBookmarkListEqual([response.data], [bookmark])
|
||||||
|
|
||||||
@@ -655,7 +655,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.data["web_archive_snapshot_url"],
|
response.data["web_archive_snapshot_url"],
|
||||||
@@ -667,7 +667,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
data = {"url": "https://example.com/updated"}
|
data = {"url": "https://example.com/updated"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertEqual(updated_bookmark.url, data["url"])
|
self.assertEqual(updated_bookmark.url, data["url"])
|
||||||
@@ -682,7 +682,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
"website_title": "test",
|
"website_title": "test",
|
||||||
"website_description": "test",
|
"website_description": "test",
|
||||||
}
|
}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertEqual(data["url"], updated_bookmark.url)
|
self.assertEqual(data["url"], updated_bookmark.url)
|
||||||
@@ -699,7 +699,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
data = {"title": "https://example.com/"}
|
data = {"title": "https://example.com/"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_400_BAD_REQUEST)
|
self.put(url, data, expected_status_code=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
def test_update_bookmark_with_minimal_payload_does_not_modify_bookmark(self):
|
def test_update_bookmark_with_minimal_payload_does_not_modify_bookmark(self):
|
||||||
@@ -709,7 +709,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertEqual(updated_bookmark.url, data["url"])
|
self.assertEqual(updated_bookmark.url, data["url"])
|
||||||
@@ -726,7 +726,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
data = {"url": "https://example.com/", "unread": True}
|
data = {"url": "https://example.com/", "unread": True}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertEqual(updated_bookmark.unread, True)
|
self.assertEqual(updated_bookmark.unread, True)
|
||||||
@@ -736,7 +736,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
data = {"url": "https://example.com/", "shared": True}
|
data = {"url": "https://example.com/", "shared": True}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertEqual(updated_bookmark.shared, True)
|
self.assertEqual(updated_bookmark.shared, True)
|
||||||
@@ -752,7 +752,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
data = {"url": "https://example.com/", "tag_names": [tag1.name]}
|
data = {"url": "https://example.com/", "tag_names": [tag1.name]}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertCountEqual(updated_bookmark.tags.all(), [tag1, tag2])
|
self.assertCountEqual(updated_bookmark.tags.all(), [tag1, tag2])
|
||||||
@@ -767,17 +767,17 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
# if the URL isn't modified it's not a duplicate
|
# if the URL isn't modified it's not a duplicate
|
||||||
data = {"url": edited_bookmark.url}
|
data = {"url": edited_bookmark.url}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[edited_bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[edited_bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
|
|
||||||
# if the URL is already bookmarked by another user, it's not a duplicate
|
# if the URL is already bookmarked by another user, it's not a duplicate
|
||||||
data = {"url": other_user_bookmark.url}
|
data = {"url": other_user_bookmark.url}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[edited_bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[edited_bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
self.put(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
|
|
||||||
# if the URL is already bookmarked by the same user, it's a duplicate
|
# if the URL is already bookmarked by the same user, it's a duplicate
|
||||||
data = {"url": existing_bookmark.url}
|
data = {"url": existing_bookmark.url}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[edited_bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[edited_bookmark.id])
|
||||||
self.put(url, data, expected_status_code=status.HTTP_400_BAD_REQUEST)
|
self.put(url, data, expected_status_code=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
def test_patch_bookmark(self):
|
def test_patch_bookmark(self):
|
||||||
@@ -785,55 +785,55 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
data = {"url": "https://example.com"}
|
data = {"url": "https://example.com"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertEqual(bookmark.url, data["url"])
|
self.assertEqual(bookmark.url, data["url"])
|
||||||
|
|
||||||
data = {"title": "Updated title"}
|
data = {"title": "Updated title"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertEqual(bookmark.title, data["title"])
|
self.assertEqual(bookmark.title, data["title"])
|
||||||
|
|
||||||
data = {"description": "Updated description"}
|
data = {"description": "Updated description"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertEqual(bookmark.description, data["description"])
|
self.assertEqual(bookmark.description, data["description"])
|
||||||
|
|
||||||
data = {"notes": "Updated notes"}
|
data = {"notes": "Updated notes"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertEqual(bookmark.notes, data["notes"])
|
self.assertEqual(bookmark.notes, data["notes"])
|
||||||
|
|
||||||
data = {"unread": True}
|
data = {"unread": True}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertTrue(bookmark.unread)
|
self.assertTrue(bookmark.unread)
|
||||||
|
|
||||||
data = {"unread": False}
|
data = {"unread": False}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertFalse(bookmark.unread)
|
self.assertFalse(bookmark.unread)
|
||||||
|
|
||||||
data = {"shared": True}
|
data = {"shared": True}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertTrue(bookmark.shared)
|
self.assertTrue(bookmark.shared)
|
||||||
|
|
||||||
data = {"shared": False}
|
data = {"shared": False}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
self.assertFalse(bookmark.shared)
|
self.assertFalse(bookmark.shared)
|
||||||
|
|
||||||
data = {"tag_names": ["updated-tag-1", "updated-tag-2"]}
|
data = {"tag_names": ["updated-tag-1", "updated-tag-2"]}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
bookmark.refresh_from_db()
|
bookmark.refresh_from_db()
|
||||||
tag_names = [tag.name for tag in bookmark.tags.all()]
|
tag_names = [tag.name for tag in bookmark.tags.all()]
|
||||||
@@ -848,7 +848,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
"website_title": "test",
|
"website_title": "test",
|
||||||
"website_description": "test",
|
"website_description": "test",
|
||||||
}
|
}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
@@ -865,7 +865,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
is_archived=True, unread=True, shared=True, tags=[self.setup_tag()]
|
is_archived=True, unread=True, shared=True, tags=[self.setup_tag()]
|
||||||
)
|
)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, {}, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, {}, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertEqual(updated_bookmark.url, bookmark.url)
|
self.assertEqual(updated_bookmark.url, bookmark.url)
|
||||||
@@ -888,7 +888,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
data = {"tag_names": [tag1.name]}
|
data = {"tag_names": [tag1.name]}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
self.patch(url, data, expected_status_code=status.HTTP_200_OK)
|
||||||
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
updated_bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertCountEqual(updated_bookmark.tags.all(), [tag1, tag2])
|
self.assertCountEqual(updated_bookmark.tags.all(), [tag1, tag2])
|
||||||
@@ -897,7 +897,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
self.delete(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
self.delete(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
||||||
self.assertEqual(len(Bookmark.objects.filter(id=bookmark.id)), 0)
|
self.assertEqual(len(Bookmark.objects.filter(id=bookmark.id)), 0)
|
||||||
|
|
||||||
@@ -905,7 +905,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-archive", args=[bookmark.id])
|
url = reverse("linkding:bookmark-archive", args=[bookmark.id])
|
||||||
self.post(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
self.post(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
||||||
bookmark = Bookmark.objects.get(id=bookmark.id)
|
bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertTrue(bookmark.is_archived)
|
self.assertTrue(bookmark.is_archived)
|
||||||
@@ -914,7 +914,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.authenticate()
|
self.authenticate()
|
||||||
bookmark = self.setup_bookmark(is_archived=True)
|
bookmark = self.setup_bookmark(is_archived=True)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-unarchive", args=[bookmark.id])
|
url = reverse("linkding:bookmark-unarchive", args=[bookmark.id])
|
||||||
self.post(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
self.post(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
||||||
bookmark = Bookmark.objects.get(id=bookmark.id)
|
bookmark = Bookmark.objects.get(id=bookmark.id)
|
||||||
self.assertFalse(bookmark.is_archived)
|
self.assertFalse(bookmark.is_archived)
|
||||||
@@ -922,7 +922,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
def test_check_returns_no_bookmark_if_url_is_not_bookmarked(self):
|
def test_check_returns_no_bookmark_if_url_is_not_bookmarked(self):
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-check")
|
url = reverse("linkding:bookmark-check")
|
||||||
check_url = urllib.parse.quote_plus("https://example.com")
|
check_url = urllib.parse.quote_plus("https://example.com")
|
||||||
response = self.get(
|
response = self.get(
|
||||||
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
||||||
@@ -945,7 +945,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
mock_load_website_metadata.return_value = expected_metadata
|
mock_load_website_metadata.return_value = expected_metadata
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-check")
|
url = reverse("linkding:bookmark-check")
|
||||||
check_url = urllib.parse.quote_plus("https://example.com")
|
check_url = urllib.parse.quote_plus("https://example.com")
|
||||||
response = self.get(
|
response = self.get(
|
||||||
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
||||||
@@ -969,7 +969,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
preview_image_file="preview.png",
|
preview_image_file="preview.png",
|
||||||
)
|
)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-check")
|
url = reverse("linkding:bookmark-check")
|
||||||
check_url = urllib.parse.quote_plus("https://example.com")
|
check_url = urllib.parse.quote_plus("https://example.com")
|
||||||
response = self.get(
|
response = self.get(
|
||||||
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
||||||
@@ -1006,7 +1006,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
mock_load_website_metadata.return_value = expected_metadata
|
mock_load_website_metadata.return_value = expected_metadata
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-check")
|
url = reverse("linkding:bookmark-check")
|
||||||
check_url = urllib.parse.quote_plus("https://example.com")
|
check_url = urllib.parse.quote_plus("https://example.com")
|
||||||
response = self.get(
|
response = self.get(
|
||||||
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
||||||
@@ -1022,7 +1022,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
def test_check_returns_no_auto_tags_if_none_configured(self):
|
def test_check_returns_no_auto_tags_if_none_configured(self):
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-check")
|
url = reverse("linkding:bookmark-check")
|
||||||
check_url = urllib.parse.quote_plus("https://example.com")
|
check_url = urllib.parse.quote_plus("https://example.com")
|
||||||
response = self.get(
|
response = self.get(
|
||||||
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
||||||
@@ -1038,7 +1038,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
profile.auto_tagging_rules = "example.com tag1 tag2"
|
profile.auto_tagging_rules = "example.com tag1 tag2"
|
||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-check")
|
url = reverse("linkding:bookmark-check")
|
||||||
check_url = urllib.parse.quote_plus("https://example.com")
|
check_url = urllib.parse.quote_plus("https://example.com")
|
||||||
response = self.get(
|
response = self.get(
|
||||||
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
||||||
@@ -1059,23 +1059,23 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
inaccessible_shared_bookmark = self.setup_bookmark(user=other_user, shared=True)
|
inaccessible_shared_bookmark = self.setup_bookmark(user=other_user, shared=True)
|
||||||
self.setup_bookmark(user=other_user, is_archived=True)
|
self.setup_bookmark(user=other_user, is_archived=True)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-list")
|
url = reverse("linkding:bookmark-list")
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
self.assertEqual(len(response.data["results"]), 1)
|
self.assertEqual(len(response.data["results"]), 1)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-archived")
|
url = reverse("linkding:bookmark-archived")
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
self.assertEqual(len(response.data["results"]), 1)
|
self.assertEqual(len(response.data["results"]), 1)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[inaccessible_bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[inaccessible_bookmark.id])
|
||||||
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark-detail", args=[inaccessible_shared_bookmark.id]
|
"linkding:bookmark-detail", args=[inaccessible_shared_bookmark.id]
|
||||||
)
|
)
|
||||||
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.get(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[inaccessible_bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[inaccessible_bookmark.id])
|
||||||
self.put(
|
self.put(
|
||||||
url,
|
url,
|
||||||
{url: "https://example.com/"},
|
{url: "https://example.com/"},
|
||||||
@@ -1084,7 +1084,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
self.patch(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.patch(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark-detail", args=[inaccessible_shared_bookmark.id]
|
"linkding:bookmark-detail", args=[inaccessible_shared_bookmark.id]
|
||||||
)
|
)
|
||||||
self.put(
|
self.put(
|
||||||
url,
|
url,
|
||||||
@@ -1093,31 +1093,31 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
self.patch(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.patch(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[inaccessible_bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[inaccessible_bookmark.id])
|
||||||
self.delete(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.delete(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark-detail", args=[inaccessible_shared_bookmark.id]
|
"linkding:bookmark-detail", args=[inaccessible_shared_bookmark.id]
|
||||||
)
|
)
|
||||||
self.delete(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.delete(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-archive", args=[inaccessible_bookmark.id])
|
url = reverse("linkding:bookmark-archive", args=[inaccessible_bookmark.id])
|
||||||
self.post(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.post(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark-archive", args=[inaccessible_shared_bookmark.id]
|
"linkding:bookmark-archive", args=[inaccessible_shared_bookmark.id]
|
||||||
)
|
)
|
||||||
self.post(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.post(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-unarchive", args=[inaccessible_bookmark.id])
|
url = reverse("linkding:bookmark-unarchive", args=[inaccessible_bookmark.id])
|
||||||
self.post(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.post(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse(
|
url = reverse(
|
||||||
"bookmarks:bookmark-unarchive", args=[inaccessible_shared_bookmark.id]
|
"linkding:bookmark-unarchive", args=[inaccessible_shared_bookmark.id]
|
||||||
)
|
)
|
||||||
self.post(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.post(url, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
url = reverse("bookmarks:bookmark-check")
|
url = reverse("linkding:bookmark-check")
|
||||||
check_url = urllib.parse.quote_plus(inaccessible_bookmark.url)
|
check_url = urllib.parse.quote_plus(inaccessible_bookmark.url)
|
||||||
response = self.get(
|
response = self.get(
|
||||||
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK
|
||||||
@@ -1153,7 +1153,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
# default profile
|
# default profile
|
||||||
profile = self.user.profile
|
profile = self.user.profile
|
||||||
url = reverse("bookmarks:user-profile")
|
url = reverse("linkding:user-profile")
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
|
|
||||||
self.assertUserProfile(response, profile)
|
self.assertUserProfile(response, profile)
|
||||||
@@ -1176,7 +1176,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
}
|
}
|
||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
url = reverse("bookmarks:user-profile")
|
url = reverse("linkding:user-profile")
|
||||||
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
response = self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
|
|
||||||
self.assertUserProfile(response, profile)
|
self.assertUserProfile(response, profile)
|
||||||
@@ -1194,7 +1194,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:bookmark-singlefile"),
|
reverse("linkding:bookmark-singlefile"),
|
||||||
self.create_singlefile_upload_body(),
|
self.create_singlefile_upload_body(),
|
||||||
format="multipart",
|
format="multipart",
|
||||||
expected_status_code=status.HTTP_201_CREATED,
|
expected_status_code=status.HTTP_201_CREATED,
|
||||||
@@ -1211,7 +1211,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:bookmark-singlefile"),
|
reverse("linkding:bookmark-singlefile"),
|
||||||
self.create_singlefile_upload_body(),
|
self.create_singlefile_upload_body(),
|
||||||
format="multipart",
|
format="multipart",
|
||||||
expected_status_code=status.HTTP_201_CREATED,
|
expected_status_code=status.HTTP_201_CREATED,
|
||||||
@@ -1232,7 +1232,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:bookmark-singlefile"),
|
reverse("linkding:bookmark-singlefile"),
|
||||||
self.create_singlefile_upload_body(),
|
self.create_singlefile_upload_body(),
|
||||||
format="multipart",
|
format="multipart",
|
||||||
expected_status_code=status.HTTP_201_CREATED,
|
expected_status_code=status.HTTP_201_CREATED,
|
||||||
@@ -1248,7 +1248,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
) as mock_create_bookmark:
|
) as mock_create_bookmark:
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:bookmark-singlefile"),
|
reverse("linkding:bookmark-singlefile"),
|
||||||
self.create_singlefile_upload_body(),
|
self.create_singlefile_upload_body(),
|
||||||
format="multipart",
|
format="multipart",
|
||||||
expected_status_code=status.HTTP_201_CREATED,
|
expected_status_code=status.HTTP_201_CREATED,
|
||||||
@@ -1267,7 +1267,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
file = io.BytesIO(file_content)
|
file = io.BytesIO(file_content)
|
||||||
file.name = "snapshot.html"
|
file.name = "snapshot.html"
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:bookmark-singlefile"),
|
reverse("linkding:bookmark-singlefile"),
|
||||||
{"file": file},
|
{"file": file},
|
||||||
format="multipart",
|
format="multipart",
|
||||||
expected_status_code=status.HTTP_400_BAD_REQUEST,
|
expected_status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
@@ -1278,7 +1278,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
# Missing 'file'
|
# Missing 'file'
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:bookmark-singlefile"),
|
reverse("linkding:bookmark-singlefile"),
|
||||||
{"url": "https://example.com"},
|
{"url": "https://example.com"},
|
||||||
format="multipart",
|
format="multipart",
|
||||||
expected_status_code=status.HTTP_400_BAD_REQUEST,
|
expected_status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
@@ -1291,7 +1291,7 @@ class BookmarksApiTestCase(LinkdingApiTestCase, BookmarkFactoryMixin):
|
|||||||
def test_singlefile_upload_disabled(self):
|
def test_singlefile_upload_disabled(self):
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:bookmark-singlefile"),
|
reverse("linkding:bookmark-singlefile"),
|
||||||
self.create_singlefile_upload_body(),
|
self.create_singlefile_upload_body(),
|
||||||
format="multipart",
|
format="multipart",
|
||||||
expected_status_code=status.HTTP_403_FORBIDDEN,
|
expected_status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
@@ -33,7 +33,7 @@ class BookmarksApiPerformanceTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
context = CaptureQueriesContext(self.get_connection())
|
context = CaptureQueriesContext(self.get_connection())
|
||||||
with context:
|
with context:
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-list"),
|
reverse("linkding:bookmark-list"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ class BookmarksApiPerformanceTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
context = CaptureQueriesContext(self.get_connection())
|
context = CaptureQueriesContext(self.get_connection())
|
||||||
with context:
|
with context:
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-archived"),
|
reverse("linkding:bookmark-archived"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ class BookmarksApiPerformanceTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
context = CaptureQueriesContext(self.get_connection())
|
context = CaptureQueriesContext(self.get_connection())
|
||||||
with context:
|
with context:
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-shared"),
|
reverse("linkding:bookmark-shared"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -16,36 +16,36 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
|
|
||||||
def test_list_bookmarks_requires_authentication(self):
|
def test_list_bookmarks_requires_authentication(self):
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-list"),
|
reverse("linkding:bookmark-list"),
|
||||||
expected_status_code=status.HTTP_401_UNAUTHORIZED,
|
expected_status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
reverse("linkding:bookmark-list"), expected_status_code=status.HTTP_200_OK
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_list_archived_bookmarks_requires_authentication(self):
|
def test_list_archived_bookmarks_requires_authentication(self):
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-archived"),
|
reverse("linkding:bookmark-archived"),
|
||||||
expected_status_code=status.HTTP_401_UNAUTHORIZED,
|
expected_status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-archived"),
|
reverse("linkding:bookmark-archived"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_list_shared_bookmarks_does_not_require_authentication(self):
|
def test_list_shared_bookmarks_does_not_require_authentication(self):
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-shared"),
|
reverse("linkding:bookmark-shared"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
self.get(
|
self.get(
|
||||||
reverse("bookmarks:bookmark-shared"),
|
reverse("linkding:bookmark-shared"),
|
||||||
expected_status_code=status.HTTP_200_OK,
|
expected_status_code=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -61,16 +61,14 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
"tag_names": ["tag1", "tag2"],
|
"tag_names": ["tag1", "tag2"],
|
||||||
}
|
}
|
||||||
|
|
||||||
self.post(
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_401_UNAUTHORIZED)
|
||||||
reverse("bookmarks:bookmark-list"), data, status.HTTP_401_UNAUTHORIZED
|
|
||||||
)
|
|
||||||
|
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
self.post(reverse("bookmarks:bookmark-list"), data, status.HTTP_201_CREATED)
|
self.post(reverse("linkding:bookmark-list"), data, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
def test_get_bookmark_requires_authentication(self):
|
def test_get_bookmark_requires_authentication(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
|
|
||||||
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
@@ -80,7 +78,7 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
def test_update_bookmark_requires_authentication(self):
|
def test_update_bookmark_requires_authentication(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
|
|
||||||
self.put(url, data, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.put(url, data, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
@@ -93,14 +91,14 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
other_user = self.setup_user()
|
other_user = self.setup_user()
|
||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
data = {"url": "https://example.com/"}
|
data = {"url": "https://example.com/"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
|
|
||||||
self.put(url, data, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.put(url, data, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
def test_patch_bookmark_requires_authentication(self):
|
def test_patch_bookmark_requires_authentication(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
data = {"url": "https://example.com"}
|
data = {"url": "https://example.com"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
|
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.patch(url, data, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
@@ -113,13 +111,13 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
other_user = self.setup_user()
|
other_user = self.setup_user()
|
||||||
bookmark = self.setup_bookmark(user=other_user)
|
bookmark = self.setup_bookmark(user=other_user)
|
||||||
data = {"url": "https://example.com"}
|
data = {"url": "https://example.com"}
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
|
|
||||||
self.patch(url, data, expected_status_code=status.HTTP_404_NOT_FOUND)
|
self.patch(url, data, expected_status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
def test_delete_bookmark_requires_authentication(self):
|
def test_delete_bookmark_requires_authentication(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse("bookmarks:bookmark-detail", args=[bookmark.id])
|
url = reverse("linkding:bookmark-detail", args=[bookmark.id])
|
||||||
|
|
||||||
self.delete(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.delete(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
@@ -128,7 +126,7 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
|
|
||||||
def test_archive_requires_authentication(self):
|
def test_archive_requires_authentication(self):
|
||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
url = reverse("bookmarks:bookmark-archive", args=[bookmark.id])
|
url = reverse("linkding:bookmark-archive", args=[bookmark.id])
|
||||||
|
|
||||||
self.post(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.post(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
@@ -137,7 +135,7 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
|
|
||||||
def test_unarchive_requires_authentication(self):
|
def test_unarchive_requires_authentication(self):
|
||||||
bookmark = self.setup_bookmark(is_archived=True)
|
bookmark = self.setup_bookmark(is_archived=True)
|
||||||
url = reverse("bookmarks:bookmark-unarchive", args=[bookmark.id])
|
url = reverse("linkding:bookmark-unarchive", args=[bookmark.id])
|
||||||
|
|
||||||
self.post(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.post(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
@@ -145,7 +143,7 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
self.post(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
self.post(url, expected_status_code=status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
def test_check_requires_authentication(self):
|
def test_check_requires_authentication(self):
|
||||||
url = reverse("bookmarks:bookmark-check")
|
url = reverse("linkding:bookmark-check")
|
||||||
check_url = urllib.parse.quote_plus("https://example.com")
|
check_url = urllib.parse.quote_plus("https://example.com")
|
||||||
|
|
||||||
self.get(
|
self.get(
|
||||||
@@ -156,7 +154,7 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
self.get(f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK)
|
self.get(f"{url}?url={check_url}", expected_status_code=status.HTTP_200_OK)
|
||||||
|
|
||||||
def test_user_profile_requires_authentication(self):
|
def test_user_profile_requires_authentication(self):
|
||||||
url = reverse("bookmarks:user-profile")
|
url = reverse("linkding:user-profile")
|
||||||
|
|
||||||
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.get(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
@@ -164,6 +162,6 @@ class BookmarksApiPermissionsTestCase(LinkdingApiTestCase, BookmarkFactoryMixin)
|
|||||||
self.get(url, expected_status_code=status.HTTP_200_OK)
|
self.get(url, expected_status_code=status.HTTP_200_OK)
|
||||||
|
|
||||||
def test_singlefile_upload_requires_authentication(self):
|
def test_singlefile_upload_requires_authentication(self):
|
||||||
url = reverse("bookmarks:bookmark-singlefile")
|
url = reverse("linkding:bookmark-singlefile")
|
||||||
|
|
||||||
self.post(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
self.post(url, expected_status_code=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
@@ -65,7 +65,7 @@ class BookmarkListTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
count=1,
|
count=1,
|
||||||
):
|
):
|
||||||
if base_url is None:
|
if base_url is None:
|
||||||
base_url = reverse("bookmarks:index")
|
base_url = reverse("linkding:bookmarks.index")
|
||||||
details_url = base_url + f"?details={bookmark.id}"
|
details_url = base_url + f"?details={bookmark.id}"
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
f"""
|
f"""
|
||||||
@@ -76,7 +76,7 @@ class BookmarkListTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def assertEditLinkCount(self, html: str, bookmark: Bookmark, count=1):
|
def assertEditLinkCount(self, html: str, bookmark: Bookmark, count=1):
|
||||||
edit_url = reverse("bookmarks:edit", args=[bookmark.id])
|
edit_url = reverse("linkding:bookmarks.edit", args=[bookmark.id])
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
f"""
|
f"""
|
||||||
<a href="{edit_url}?return_url=/bookmarks">Edit</a>
|
<a href="{edit_url}?return_url=/bookmarks">Edit</a>
|
||||||
@@ -660,7 +660,9 @@ class BookmarkListTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
bookmark = self.setup_bookmark(user=other_user, shared=True)
|
bookmark = self.setup_bookmark(user=other_user, shared=True)
|
||||||
html = self.render_template(context_type=contexts.SharedBookmarkListContext)
|
html = self.render_template(context_type=contexts.SharedBookmarkListContext)
|
||||||
|
|
||||||
self.assertViewLink(html, bookmark, base_url=reverse("bookmarks:shared"))
|
self.assertViewLink(
|
||||||
|
html, bookmark, base_url=reverse("linkding:bookmarks.shared")
|
||||||
|
)
|
||||||
self.assertNoBookmarkActions(html, bookmark)
|
self.assertNoBookmarkActions(html, bookmark)
|
||||||
self.assertShareInfo(html, bookmark)
|
self.assertShareInfo(html, bookmark)
|
||||||
|
|
||||||
@@ -952,7 +954,9 @@ class BookmarkListTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
self.assertWebArchiveLink(
|
self.assertWebArchiveLink(
|
||||||
html, "1 week ago", bookmark.web_archive_snapshot_url, link_target="_blank"
|
html, "1 week ago", bookmark.web_archive_snapshot_url, link_target="_blank"
|
||||||
)
|
)
|
||||||
self.assertViewLink(html, bookmark, base_url=reverse("bookmarks:shared"))
|
self.assertViewLink(
|
||||||
|
html, bookmark, base_url=reverse("linkding:bookmarks.shared")
|
||||||
|
)
|
||||||
self.assertNoBookmarkActions(html, bookmark)
|
self.assertNoBookmarkActions(html, bookmark)
|
||||||
self.assertShareInfo(html, bookmark)
|
self.assertShareInfo(html, bookmark)
|
||||||
self.assertMarkAsReadButton(html, bookmark, count=0)
|
self.assertMarkAsReadButton(html, bookmark, count=0)
|
||||||
|
@@ -12,21 +12,21 @@ class MockUrlConf:
|
|||||||
class ContextPathTestCase(TestCase):
|
class ContextPathTestCase(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.siteroot_urls = importlib.import_module("siteroot.urls")
|
self.urls_module = importlib.import_module("bookmarks.urls")
|
||||||
|
|
||||||
@override_settings(LD_CONTEXT_PATH=None)
|
@override_settings(LD_CONTEXT_PATH=None)
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
importlib.reload(self.siteroot_urls)
|
importlib.reload(self.urls_module)
|
||||||
|
|
||||||
@override_settings(LD_CONTEXT_PATH="linkding/")
|
@override_settings(LD_CONTEXT_PATH="linkding/")
|
||||||
def test_route_with_context_path(self):
|
def test_route_with_context_path(self):
|
||||||
module = importlib.reload(self.siteroot_urls)
|
module = importlib.reload(self.urls_module)
|
||||||
# pass mock config instead of actual module to prevent caching the
|
# pass mock config instead of actual module to prevent caching the
|
||||||
# url config in django.urls.reverse
|
# url config in django.urls.reverse
|
||||||
urlconf = MockUrlConf(module)
|
urlconf = MockUrlConf(module)
|
||||||
test_cases = [
|
test_cases = [
|
||||||
("bookmarks:index", "/linkding/bookmarks"),
|
("linkding:bookmarks.index", "/linkding/bookmarks"),
|
||||||
("bookmarks:bookmark-list", "/linkding/api/bookmarks/"),
|
("linkding:bookmark-list", "/linkding/api/bookmarks/"),
|
||||||
("login", "/linkding/login/"),
|
("login", "/linkding/login/"),
|
||||||
(
|
(
|
||||||
"admin:bookmarks_bookmark_changelist",
|
"admin:bookmarks_bookmark_changelist",
|
||||||
@@ -40,13 +40,13 @@ class ContextPathTestCase(TestCase):
|
|||||||
|
|
||||||
@override_settings(LD_CONTEXT_PATH="")
|
@override_settings(LD_CONTEXT_PATH="")
|
||||||
def test_route_without_context_path(self):
|
def test_route_without_context_path(self):
|
||||||
module = importlib.reload(self.siteroot_urls)
|
module = importlib.reload(self.urls_module)
|
||||||
# pass mock config instead of actual module to prevent caching the
|
# pass mock config instead of actual module to prevent caching the
|
||||||
# url config in django.urls.reverse
|
# url config in django.urls.reverse
|
||||||
urlconf = MockUrlConf(module)
|
urlconf = MockUrlConf(module)
|
||||||
test_cases = [
|
test_cases = [
|
||||||
("bookmarks:index", "/bookmarks"),
|
("linkding:bookmarks.index", "/bookmarks"),
|
||||||
("bookmarks:bookmark-list", "/api/bookmarks/"),
|
("linkding:bookmark-list", "/api/bookmarks/"),
|
||||||
("login", "/login/"),
|
("login", "/login/"),
|
||||||
("admin:bookmarks_bookmark_changelist", "/admin/bookmarks/bookmark/"),
|
("admin:bookmarks_bookmark_changelist", "/admin/bookmarks/bookmark/"),
|
||||||
]
|
]
|
||||||
|
@@ -10,7 +10,7 @@ class CustomCssViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.client.force_login(user)
|
self.client.force_login(user)
|
||||||
|
|
||||||
def test_with_empty_css(self):
|
def test_with_empty_css(self):
|
||||||
response = self.client.get(reverse("bookmarks:custom_css"))
|
response = self.client.get(reverse("linkding:custom_css"))
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response["Content-Type"], "text/css")
|
self.assertEqual(response["Content-Type"], "text/css")
|
||||||
self.assertEqual(response.headers["Cache-Control"], "public, max-age=2592000")
|
self.assertEqual(response.headers["Cache-Control"], "public, max-age=2592000")
|
||||||
@@ -21,7 +21,7 @@ class CustomCssViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.user.profile.custom_css = css
|
self.user.profile.custom_css = css
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:custom_css"))
|
response = self.client.get(reverse("linkding:custom_css"))
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response["Content-Type"], "text/css")
|
self.assertEqual(response["Content-Type"], "text/css")
|
||||||
self.assertEqual(response.headers["Cache-Control"], "public, max-age=2592000")
|
self.assertEqual(response.headers["Cache-Control"], "public, max-age=2592000")
|
||||||
|
@@ -86,8 +86,8 @@ class ExporterTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"<DD>Example description[linkding-notes]Example notes[/linkding-notes]",
|
"<DD>Example description[linkding-notes]Example notes[/linkding-notes]",
|
||||||
'<DT><A HREF="https://example.com/6" ADD_DATE="6" LAST_MODIFIED="66" PRIVATE="0" TOREAD="0" TAGS="">Title 6</A>',
|
'<DT><A HREF="https://example.com/6" ADD_DATE="6" LAST_MODIFIED="66" PRIVATE="0" TOREAD="0" TAGS="">Title 6</A>',
|
||||||
"<DD>[linkding-notes]Example notes[/linkding-notes]",
|
"<DD>[linkding-notes]Example notes[/linkding-notes]",
|
||||||
'<DT><A HREF="https://example.com/7" ADD_DATE="7" LAST_MODIFIED="77" PRIVATE="1" TOREAD="0" TAGS="linkding:archived">Title 7</A>',
|
'<DT><A HREF="https://example.com/7" ADD_DATE="7" LAST_MODIFIED="77" PRIVATE="1" TOREAD="0" TAGS="linkding:bookmarks.archived">Title 7</A>',
|
||||||
'<DT><A HREF="https://example.com/8" ADD_DATE="8" LAST_MODIFIED="88" PRIVATE="1" TOREAD="0" TAGS="tag4,tag5,linkding:archived">Title 8</A>',
|
'<DT><A HREF="https://example.com/8" ADD_DATE="8" LAST_MODIFIED="88" PRIVATE="1" TOREAD="0" TAGS="tag4,tag5,linkding:bookmarks.archived">Title 8</A>',
|
||||||
]
|
]
|
||||||
self.assertIn("\n\r".join(lines), html)
|
self.assertIn("\n\r".join(lines), html)
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ class ExporterPerformanceTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
# capture number of queries
|
# capture number of queries
|
||||||
context = CaptureQueriesContext(self.get_connection())
|
context = CaptureQueriesContext(self.get_connection())
|
||||||
with context:
|
with context:
|
||||||
self.client.get(reverse("bookmarks:settings.export"), follow=True)
|
self.client.get(reverse("linkding:settings.export"), follow=True)
|
||||||
|
|
||||||
number_of_queries = context.final_queries
|
number_of_queries = context.final_queries
|
||||||
|
|
||||||
|
@@ -51,12 +51,12 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.assertContains(response, expected_item, count=1)
|
self.assertContains(response, expected_item, count=1)
|
||||||
|
|
||||||
def test_all_returns_404_for_unknown_feed_token(self):
|
def test_all_returns_404_for_unknown_feed_token(self):
|
||||||
response = self.client.get(reverse("bookmarks:feeds.all", args=["foo"]))
|
response = self.client.get(reverse("linkding:feeds.all", args=["foo"]))
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
def test_all_metadata(self):
|
def test_all_metadata(self):
|
||||||
feed_url = reverse("bookmarks:feeds.all", args=[self.token.key])
|
feed_url = reverse("linkding:feeds.all", args=[self.token.key])
|
||||||
response = self.client.get(feed_url)
|
response = self.client.get(feed_url)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -77,9 +77,7 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(is_archived=True)
|
self.setup_bookmark(is_archived=True)
|
||||||
self.setup_bookmark(is_archived=True)
|
self.setup_bookmark(is_archived=True)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("linkding:feeds.all", args=[self.token.key]))
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key])
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertFeedItems(response, bookmarks)
|
self.assertFeedItems(response, bookmarks)
|
||||||
|
|
||||||
@@ -91,20 +89,18 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(unread=True, user=other_user)
|
self.setup_bookmark(unread=True, user=other_user)
|
||||||
self.setup_bookmark(unread=True, user=other_user)
|
self.setup_bookmark(unread=True, user=other_user)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("linkding:feeds.all", args=[self.token.key]))
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key])
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
self.assertContains(response, "<item>", count=0)
|
self.assertContains(response, "<item>", count=0)
|
||||||
|
|
||||||
def test_unread_returns_404_for_unknown_feed_token(self):
|
def test_unread_returns_404_for_unknown_feed_token(self):
|
||||||
response = self.client.get(reverse("bookmarks:feeds.unread", args=["foo"]))
|
response = self.client.get(reverse("linkding:feeds.unread", args=["foo"]))
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
def test_unread_metadata(self):
|
def test_unread_metadata(self):
|
||||||
feed_url = reverse("bookmarks:feeds.unread", args=[self.token.key])
|
feed_url = reverse("linkding:feeds.unread", args=[self.token.key])
|
||||||
response = self.client.get(feed_url)
|
response = self.client.get(feed_url)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -130,7 +126,7 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.unread", args=[self.token.key])
|
reverse("linkding:feeds.unread", args=[self.token.key])
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertFeedItems(response, unread_bookmarks)
|
self.assertFeedItems(response, unread_bookmarks)
|
||||||
@@ -144,19 +140,19 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(unread=True, user=other_user)
|
self.setup_bookmark(unread=True, user=other_user)
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.unread", args=[self.token.key])
|
reverse("linkding:feeds.unread", args=[self.token.key])
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
self.assertContains(response, "<item>", count=0)
|
self.assertContains(response, "<item>", count=0)
|
||||||
|
|
||||||
def test_shared_returns_404_for_unknown_feed_token(self):
|
def test_shared_returns_404_for_unknown_feed_token(self):
|
||||||
response = self.client.get(reverse("bookmarks:feeds.shared", args=["foo"]))
|
response = self.client.get(reverse("linkding:feeds.shared", args=["foo"]))
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
def test_shared_metadata(self):
|
def test_shared_metadata(self):
|
||||||
feed_url = reverse("bookmarks:feeds.shared", args=[self.token.key])
|
feed_url = reverse("linkding:feeds.shared", args=[self.token.key])
|
||||||
response = self.client.get(feed_url)
|
response = self.client.get(feed_url)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -182,18 +178,18 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.shared", args=[self.token.key])
|
reverse("linkding:feeds.shared", args=[self.token.key])
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertFeedItems(response, shared_bookmarks)
|
self.assertFeedItems(response, shared_bookmarks)
|
||||||
|
|
||||||
def test_public_shared_does_not_require_auth(self):
|
def test_public_shared_does_not_require_auth(self):
|
||||||
response = self.client.get(reverse("bookmarks:feeds.public_shared"))
|
response = self.client.get(reverse("linkding:feeds.public_shared"))
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_public_shared_metadata(self):
|
def test_public_shared_metadata(self):
|
||||||
feed_url = reverse("bookmarks:feeds.public_shared")
|
feed_url = reverse("linkding:feeds.public_shared")
|
||||||
response = self.client.get(feed_url)
|
response = self.client.get(feed_url)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@@ -223,7 +219,7 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(shared=True, user=user1, description="test"),
|
self.setup_bookmark(shared=True, user=user1, description="test"),
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:feeds.public_shared"))
|
response = self.client.get(reverse("linkding:feeds.public_shared"))
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertFeedItems(response, public_shared_bookmarks)
|
self.assertFeedItems(response, public_shared_bookmarks)
|
||||||
|
|
||||||
@@ -237,7 +233,7 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark()
|
self.setup_bookmark()
|
||||||
self.setup_bookmark()
|
self.setup_bookmark()
|
||||||
|
|
||||||
feed_url = reverse("bookmarks:feeds.all", args=[self.token.key])
|
feed_url = reverse("linkding:feeds.all", args=[self.token.key])
|
||||||
|
|
||||||
url = feed_url + f"?q={bookmark1.title}"
|
url = feed_url + f"?q={bookmark1.title}"
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
@@ -267,22 +263,20 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(unread=False),
|
self.setup_bookmark(unread=False),
|
||||||
|
|
||||||
# without unread parameter
|
# without unread parameter
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("linkding:feeds.all", args=[self.token.key]))
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key])
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=6)
|
self.assertContains(response, "<item>", count=6)
|
||||||
|
|
||||||
# with unread=yes
|
# with unread=yes
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key]) + "?unread=yes"
|
reverse("linkding:feeds.all", args=[self.token.key]) + "?unread=yes"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=2)
|
self.assertContains(response, "<item>", count=2)
|
||||||
|
|
||||||
# with unread=no
|
# with unread=no
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key]) + "?unread=no"
|
reverse("linkding:feeds.all", args=[self.token.key]) + "?unread=no"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=4)
|
self.assertContains(response, "<item>", count=4)
|
||||||
@@ -296,22 +290,20 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(shared=False)
|
self.setup_bookmark(shared=False)
|
||||||
|
|
||||||
# without shared parameter
|
# without shared parameter
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("linkding:feeds.all", args=[self.token.key]))
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key])
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=6)
|
self.assertContains(response, "<item>", count=6)
|
||||||
|
|
||||||
# with shared=yes
|
# with shared=yes
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key]) + "?shared=yes"
|
reverse("linkding:feeds.all", args=[self.token.key]) + "?shared=yes"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=2)
|
self.assertContains(response, "<item>", count=2)
|
||||||
|
|
||||||
# with shared=no
|
# with shared=no
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key]) + "?shared=no"
|
reverse("linkding:feeds.all", args=[self.token.key]) + "?shared=no"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=4)
|
self.assertContains(response, "<item>", count=4)
|
||||||
@@ -325,9 +317,7 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("linkding:feeds.all", args=[self.token.key]))
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key])
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertFeedItems(response, bookmarks)
|
self.assertFeedItems(response, bookmarks)
|
||||||
|
|
||||||
@@ -335,22 +325,20 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_numbered_bookmarks(200)
|
self.setup_numbered_bookmarks(200)
|
||||||
|
|
||||||
# without limit - defaults to 100
|
# without limit - defaults to 100
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("linkding:feeds.all", args=[self.token.key]))
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key])
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=100)
|
self.assertContains(response, "<item>", count=100)
|
||||||
|
|
||||||
# with increased limit
|
# with increased limit
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key]) + "?limit=200"
|
reverse("linkding:feeds.all", args=[self.token.key]) + "?limit=200"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=200)
|
self.assertContains(response, "<item>", count=200)
|
||||||
|
|
||||||
# with decreased limit
|
# with decreased limit
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key]) + "?limit=5"
|
reverse("linkding:feeds.all", args=[self.token.key]) + "?limit=5"
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=5)
|
self.assertContains(response, "<item>", count=5)
|
||||||
@@ -359,9 +347,7 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(
|
self.setup_bookmark(
|
||||||
title="test\n\r\t\0\x08title", description="test\n\r\t\0\x08description"
|
title="test\n\r\t\0\x08title", description="test\n\r\t\0\x08description"
|
||||||
)
|
)
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("linkding:feeds.all", args=[self.token.key]))
|
||||||
reverse("bookmarks:feeds.all", args=[self.token.key])
|
|
||||||
)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, "<item>", count=1)
|
self.assertContains(response, "<item>", count=1)
|
||||||
self.assertContains(response, f"<title>test\n\r\ttitle</title>", count=1)
|
self.assertContains(response, f"<title>test\n\r\ttitle</title>", count=1)
|
||||||
|
@@ -30,7 +30,7 @@ class FeedsPerformanceTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
# capture number of queries
|
# capture number of queries
|
||||||
context = CaptureQueriesContext(self.get_connection())
|
context = CaptureQueriesContext(self.get_connection())
|
||||||
with context:
|
with context:
|
||||||
feed_url = reverse("bookmarks:feeds.all", args=[self.token.key])
|
feed_url = reverse("linkding:feeds.all", args=[self.token.key])
|
||||||
self.client.get(feed_url)
|
self.client.get(feed_url)
|
||||||
|
|
||||||
number_of_queries = context.final_queries
|
number_of_queries = context.final_queries
|
||||||
|
@@ -419,7 +419,7 @@ class ImporterTestCase(TestCase, BookmarkFactoryMixin, ImportTestMixin):
|
|||||||
def test_archived_state(self):
|
def test_archived_state(self):
|
||||||
test_html = self.render_html(
|
test_html = self.render_html(
|
||||||
tags_html="""
|
tags_html="""
|
||||||
<DT><A HREF="https://example.com/1" ADD_DATE="1" TAGS="tag1,tag2,linkding:archived">Example title 1</A>
|
<DT><A HREF="https://example.com/1" ADD_DATE="1" TAGS="tag1,tag2,linkding:bookmarks.archived">Example title 1</A>
|
||||||
<DD>Example description 1</DD>
|
<DD>Example description 1</DD>
|
||||||
<DT><A HREF="https://example.com/2" ADD_DATE="1" PRIVATE="1" TAGS="tag1,tag2">Example title 2</A>
|
<DT><A HREF="https://example.com/2" ADD_DATE="1" PRIVATE="1" TAGS="tag1,tag2">Example title 2</A>
|
||||||
<DD>Example description 2</DD>
|
<DD>Example description 2</DD>
|
||||||
|
@@ -14,12 +14,12 @@ class LayoutTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
def test_nav_menu_should_respect_share_profile_setting(self):
|
def test_nav_menu_should_respect_share_profile_setting(self):
|
||||||
self.user.profile.enable_sharing = False
|
self.user.profile.enable_sharing = False
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
f"""
|
f"""
|
||||||
<a href="{reverse('bookmarks:shared')}" class="menu-link">Shared</a>
|
<a href="{reverse('linkding:bookmarks.shared')}" class="menu-link">Shared</a>
|
||||||
""",
|
""",
|
||||||
html,
|
html,
|
||||||
count=0,
|
count=0,
|
||||||
@@ -27,12 +27,12 @@ class LayoutTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
|
|
||||||
self.user.profile.enable_sharing = True
|
self.user.profile.enable_sharing = True
|
||||||
self.user.profile.save()
|
self.user.profile.save()
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
f"""
|
f"""
|
||||||
<a href="{reverse('bookmarks:shared')}" class="menu-link">Shared</a>
|
<a href="{reverse('linkding:bookmarks.shared')}" class="menu-link">Shared</a>
|
||||||
""",
|
""",
|
||||||
html,
|
html,
|
||||||
count=2,
|
count=2,
|
||||||
@@ -43,7 +43,7 @@ class LayoutTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
settings.enable_link_prefetch = False
|
settings.enable_link_prefetch = False
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -55,7 +55,7 @@ class LayoutTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
settings.enable_link_prefetch = True
|
settings.enable_link_prefetch = True
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -65,7 +65,7 @@ class LayoutTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_does_not_link_custom_css_when_empty(self):
|
def test_does_not_link_custom_css_when_empty(self):
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ class LayoutTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
profile.custom_css = "body { background-color: red; }"
|
profile.custom_css = "body { background-color: red; }"
|
||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
|
|
||||||
@@ -89,12 +89,12 @@ class LayoutTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||||||
profile.custom_css = "body { background-color: red; }"
|
profile.custom_css = "body { background-color: red; }"
|
||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
soup = self.make_soup(html)
|
soup = self.make_soup(html)
|
||||||
|
|
||||||
link = soup.select_one("link[rel='stylesheet'][href*='custom_css']")
|
link = soup.select_one("link[rel='stylesheet'][href*='custom_css']")
|
||||||
expected_url = (
|
expected_url = (
|
||||||
reverse("bookmarks:custom_css") + f"?hash={profile.custom_css_hash}"
|
reverse("linkding:custom_css") + f"?hash={profile.custom_css_hash}"
|
||||||
)
|
)
|
||||||
self.assertEqual(link["href"], expected_url)
|
self.assertEqual(link["href"], expected_url)
|
||||||
|
@@ -2,7 +2,7 @@ from django.test import TestCase, override_settings
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from bookmarks.tests.helpers import BookmarkFactoryMixin, HtmlTestMixin
|
from bookmarks.tests.helpers import BookmarkFactoryMixin, HtmlTestMixin
|
||||||
from siteroot.urls import urlpatterns as base_patterns
|
from bookmarks.urls import urlpatterns as base_patterns
|
||||||
|
|
||||||
# Register OIDC urls for this test, otherwise login template can not render when OIDC is enabled
|
# Register OIDC urls for this test, otherwise login template can not render when OIDC is enabled
|
||||||
urlpatterns = base_patterns + [path("oidc/", include("mozilla_django_oidc.urls"))]
|
urlpatterns = base_patterns + [path("oidc/", include("mozilla_django_oidc.urls"))]
|
||||||
|
@@ -9,28 +9,28 @@ from bookmarks import utils
|
|||||||
|
|
||||||
class OidcSupportTest(TestCase):
|
class OidcSupportTest(TestCase):
|
||||||
def test_should_not_add_oidc_urls_by_default(self):
|
def test_should_not_add_oidc_urls_by_default(self):
|
||||||
siteroot_urls = importlib.import_module("siteroot.urls")
|
urls_module = importlib.import_module("bookmarks.urls")
|
||||||
importlib.reload(siteroot_urls)
|
importlib.reload(urls_module)
|
||||||
oidc_url_found = any(
|
oidc_url_found = any(
|
||||||
isinstance(urlpattern, URLResolver) and urlpattern.pattern._route == "oidc/"
|
isinstance(urlpattern, URLResolver) and urlpattern.pattern._route == "oidc/"
|
||||||
for urlpattern in siteroot_urls.urlpatterns
|
for urlpattern in urls_module.urlpatterns
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertFalse(oidc_url_found)
|
self.assertFalse(oidc_url_found)
|
||||||
|
|
||||||
@override_settings(LD_ENABLE_OIDC=True)
|
@override_settings(LD_ENABLE_OIDC=True)
|
||||||
def test_should_add_oidc_urls_when_enabled(self):
|
def test_should_add_oidc_urls_when_enabled(self):
|
||||||
siteroot_urls = importlib.import_module("siteroot.urls")
|
urls_module = importlib.import_module("bookmarks.urls")
|
||||||
importlib.reload(siteroot_urls)
|
importlib.reload(urls_module)
|
||||||
oidc_url_found = any(
|
oidc_url_found = any(
|
||||||
isinstance(urlpattern, URLResolver) and urlpattern.pattern._route == "oidc/"
|
isinstance(urlpattern, URLResolver) and urlpattern.pattern._route == "oidc/"
|
||||||
for urlpattern in siteroot_urls.urlpatterns
|
for urlpattern in urls_module.urlpatterns
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(oidc_url_found)
|
self.assertTrue(oidc_url_found)
|
||||||
|
|
||||||
def test_should_not_add_oidc_authentication_backend_by_default(self):
|
def test_should_not_add_oidc_authentication_backend_by_default(self):
|
||||||
base_settings = importlib.import_module("siteroot.settings.base")
|
base_settings = importlib.import_module("bookmarks.settings.base")
|
||||||
importlib.reload(base_settings)
|
importlib.reload(base_settings)
|
||||||
|
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
@@ -40,7 +40,7 @@ class OidcSupportTest(TestCase):
|
|||||||
|
|
||||||
def test_should_add_oidc_authentication_backend_when_enabled(self):
|
def test_should_add_oidc_authentication_backend_when_enabled(self):
|
||||||
os.environ["LD_ENABLE_OIDC"] = "True"
|
os.environ["LD_ENABLE_OIDC"] = "True"
|
||||||
base_settings = importlib.import_module("siteroot.settings.base")
|
base_settings = importlib.import_module("bookmarks.settings.base")
|
||||||
importlib.reload(base_settings)
|
importlib.reload(base_settings)
|
||||||
|
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
@@ -54,7 +54,7 @@ class OidcSupportTest(TestCase):
|
|||||||
|
|
||||||
def test_default_settings(self):
|
def test_default_settings(self):
|
||||||
os.environ["LD_ENABLE_OIDC"] = "True"
|
os.environ["LD_ENABLE_OIDC"] = "True"
|
||||||
base_settings = importlib.import_module("siteroot.settings.base")
|
base_settings = importlib.import_module("bookmarks.settings.base")
|
||||||
importlib.reload(base_settings)
|
importlib.reload(base_settings)
|
||||||
|
|
||||||
self.assertEqual(True, base_settings.OIDC_VERIFY_SSL)
|
self.assertEqual(True, base_settings.OIDC_VERIFY_SSL)
|
||||||
|
@@ -7,7 +7,7 @@ from bookmarks.tests.helpers import BookmarkFactoryMixin
|
|||||||
|
|
||||||
class RootViewTestCase(TestCase, BookmarkFactoryMixin):
|
class RootViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||||
def test_unauthenticated_user_redirect_to_login_by_default(self):
|
def test_unauthenticated_user_redirect_to_login_by_default(self):
|
||||||
response = self.client.get(reverse("bookmarks:root"))
|
response = self.client.get(reverse("linkding:root"))
|
||||||
self.assertRedirects(response, reverse("login"))
|
self.assertRedirects(response, reverse("login"))
|
||||||
|
|
||||||
def test_unauthenticated_redirect_to_shared_bookmarks_if_configured_in_global_settings(
|
def test_unauthenticated_redirect_to_shared_bookmarks_if_configured_in_global_settings(
|
||||||
@@ -17,24 +17,24 @@ class RootViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
settings.landing_page = GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS
|
settings.landing_page = GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:root"))
|
response = self.client.get(reverse("linkding:root"))
|
||||||
self.assertRedirects(response, reverse("bookmarks:shared"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
def test_authenticated_user_always_redirected_to_bookmarks(self):
|
def test_authenticated_user_always_redirected_to_bookmarks(self):
|
||||||
self.client.force_login(self.get_or_create_test_user())
|
self.client.force_login(self.get_or_create_test_user())
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:root"))
|
response = self.client.get(reverse("linkding:root"))
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
settings = GlobalSettings.get()
|
settings = GlobalSettings.get()
|
||||||
settings.landing_page = GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS
|
settings.landing_page = GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:root"))
|
response = self.client.get(reverse("linkding:root"))
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
settings.landing_page = GlobalSettings.LANDING_PAGE_LOGIN
|
settings.landing_page = GlobalSettings.LANDING_PAGE_LOGIN
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:root"))
|
response = self.client.get(reverse("linkding:root"))
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
|
@@ -25,7 +25,7 @@ class SettingsExportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(tags=[self.setup_tag()], is_archived=True)
|
self.setup_bookmark(tags=[self.setup_tag()], is_archived=True)
|
||||||
self.setup_bookmark(tags=[self.setup_tag()], is_archived=True)
|
self.setup_bookmark(tags=[self.setup_tag()], is_archived=True)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:settings.export"), follow=True)
|
response = self.client.get(reverse("linkding:settings.export"), follow=True)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response["content-type"], "text/plain; charset=UTF-8")
|
self.assertEqual(response["content-type"], "text/plain; charset=UTF-8")
|
||||||
@@ -49,7 +49,7 @@ class SettingsExportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.setup_bookmark(tags=[self.setup_tag()], user=other_user),
|
self.setup_bookmark(tags=[self.setup_tag()], user=other_user),
|
||||||
]
|
]
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:settings.export"), follow=True)
|
response = self.client.get(reverse("linkding:settings.export"), follow=True)
|
||||||
|
|
||||||
text = response.content.decode("utf-8")
|
text = response.content.decode("utf-8")
|
||||||
|
|
||||||
@@ -61,10 +61,10 @@ class SettingsExportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_should_check_authentication(self):
|
def test_should_check_authentication(self):
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
response = self.client.get(reverse("bookmarks:settings.export"), follow=True)
|
response = self.client.get(reverse("linkding:settings.export"), follow=True)
|
||||||
|
|
||||||
self.assertRedirects(
|
self.assertRedirects(
|
||||||
response, reverse("login") + "?next=" + reverse("bookmarks:settings.export")
|
response, reverse("login") + "?next=" + reverse("linkding:settings.export")
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_should_show_hint_when_export_raises_error(self):
|
def test_should_show_hint_when_export_raises_error(self):
|
||||||
@@ -72,9 +72,7 @@ class SettingsExportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"bookmarks.services.exporter.export_netscape_html"
|
"bookmarks.services.exporter.export_netscape_html"
|
||||||
) as mock_export_netscape_html:
|
) as mock_export_netscape_html:
|
||||||
mock_export_netscape_html.side_effect = Exception("Nope")
|
mock_export_netscape_html.side_effect = Exception("Nope")
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("linkding:settings.export"), follow=True)
|
||||||
reverse("bookmarks:settings.export"), follow=True
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertTemplateUsed(response, "settings/general.html")
|
self.assertTemplateUsed(response, "settings/general.html")
|
||||||
self.assertFormErrorHint(
|
self.assertFormErrorHint(
|
||||||
|
@@ -71,24 +71,24 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_should_render_successfully(self):
|
def test_should_render_successfully(self):
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_should_check_authentication(self):
|
def test_should_check_authentication(self):
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"), follow=True)
|
response = self.client.get(reverse("linkding:settings.general"), follow=True)
|
||||||
|
|
||||||
self.assertRedirects(
|
self.assertRedirects(
|
||||||
response,
|
response,
|
||||||
reverse("login") + "?next=" + reverse("bookmarks:settings.general"),
|
reverse("login") + "?next=" + reverse("linkding:settings.general"),
|
||||||
)
|
)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:settings.update"), follow=True)
|
response = self.client.get(reverse("linkding:settings.update"), follow=True)
|
||||||
|
|
||||||
self.assertRedirects(
|
self.assertRedirects(
|
||||||
response,
|
response,
|
||||||
reverse("login") + "?next=" + reverse("bookmarks:settings.update"),
|
reverse("login") + "?next=" + reverse("linkding:settings.update"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_update_profile(self):
|
def test_update_profile(self):
|
||||||
@@ -121,7 +121,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"collapse_side_panel": True,
|
"collapse_side_panel": True,
|
||||||
}
|
}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_update_profile_with_invalid_form_returns_422(self):
|
def test_update_profile_with_invalid_form_returns_422(self):
|
||||||
form_data = self.create_profile_form_data({"items_per_page": "-1"})
|
form_data = self.create_profile_form_data({"items_per_page": "-1"})
|
||||||
response = self.client.post(reverse("bookmarks:settings.update"), form_data)
|
response = self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 422)
|
self.assertEqual(response.status_code, 422)
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"theme": UserProfile.THEME_DARK,
|
"theme": UserProfile.THEME_DARK,
|
||||||
}
|
}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -229,21 +229,21 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"custom_css": "body { background-color: #000; }",
|
"custom_css": "body { background-color: #000; }",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data, follow=True)
|
self.client.post(reverse("linkding:settings.update"), form_data, follow=True)
|
||||||
self.user.profile.refresh_from_db()
|
self.user.profile.refresh_from_db()
|
||||||
|
|
||||||
expected_hash = hashlib.md5(form_data["custom_css"].encode("utf-8")).hexdigest()
|
expected_hash = hashlib.md5(form_data["custom_css"].encode("utf-8")).hexdigest()
|
||||||
self.assertEqual(expected_hash, self.user.profile.custom_css_hash)
|
self.assertEqual(expected_hash, self.user.profile.custom_css_hash)
|
||||||
|
|
||||||
form_data["custom_css"] = "body { background-color: #fff; }"
|
form_data["custom_css"] = "body { background-color: #fff; }"
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data, follow=True)
|
self.client.post(reverse("linkding:settings.update"), form_data, follow=True)
|
||||||
self.user.profile.refresh_from_db()
|
self.user.profile.refresh_from_db()
|
||||||
|
|
||||||
expected_hash = hashlib.md5(form_data["custom_css"].encode("utf-8")).hexdigest()
|
expected_hash = hashlib.md5(form_data["custom_css"].encode("utf-8")).hexdigest()
|
||||||
self.assertEqual(expected_hash, self.user.profile.custom_css_hash)
|
self.assertEqual(expected_hash, self.user.profile.custom_css_hash)
|
||||||
|
|
||||||
form_data["custom_css"] = ""
|
form_data["custom_css"] = ""
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data, follow=True)
|
self.client.post(reverse("linkding:settings.update"), form_data, follow=True)
|
||||||
self.user.profile.refresh_from_db()
|
self.user.profile.refresh_from_db()
|
||||||
|
|
||||||
self.assertEqual("", self.user.profile.custom_css_hash)
|
self.assertEqual("", self.user.profile.custom_css_hash)
|
||||||
@@ -258,14 +258,14 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"enable_favicons": True,
|
"enable_favicons": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data)
|
self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
|
|
||||||
mock_schedule_bookmarks_without_favicons.assert_called_once_with(self.user)
|
mock_schedule_bookmarks_without_favicons.assert_called_once_with(self.user)
|
||||||
|
|
||||||
# No update scheduled if favicons are already enabled
|
# No update scheduled if favicons are already enabled
|
||||||
mock_schedule_bookmarks_without_favicons.reset_mock()
|
mock_schedule_bookmarks_without_favicons.reset_mock()
|
||||||
|
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data)
|
self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
|
|
||||||
mock_schedule_bookmarks_without_favicons.assert_not_called()
|
mock_schedule_bookmarks_without_favicons.assert_not_called()
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data)
|
self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
|
|
||||||
mock_schedule_bookmarks_without_favicons.assert_not_called()
|
mock_schedule_bookmarks_without_favicons.assert_not_called()
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"refresh_favicons": "",
|
"refresh_favicons": "",
|
||||||
}
|
}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
tasks, "schedule_refresh_favicons"
|
tasks, "schedule_refresh_favicons"
|
||||||
) as mock_schedule_refresh_favicons:
|
) as mock_schedule_refresh_favicons:
|
||||||
form_data = {}
|
form_data = {}
|
||||||
response = self.client.post(reverse("bookmarks:settings.update"), form_data)
|
response = self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
mock_schedule_refresh_favicons.assert_not_called()
|
mock_schedule_refresh_favicons.assert_not_called()
|
||||||
@@ -315,7 +315,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
profile.enable_favicons = True
|
profile.enable_favicons = True
|
||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -333,7 +333,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
profile.enable_favicons = False
|
profile.enable_favicons = False
|
||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -350,7 +350,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
profile.enable_favicons = True
|
profile.enable_favicons = True
|
||||||
profile.save()
|
profile.save()
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -371,14 +371,14 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"enable_preview_images": True,
|
"enable_preview_images": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data)
|
self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
|
|
||||||
mock_schedule_bookmarks_without_previews.assert_called_once_with(self.user)
|
mock_schedule_bookmarks_without_previews.assert_called_once_with(self.user)
|
||||||
|
|
||||||
# No update scheduled if favicons are already enabled
|
# No update scheduled if favicons are already enabled
|
||||||
mock_schedule_bookmarks_without_previews.reset_mock()
|
mock_schedule_bookmarks_without_previews.reset_mock()
|
||||||
|
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data)
|
self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
|
|
||||||
mock_schedule_bookmarks_without_previews.assert_not_called()
|
mock_schedule_bookmarks_without_previews.assert_not_called()
|
||||||
|
|
||||||
@@ -389,14 +389,14 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
self.client.post(reverse("bookmarks:settings.update"), form_data)
|
self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
|
|
||||||
mock_schedule_bookmarks_without_previews.assert_not_called()
|
mock_schedule_bookmarks_without_previews.assert_not_called()
|
||||||
|
|
||||||
def test_automatic_html_snapshots_should_be_hidden_when_snapshots_not_supported(
|
def test_automatic_html_snapshots_should_be_hidden_when_snapshots_not_supported(
|
||||||
self,
|
self,
|
||||||
):
|
):
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -411,7 +411,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
def test_automatic_html_snapshots_should_be_visible_when_snapshots_supported(
|
def test_automatic_html_snapshots_should_be_visible_when_snapshots_supported(
|
||||||
self,
|
self,
|
||||||
):
|
):
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -423,7 +423,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_about_shows_version_info(self):
|
def test_about_shows_version_info(self):
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -478,7 +478,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"create_missing_html_snapshots": "",
|
"create_missing_html_snapshots": "",
|
||||||
}
|
}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -498,7 +498,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"create_missing_html_snapshots": "",
|
"create_missing_html_snapshots": "",
|
||||||
}
|
}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -515,7 +515,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
mock_create_missing_html_snapshots.return_value = 5
|
mock_create_missing_html_snapshots.return_value = 5
|
||||||
form_data = {}
|
form_data = {}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
@@ -537,7 +537,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"guest_profile_user": selectable_user.id,
|
"guest_profile_user": selectable_user.id,
|
||||||
}
|
}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertSuccessMessage(response.content.decode(), "Global settings updated")
|
self.assertSuccessMessage(response.content.decode(), "Global settings updated")
|
||||||
@@ -553,7 +553,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"guest_profile_user": "",
|
"guest_profile_user": "",
|
||||||
}
|
}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertSuccessMessage(response.content.decode(), "Global settings updated")
|
self.assertSuccessMessage(response.content.decode(), "Global settings updated")
|
||||||
@@ -573,7 +573,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"landing_page": GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS,
|
"landing_page": GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS,
|
||||||
}
|
}
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
reverse("linkding:settings.update"), form_data, follow=True
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertSuccessMessage(
|
self.assertSuccessMessage(
|
||||||
@@ -585,11 +585,11 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"update_global_settings": "",
|
"update_global_settings": "",
|
||||||
"landing_page": GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS,
|
"landing_page": GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS,
|
||||||
}
|
}
|
||||||
response = self.client.post(reverse("bookmarks:settings.update"), form_data)
|
response = self.client.post(reverse("linkding:settings.update"), form_data)
|
||||||
self.assertEqual(response.status_code, 403)
|
self.assertEqual(response.status_code, 403)
|
||||||
|
|
||||||
def test_global_settings_only_visible_for_superuser(self):
|
def test_global_settings_only_visible_for_superuser(self):
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
@@ -601,7 +601,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
superuser = self.setup_superuser()
|
superuser = self.setup_superuser()
|
||||||
self.client.force_login(superuser)
|
self.client.force_login(superuser)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:settings.general"))
|
response = self.client.get(reverse("linkding:settings.general"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(
|
self.assertInHTML(
|
||||||
|
@@ -38,12 +38,12 @@ class SettingsImportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"bookmarks/tests/resources/simple_valid_import_file.html"
|
"bookmarks/tests/resources/simple_valid_import_file.html"
|
||||||
) as import_file:
|
) as import_file:
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.import"),
|
reverse("linkding:settings.import"),
|
||||||
{"import_file": import_file},
|
{"import_file": import_file},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:settings.general"))
|
self.assertRedirects(response, reverse("linkding:settings.general"))
|
||||||
self.assertSuccessMessage(
|
self.assertSuccessMessage(
|
||||||
response, "3 bookmarks were successfully imported."
|
response, "3 bookmarks were successfully imported."
|
||||||
)
|
)
|
||||||
@@ -51,16 +51,16 @@ class SettingsImportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_should_check_authentication(self):
|
def test_should_check_authentication(self):
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
response = self.client.get(reverse("bookmarks:settings.import"), follow=True)
|
response = self.client.get(reverse("linkding:settings.import"), follow=True)
|
||||||
|
|
||||||
self.assertRedirects(
|
self.assertRedirects(
|
||||||
response, reverse("login") + "?next=" + reverse("bookmarks:settings.import")
|
response, reverse("login") + "?next=" + reverse("linkding:settings.import")
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_should_show_hint_if_there_is_no_file(self):
|
def test_should_show_hint_if_there_is_no_file(self):
|
||||||
response = self.client.post(reverse("bookmarks:settings.import"), follow=True)
|
response = self.client.post(reverse("linkding:settings.import"), follow=True)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:settings.general"))
|
self.assertRedirects(response, reverse("linkding:settings.general"))
|
||||||
self.assertNoSuccessMessage(response)
|
self.assertNoSuccessMessage(response)
|
||||||
self.assertErrorMessage(response, "Please select a file to import.")
|
self.assertErrorMessage(response, "Please select a file to import.")
|
||||||
|
|
||||||
@@ -70,12 +70,12 @@ class SettingsImportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"bookmarks/tests/resources/invalid_import_file.png", "rb"
|
"bookmarks/tests/resources/invalid_import_file.png", "rb"
|
||||||
) as import_file:
|
) as import_file:
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.import"),
|
reverse("linkding:settings.import"),
|
||||||
{"import_file": import_file},
|
{"import_file": import_file},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:settings.general"))
|
self.assertRedirects(response, reverse("linkding:settings.general"))
|
||||||
self.assertNoSuccessMessage(response)
|
self.assertNoSuccessMessage(response)
|
||||||
self.assertErrorMessage(
|
self.assertErrorMessage(
|
||||||
response, "An error occurred during bookmark import."
|
response, "An error occurred during bookmark import."
|
||||||
@@ -89,12 +89,12 @@ class SettingsImportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"bookmarks/tests/resources/simple_valid_import_file_with_one_invalid_bookmark.html"
|
"bookmarks/tests/resources/simple_valid_import_file_with_one_invalid_bookmark.html"
|
||||||
) as import_file:
|
) as import_file:
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:settings.import"),
|
reverse("linkding:settings.import"),
|
||||||
{"import_file": import_file},
|
{"import_file": import_file},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:settings.general"))
|
self.assertRedirects(response, reverse("linkding:settings.general"))
|
||||||
self.assertSuccessMessage(
|
self.assertSuccessMessage(
|
||||||
response, "2 bookmarks were successfully imported."
|
response, "2 bookmarks were successfully imported."
|
||||||
)
|
)
|
||||||
@@ -108,7 +108,7 @@ class SettingsImportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"bookmarks/tests/resources/simple_valid_import_file.html"
|
"bookmarks/tests/resources/simple_valid_import_file.html"
|
||||||
) as import_file:
|
) as import_file:
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:settings.import"),
|
reverse("linkding:settings.import"),
|
||||||
{"import_file": import_file},
|
{"import_file": import_file},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
@@ -124,7 +124,7 @@ class SettingsImportViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
"bookmarks/tests/resources/simple_valid_import_file.html"
|
"bookmarks/tests/resources/simple_valid_import_file.html"
|
||||||
) as import_file:
|
) as import_file:
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:settings.import"),
|
reverse("linkding:settings.import"),
|
||||||
{"import_file": import_file, "map_private_flag": "on"},
|
{"import_file": import_file, "map_private_flag": "on"},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
|
@@ -13,25 +13,25 @@ class SettingsIntegrationsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.client.force_login(user)
|
self.client.force_login(user)
|
||||||
|
|
||||||
def test_should_render_successfully(self):
|
def test_should_render_successfully(self):
|
||||||
response = self.client.get(reverse("bookmarks:settings.integrations"))
|
response = self.client.get(reverse("linkding:settings.integrations"))
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_should_check_authentication(self):
|
def test_should_check_authentication(self):
|
||||||
self.client.logout()
|
self.client.logout()
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
reverse("bookmarks:settings.integrations"), follow=True
|
reverse("linkding:settings.integrations"), follow=True
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRedirects(
|
self.assertRedirects(
|
||||||
response,
|
response,
|
||||||
reverse("login") + "?next=" + reverse("bookmarks:settings.integrations"),
|
reverse("login") + "?next=" + reverse("linkding:settings.integrations"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_should_generate_api_token_if_not_exists(self):
|
def test_should_generate_api_token_if_not_exists(self):
|
||||||
self.assertEqual(Token.objects.count(), 0)
|
self.assertEqual(Token.objects.count(), 0)
|
||||||
|
|
||||||
self.client.get(reverse("bookmarks:settings.integrations"))
|
self.client.get(reverse("linkding:settings.integrations"))
|
||||||
|
|
||||||
self.assertEqual(Token.objects.count(), 1)
|
self.assertEqual(Token.objects.count(), 1)
|
||||||
token = Token.objects.first()
|
token = Token.objects.first()
|
||||||
@@ -41,14 +41,14 @@ class SettingsIntegrationsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
Token.objects.get_or_create(user=self.user)
|
Token.objects.get_or_create(user=self.user)
|
||||||
self.assertEqual(Token.objects.count(), 1)
|
self.assertEqual(Token.objects.count(), 1)
|
||||||
|
|
||||||
self.client.get(reverse("bookmarks:settings.integrations"))
|
self.client.get(reverse("linkding:settings.integrations"))
|
||||||
|
|
||||||
self.assertEqual(Token.objects.count(), 1)
|
self.assertEqual(Token.objects.count(), 1)
|
||||||
|
|
||||||
def test_should_generate_feed_token_if_not_exists(self):
|
def test_should_generate_feed_token_if_not_exists(self):
|
||||||
self.assertEqual(FeedToken.objects.count(), 0)
|
self.assertEqual(FeedToken.objects.count(), 0)
|
||||||
|
|
||||||
self.client.get(reverse("bookmarks:settings.integrations"))
|
self.client.get(reverse("linkding:settings.integrations"))
|
||||||
|
|
||||||
self.assertEqual(FeedToken.objects.count(), 1)
|
self.assertEqual(FeedToken.objects.count(), 1)
|
||||||
token = FeedToken.objects.first()
|
token = FeedToken.objects.first()
|
||||||
@@ -58,12 +58,12 @@ class SettingsIntegrationsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
FeedToken.objects.get_or_create(user=self.user)
|
FeedToken.objects.get_or_create(user=self.user)
|
||||||
self.assertEqual(FeedToken.objects.count(), 1)
|
self.assertEqual(FeedToken.objects.count(), 1)
|
||||||
|
|
||||||
self.client.get(reverse("bookmarks:settings.integrations"))
|
self.client.get(reverse("linkding:settings.integrations"))
|
||||||
|
|
||||||
self.assertEqual(FeedToken.objects.count(), 1)
|
self.assertEqual(FeedToken.objects.count(), 1)
|
||||||
|
|
||||||
def test_should_display_feed_urls(self):
|
def test_should_display_feed_urls(self):
|
||||||
response = self.client.get(reverse("bookmarks:settings.integrations"))
|
response = self.client.get(reverse("linkding:settings.integrations"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
token = FeedToken.objects.first()
|
token = FeedToken.objects.first()
|
||||||
|
@@ -35,7 +35,7 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.create_toast()
|
self.create_toast()
|
||||||
self.create_toast(acknowledged=True)
|
self.create_toast(acknowledged=True)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
# Should render toasts container
|
# Should render toasts container
|
||||||
self.assertContains(response, '<div class="toasts">')
|
self.assertContains(response, '<div class="toasts">')
|
||||||
@@ -47,7 +47,7 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.create_toast(acknowledged=True)
|
self.create_toast(acknowledged=True)
|
||||||
self.create_toast(acknowledged=True)
|
self.create_toast(acknowledged=True)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
# Should not render toasts container
|
# Should not render toasts container
|
||||||
self.assertContains(response, '<div class="toasts container grid-lg">', count=0)
|
self.assertContains(response, '<div class="toasts container grid-lg">', count=0)
|
||||||
@@ -63,7 +63,7 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
self.create_toast(user=other_user)
|
self.create_toast(user=other_user)
|
||||||
self.create_toast(user=other_user)
|
self.create_toast(user=other_user)
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
# Should not render toasts container
|
# Should not render toasts container
|
||||||
self.assertContains(response, '<div class="toasts container grid-lg">', count=0)
|
self.assertContains(response, '<div class="toasts container grid-lg">', count=0)
|
||||||
@@ -72,9 +72,9 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_form_tag(self):
|
def test_form_tag(self):
|
||||||
self.create_toast()
|
self.create_toast()
|
||||||
expected_form_tag = f'<form action="{reverse("bookmarks:toasts.acknowledge")}?return_url={reverse("bookmarks:index")}" method="post">'
|
expected_form_tag = f'<form action="{reverse("linkding:toasts.acknowledge")}?return_url={reverse("linkding:bookmarks.index")}" method="post">'
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
self.assertContains(response, expected_form_tag)
|
self.assertContains(response, expected_form_tag)
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = self.client.get(reverse("bookmarks:index"))
|
response = self.client.get(reverse("linkding:bookmarks.index"))
|
||||||
html = response.content.decode()
|
html = response.content.decode()
|
||||||
|
|
||||||
self.assertInHTML(expected_toast, html)
|
self.assertInHTML(expected_toast, html)
|
||||||
@@ -96,7 +96,7 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
toast = self.create_toast()
|
toast = self.create_toast()
|
||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
reverse("bookmarks:toasts.acknowledge"),
|
reverse("linkding:toasts.acknowledge"),
|
||||||
{
|
{
|
||||||
"toast": [toast.id],
|
"toast": [toast.id],
|
||||||
},
|
},
|
||||||
@@ -107,8 +107,8 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
|
|
||||||
def test_acknowledge_toast_should_redirect_to_return_url(self):
|
def test_acknowledge_toast_should_redirect_to_return_url(self):
|
||||||
toast = self.create_toast()
|
toast = self.create_toast()
|
||||||
return_url = reverse("bookmarks:settings.general")
|
return_url = reverse("linkding:settings.general")
|
||||||
acknowledge_url = reverse("bookmarks:toasts.acknowledge")
|
acknowledge_url = reverse("linkding:toasts.acknowledge")
|
||||||
acknowledge_url = acknowledge_url + "?return_url=" + return_url
|
acknowledge_url = acknowledge_url + "?return_url=" + return_url
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
@@ -124,13 +124,13 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
toast = self.create_toast()
|
toast = self.create_toast()
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:toasts.acknowledge"),
|
reverse("linkding:toasts.acknowledge"),
|
||||||
{
|
{
|
||||||
"toast": [toast.id],
|
"toast": [toast.id],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRedirects(response, reverse("bookmarks:index"))
|
self.assertRedirects(response, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
@disable_logging
|
@disable_logging
|
||||||
def test_acknowledge_toast_should_not_acknowledge_other_users_toast(self):
|
def test_acknowledge_toast_should_not_acknowledge_other_users_toast(self):
|
||||||
@@ -140,7 +140,7 @@ class ToastsViewTestCase(TestCase, BookmarkFactoryMixin):
|
|||||||
toast = self.create_toast(user=other_user)
|
toast = self.create_toast(user=other_user)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse("bookmarks:toasts.acknowledge"),
|
reverse("linkding:toasts.acknowledge"),
|
||||||
{
|
{
|
||||||
"toast": [toast.id],
|
"toast": [toast.id],
|
||||||
},
|
},
|
||||||
|
@@ -11,7 +11,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
details_modal = self.open_details_modal(bookmark)
|
details_modal = self.open_details_modal(bookmark)
|
||||||
title = details_modal.locator("h2")
|
title = details_modal.locator("h2")
|
||||||
@@ -21,7 +21,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
# close with close button
|
# close with close button
|
||||||
details_modal = self.open_details_modal(bookmark)
|
details_modal = self.open_details_modal(bookmark)
|
||||||
@@ -44,7 +44,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
# archive
|
# archive
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
details_modal = self.open_details_modal(bookmark)
|
details_modal = self.open_details_modal(bookmark)
|
||||||
@@ -53,7 +53,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.assertReloads(0)
|
self.assertReloads(0)
|
||||||
|
|
||||||
# unarchive
|
# unarchive
|
||||||
url = reverse("bookmarks:archived")
|
url = reverse("linkding:bookmarks.archived")
|
||||||
self.page.goto(self.live_server_url + url)
|
self.page.goto(self.live_server_url + url)
|
||||||
self.resetReloads()
|
self.resetReloads()
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
# mark as unread
|
# mark as unread
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
details_modal = self.open_details_modal(bookmark)
|
details_modal = self.open_details_modal(bookmark)
|
||||||
@@ -92,7 +92,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
# share bookmark
|
# share bookmark
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
details_modal = self.open_details_modal(bookmark)
|
details_modal = self.open_details_modal(bookmark)
|
||||||
@@ -112,7 +112,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index") + f"?q={bookmark.title}"
|
url = reverse("linkding:bookmarks.index") + f"?q={bookmark.title}"
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
details_modal = self.open_details_modal(bookmark)
|
details_modal = self.open_details_modal(bookmark)
|
||||||
@@ -130,7 +130,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index") + f"?q={bookmark.title}"
|
url = reverse("linkding:bookmarks.index") + f"?q={bookmark.title}"
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
details_modal = self.open_details_modal(bookmark)
|
details_modal = self.open_details_modal(bookmark)
|
||||||
@@ -154,7 +154,7 @@ class BookmarkDetailsModalE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index") + f"?q={bookmark.title}"
|
url = reverse("linkding:bookmarks.index") + f"?q={bookmark.title}"
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
details_modal = self.open_details_modal(bookmark)
|
details_modal = self.open_details_modal(bookmark)
|
||||||
|
@@ -12,7 +12,7 @@ class BookmarkItemE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark = self.setup_bookmark(notes="Test notes")
|
bookmark = self.setup_bookmark(notes="Test notes")
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:index"), p)
|
page = self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
notes = self.locate_bookmark(bookmark.title).locator(".notes")
|
notes = self.locate_bookmark(bookmark.title).locator(".notes")
|
||||||
expect(notes).to_be_hidden()
|
expect(notes).to_be_hidden()
|
||||||
|
@@ -37,7 +37,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_test_data()
|
self.setup_test_data()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
bookmark_list = self.locate_bookmark_list()
|
bookmark_list = self.locate_bookmark_list()
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
@@ -75,7 +75,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_test_data()
|
self.setup_test_data()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:archived"), p)
|
self.open(reverse("linkding:bookmarks.archived"), p)
|
||||||
|
|
||||||
bookmark_list = self.locate_bookmark_list()
|
bookmark_list = self.locate_bookmark_list()
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
@@ -113,7 +113,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_test_data()
|
self.setup_test_data()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index") + "?q=foo", p)
|
self.open(reverse("linkding:bookmarks.index") + "?q=foo", p)
|
||||||
|
|
||||||
bookmark_list = self.locate_bookmark_list()
|
bookmark_list = self.locate_bookmark_list()
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
@@ -151,7 +151,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_test_data()
|
self.setup_test_data()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:archived") + "?q=foo", p)
|
self.open(reverse("linkding:bookmarks.archived") + "?q=foo", p)
|
||||||
|
|
||||||
bookmark_list = self.locate_bookmark_list()
|
bookmark_list = self.locate_bookmark_list()
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
@@ -189,7 +189,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(5)
|
self.setup_numbered_bookmarks(5)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
page = self.open(url, p)
|
page = self.open(url, p)
|
||||||
|
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
@@ -213,7 +213,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(5)
|
self.setup_numbered_bookmarks(5)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
@@ -230,7 +230,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(5)
|
self.setup_numbered_bookmarks(5)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
@@ -252,7 +252,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(5)
|
self.setup_numbered_bookmarks(5)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
@@ -278,7 +278,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(100)
|
self.setup_numbered_bookmarks(100)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
page = self.open(url, p)
|
page = self.open(url, p)
|
||||||
|
|
||||||
bookmark_list = self.locate_bookmark_list()
|
bookmark_list = self.locate_bookmark_list()
|
||||||
@@ -310,7 +310,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(100)
|
self.setup_numbered_bookmarks(100)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
bookmark_list = self.locate_bookmark_list()
|
bookmark_list = self.locate_bookmark_list()
|
||||||
|
@@ -44,7 +44,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(5, prefix="bar")
|
self.setup_numbered_bookmarks(5, prefix="bar")
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index") + "?q=foo"
|
url = reverse("linkding:bookmarks.index") + "?q=foo"
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
self.assertVisibleBookmarks(["foo 1", "foo 2", "foo 3", "foo 4", "foo 5"])
|
self.assertVisibleBookmarks(["foo 1", "foo 2", "foo 3", "foo 4", "foo 5"])
|
||||||
@@ -56,7 +56,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(5, prefix="foo")
|
self.setup_numbered_bookmarks(5, prefix="foo")
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index") + "?sort=title_asc"
|
url = reverse("linkding:bookmarks.index") + "?sort=title_asc"
|
||||||
page = self.open(url, p)
|
page = self.open(url, p)
|
||||||
|
|
||||||
first_item = page.locator("li[ld-bookmark-item]").first
|
first_item = page.locator("li[ld-bookmark-item]").first
|
||||||
@@ -72,7 +72,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(50, prefix="foo", suffix="-")
|
self.setup_numbered_bookmarks(50, prefix="foo", suffix="-")
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index") + "?q=foo&page=2"
|
url = reverse("linkding:bookmarks.index") + "?q=foo&page=2"
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
# with descending sort, page two has 'foo 1' to 'foo 20'
|
# with descending sort, page two has 'foo 1' to 'foo 20'
|
||||||
@@ -88,7 +88,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_numbered_bookmarks(5)
|
self.setup_numbered_bookmarks(5)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
url = reverse("bookmarks:index")
|
url = reverse("linkding:bookmarks.index")
|
||||||
self.open(url, p)
|
self.open(url, p)
|
||||||
|
|
||||||
self.locate_bookmark("Bookmark 1").get_by_text("Archive").click()
|
self.locate_bookmark("Bookmark 1").get_by_text("Archive").click()
|
||||||
@@ -108,7 +108,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_fixture()
|
self.setup_fixture()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
self.locate_bookmark("Bookmark 2").get_by_text("Archive").click()
|
self.locate_bookmark("Bookmark 2").get_by_text("Archive").click()
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_fixture()
|
self.setup_fixture()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
self.locate_bookmark("Bookmark 2").get_by_text("Remove").click()
|
self.locate_bookmark("Bookmark 2").get_by_text("Remove").click()
|
||||||
self.locate_bookmark("Bookmark 2").get_by_text("Confirm").click()
|
self.locate_bookmark("Bookmark 2").get_by_text("Confirm").click()
|
||||||
@@ -136,7 +136,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark2.save()
|
bookmark2.save()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
expect(self.locate_bookmark("Bookmark 2")).to_have_class("unread")
|
expect(self.locate_bookmark("Bookmark 2")).to_have_class("unread")
|
||||||
self.locate_bookmark("Bookmark 2").get_by_text("Unread").click()
|
self.locate_bookmark("Bookmark 2").get_by_text("Unread").click()
|
||||||
@@ -152,7 +152,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark2.save()
|
bookmark2.save()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
expect(self.locate_bookmark("Bookmark 2")).to_have_class("shared")
|
expect(self.locate_bookmark("Bookmark 2")).to_have_class("shared")
|
||||||
self.locate_bookmark("Bookmark 2").get_by_text("Shared").click()
|
self.locate_bookmark("Bookmark 2").get_by_text("Shared").click()
|
||||||
@@ -165,7 +165,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_fixture()
|
self.setup_fixture()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
self.locate_bookmark("Bookmark 2").locator(
|
self.locate_bookmark("Bookmark 2").locator(
|
||||||
@@ -183,7 +183,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_fixture()
|
self.setup_fixture()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
self.locate_bookmark("Bookmark 2").locator(
|
self.locate_bookmark("Bookmark 2").locator(
|
||||||
@@ -201,7 +201,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_fixture()
|
self.setup_fixture()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:archived"), p)
|
self.open(reverse("linkding:bookmarks.archived"), p)
|
||||||
|
|
||||||
self.locate_bookmark("Archived Bookmark 2").get_by_text("Unarchive").click()
|
self.locate_bookmark("Archived Bookmark 2").get_by_text("Unarchive").click()
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_fixture()
|
self.setup_fixture()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:archived"), p)
|
self.open(reverse("linkding:bookmarks.archived"), p)
|
||||||
|
|
||||||
self.locate_bookmark("Archived Bookmark 2").get_by_text("Remove").click()
|
self.locate_bookmark("Archived Bookmark 2").get_by_text("Remove").click()
|
||||||
self.locate_bookmark("Archived Bookmark 2").get_by_text("Confirm").click()
|
self.locate_bookmark("Archived Bookmark 2").get_by_text("Confirm").click()
|
||||||
@@ -226,7 +226,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_fixture()
|
self.setup_fixture()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:archived"), p)
|
self.open(reverse("linkding:bookmarks.archived"), p)
|
||||||
|
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
self.locate_bookmark("Archived Bookmark 2").locator(
|
self.locate_bookmark("Archived Bookmark 2").locator(
|
||||||
@@ -244,7 +244,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_fixture()
|
self.setup_fixture()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:archived"), p)
|
self.open(reverse("linkding:bookmarks.archived"), p)
|
||||||
|
|
||||||
self.locate_bulk_edit_toggle().click()
|
self.locate_bulk_edit_toggle().click()
|
||||||
self.locate_bookmark("Archived Bookmark 2").locator(
|
self.locate_bookmark("Archived Bookmark 2").locator(
|
||||||
@@ -265,7 +265,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:shared"), p)
|
self.open(reverse("linkding:bookmarks.shared"), p)
|
||||||
|
|
||||||
self.locate_bookmark("My Bookmark 2").get_by_text("Archive").click()
|
self.locate_bookmark("My Bookmark 2").get_by_text("Archive").click()
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ class BookmarkPagePartialUpdatesE2ETestCase(LinkdingE2ETestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:shared"), p)
|
self.open(reverse("linkding:bookmarks.shared"), p)
|
||||||
|
|
||||||
self.locate_bookmark("My Bookmark 2").get_by_text("Remove").click()
|
self.locate_bookmark("My Bookmark 2").get_by_text("Remove").click()
|
||||||
self.locate_bookmark("My Bookmark 2").get_by_text("Confirm").click()
|
self.locate_bookmark("My Bookmark 2").get_by_text("Confirm").click()
|
||||||
|
@@ -23,13 +23,15 @@ class CollapseSidePanelE2ETestCase(LinkdingE2ETestCase):
|
|||||||
|
|
||||||
def test_side_panel_should_be_visible_by_default(self):
|
def test_side_panel_should_be_visible_by_default(self):
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
self.assertSidePanelIsVisible()
|
self.assertSidePanelIsVisible()
|
||||||
|
|
||||||
self.page.goto(self.live_server_url + reverse("bookmarks:archived"))
|
self.page.goto(
|
||||||
|
self.live_server_url + reverse("linkding:bookmarks.archived")
|
||||||
|
)
|
||||||
self.assertSidePanelIsVisible()
|
self.assertSidePanelIsVisible()
|
||||||
|
|
||||||
self.page.goto(self.live_server_url + reverse("bookmarks:shared"))
|
self.page.goto(self.live_server_url + reverse("linkding:bookmarks.shared"))
|
||||||
self.assertSidePanelIsVisible()
|
self.assertSidePanelIsVisible()
|
||||||
|
|
||||||
def test_side_panel_should_be_hidden_when_collapsed(self):
|
def test_side_panel_should_be_hidden_when_collapsed(self):
|
||||||
@@ -38,11 +40,13 @@ class CollapseSidePanelE2ETestCase(LinkdingE2ETestCase):
|
|||||||
user.profile.save()
|
user.profile.save()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
self.open(reverse("bookmarks:index"), p)
|
self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
self.assertSidePanelIsHidden()
|
self.assertSidePanelIsHidden()
|
||||||
|
|
||||||
self.page.goto(self.live_server_url + reverse("bookmarks:archived"))
|
self.page.goto(
|
||||||
|
self.live_server_url + reverse("linkding:bookmarks.archived")
|
||||||
|
)
|
||||||
self.assertSidePanelIsHidden()
|
self.assertSidePanelIsHidden()
|
||||||
|
|
||||||
self.page.goto(self.live_server_url + reverse("bookmarks:shared"))
|
self.page.goto(self.live_server_url + reverse("linkding:bookmarks.shared"))
|
||||||
self.assertSidePanelIsHidden()
|
self.assertSidePanelIsHidden()
|
||||||
|
@@ -31,7 +31,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:edit", args=[bookmark.id]), p)
|
page = self.open(reverse("linkding:bookmarks.edit", args=[bookmark.id]), p)
|
||||||
|
|
||||||
page.wait_for_timeout(timeout=1000)
|
page.wait_for_timeout(timeout=1000)
|
||||||
page.get_by_text("This URL is already bookmarked.").wait_for(state="hidden")
|
page.get_by_text("This URL is already bookmarked.").wait_for(state="hidden")
|
||||||
@@ -42,7 +42,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:edit", args=[bookmark.id]), p)
|
page = self.open(reverse("linkding:bookmarks.edit", args=[bookmark.id]), p)
|
||||||
page.wait_for_timeout(timeout=1000)
|
page.wait_for_timeout(timeout=1000)
|
||||||
|
|
||||||
title = page.get_by_label("Title")
|
title = page.get_by_label("Title")
|
||||||
@@ -54,7 +54,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
bookmark = self.setup_bookmark()
|
bookmark = self.setup_bookmark()
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:edit", args=[bookmark.id]), p)
|
page = self.open(reverse("linkding:bookmarks.edit", args=[bookmark.id]), p)
|
||||||
|
|
||||||
page.get_by_label("URL").fill("https://example.com")
|
page.get_by_label("URL").fill("https://example.com")
|
||||||
page.wait_for_timeout(timeout=1000)
|
page.wait_for_timeout(timeout=1000)
|
||||||
|
@@ -10,7 +10,7 @@ class FilterDrawerE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_bookmark(tags=[self.setup_tag(name="hiking")])
|
self.setup_bookmark(tags=[self.setup_tag(name="hiking")])
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:index"), p)
|
page = self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
# use smaller viewport to make filter button visible
|
# use smaller viewport to make filter button visible
|
||||||
page.set_viewport_size({"width": 375, "height": 812})
|
page.set_viewport_size({"width": 375, "height": 812})
|
||||||
@@ -43,7 +43,7 @@ class FilterDrawerE2ETestCase(LinkdingE2ETestCase):
|
|||||||
self.setup_bookmark(tags=[self.setup_tag(name="hiking")])
|
self.setup_bookmark(tags=[self.setup_tag(name="hiking")])
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:index"), p)
|
page = self.open(reverse("linkding:bookmarks.index"), p)
|
||||||
|
|
||||||
# use smaller viewport to make filter button visible
|
# use smaller viewport to make filter button visible
|
||||||
page.set_viewport_size({"width": 375, "height": 812})
|
page.set_viewport_size({"width": 375, "height": 812})
|
||||||
|
@@ -9,7 +9,7 @@ class GlobalShortcutsE2ETestCase(LinkdingE2ETestCase):
|
|||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = self.setup_browser(p)
|
browser = self.setup_browser(p)
|
||||||
page = browser.new_page()
|
page = browser.new_page()
|
||||||
page.goto(self.live_server_url + reverse("bookmarks:index"))
|
page.goto(self.live_server_url + reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
page.press("body", "s")
|
page.press("body", "s")
|
||||||
|
|
||||||
@@ -21,10 +21,12 @@ class GlobalShortcutsE2ETestCase(LinkdingE2ETestCase):
|
|||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = self.setup_browser(p)
|
browser = self.setup_browser(p)
|
||||||
page = browser.new_page()
|
page = browser.new_page()
|
||||||
page.goto(self.live_server_url + reverse("bookmarks:index"))
|
page.goto(self.live_server_url + reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
page.press("body", "n")
|
page.press("body", "n")
|
||||||
|
|
||||||
expect(page).to_have_url(self.live_server_url + reverse("bookmarks:new"))
|
expect(page).to_have_url(
|
||||||
|
self.live_server_url + reverse("linkding:bookmarks.new")
|
||||||
|
)
|
||||||
|
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@@ -30,7 +30,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
|
|
||||||
def test_enter_url_prefills_title_and_description(self):
|
def test_enter_url_prefills_title_and_description(self):
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:new"), p)
|
page = self.open(reverse("linkding:bookmarks.new"), p)
|
||||||
url = page.get_by_label("URL")
|
url = page.get_by_label("URL")
|
||||||
title = page.get_by_label("Title")
|
title = page.get_by_label("Title")
|
||||||
description = page.get_by_label("Description")
|
description = page.get_by_label("Description")
|
||||||
@@ -43,7 +43,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
|
|
||||||
def test_enter_url_does_not_overwrite_modified_title_and_description(self):
|
def test_enter_url_does_not_overwrite_modified_title_and_description(self):
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:new"), p)
|
page = self.open(reverse("linkding:bookmarks.new"), p)
|
||||||
url = page.get_by_label("URL")
|
url = page.get_by_label("URL")
|
||||||
title = page.get_by_label("Title")
|
title = page.get_by_label("Title")
|
||||||
description = page.get_by_label("Description")
|
description = page.get_by_label("Description")
|
||||||
@@ -58,7 +58,10 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
|
|
||||||
def test_with_initial_url_prefills_title_and_description(self):
|
def test_with_initial_url_prefills_title_and_description(self):
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page_url = reverse("bookmarks:new") + f"?url={quote('https://example.com')}"
|
page_url = (
|
||||||
|
reverse("linkding:bookmarks.new")
|
||||||
|
+ f"?url={quote('https://example.com')}"
|
||||||
|
)
|
||||||
page = self.open(page_url, p)
|
page = self.open(page_url, p)
|
||||||
url = page.get_by_label("URL")
|
url = page.get_by_label("URL")
|
||||||
title = page.get_by_label("Title")
|
title = page.get_by_label("Title")
|
||||||
@@ -77,7 +80,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
):
|
):
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page_url = (
|
page_url = (
|
||||||
reverse("bookmarks:new")
|
reverse("linkding:bookmarks.new")
|
||||||
+ f"?url={quote('https://example.com')}&title=Initial+title&description=Initial+description"
|
+ f"?url={quote('https://example.com')}&title=Initial+title&description=Initial+description"
|
||||||
)
|
)
|
||||||
page = self.open(page_url, p)
|
page = self.open(page_url, p)
|
||||||
@@ -102,7 +105,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
tag_names = " ".join(existing_bookmark.tag_names)
|
tag_names = " ".join(existing_bookmark.tag_names)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:new"), p)
|
page = self.open(reverse("linkding:bookmarks.new"), p)
|
||||||
|
|
||||||
# Enter bookmarked URL
|
# Enter bookmarked URL
|
||||||
page.get_by_label("URL").fill(existing_bookmark.url)
|
page.get_by_label("URL").fill(existing_bookmark.url)
|
||||||
@@ -135,7 +138,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
page = self.open(reverse("bookmarks:new"), p)
|
page = self.open(reverse("linkding:bookmarks.new"), p)
|
||||||
|
|
||||||
details = page.locator("details.notes")
|
details = page.locator("details.notes")
|
||||||
expect(details).not_to_have_attribute("open", value="")
|
expect(details).not_to_have_attribute("open", value="")
|
||||||
@@ -151,7 +154,7 @@ class BookmarkFormE2ETestCase(LinkdingE2ETestCase):
|
|||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
# Open page with URL that should have auto tags
|
# Open page with URL that should have auto tags
|
||||||
url = (
|
url = (
|
||||||
reverse("bookmarks:new")
|
reverse("linkding:bookmarks.new")
|
||||||
+ "?url=https%3A%2F%2Fgithub.com%2Fsissbruecker%2Flinkding"
|
+ "?url=https%3A%2F%2Fgithub.com%2Fsissbruecker%2Flinkding"
|
||||||
)
|
)
|
||||||
page = self.open(url, p)
|
page = self.open(url, p)
|
||||||
|
@@ -10,7 +10,7 @@ class SettingsGeneralE2ETestCase(LinkdingE2ETestCase):
|
|||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = self.setup_browser(p)
|
browser = self.setup_browser(p)
|
||||||
page = browser.new_page()
|
page = browser.new_page()
|
||||||
page.goto(self.live_server_url + reverse("bookmarks:settings.general"))
|
page.goto(self.live_server_url + reverse("linkding:settings.general"))
|
||||||
|
|
||||||
enable_sharing = page.get_by_label("Enable bookmark sharing")
|
enable_sharing = page.get_by_label("Enable bookmark sharing")
|
||||||
enable_sharing_label = page.get_by_text("Enable bookmark sharing")
|
enable_sharing_label = page.get_by_text("Enable bookmark sharing")
|
||||||
@@ -51,7 +51,7 @@ class SettingsGeneralE2ETestCase(LinkdingE2ETestCase):
|
|||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = self.setup_browser(p)
|
browser = self.setup_browser(p)
|
||||||
page = browser.new_page()
|
page = browser.new_page()
|
||||||
page.goto(self.live_server_url + reverse("bookmarks:settings.general"))
|
page.goto(self.live_server_url + reverse("linkding:settings.general"))
|
||||||
|
|
||||||
max_lines = page.get_by_label("Bookmark description max lines")
|
max_lines = page.get_by_label("Bookmark description max lines")
|
||||||
expect(max_lines).to_be_hidden()
|
expect(max_lines).to_be_hidden()
|
||||||
@@ -66,7 +66,7 @@ class SettingsGeneralE2ETestCase(LinkdingE2ETestCase):
|
|||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = self.setup_browser(p)
|
browser = self.setup_browser(p)
|
||||||
page = browser.new_page()
|
page = browser.new_page()
|
||||||
page.goto(self.live_server_url + reverse("bookmarks:settings.general"))
|
page.goto(self.live_server_url + reverse("linkding:settings.general"))
|
||||||
|
|
||||||
max_lines = page.get_by_label("Bookmark description max lines")
|
max_lines = page.get_by_label("Bookmark description max lines")
|
||||||
expect(max_lines).to_be_visible()
|
expect(max_lines).to_be_visible()
|
||||||
@@ -75,7 +75,7 @@ class SettingsGeneralE2ETestCase(LinkdingE2ETestCase):
|
|||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = self.setup_browser(p)
|
browser = self.setup_browser(p)
|
||||||
page = browser.new_page()
|
page = browser.new_page()
|
||||||
page.goto(self.live_server_url + reverse("bookmarks:settings.general"))
|
page.goto(self.live_server_url + reverse("linkding:settings.general"))
|
||||||
|
|
||||||
max_lines = page.get_by_label("Bookmark description max lines")
|
max_lines = page.get_by_label("Bookmark description max lines")
|
||||||
expect(max_lines).to_be_hidden()
|
expect(max_lines).to_be_hidden()
|
||||||
|
@@ -1,35 +1,37 @@
|
|||||||
|
from django.contrib.auth import views as auth_views
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from django.urls import re_path
|
from django.urls import re_path
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from bookmarks import views
|
from bookmarks import feeds, views
|
||||||
|
from bookmarks.admin import linkding_admin_site
|
||||||
from bookmarks.api import routes as api_routes
|
from bookmarks.api import routes as api_routes
|
||||||
from bookmarks.feeds import (
|
|
||||||
AllBookmarksFeed,
|
|
||||||
UnreadBookmarksFeed,
|
|
||||||
SharedBookmarksFeed,
|
|
||||||
PublicSharedBookmarksFeed,
|
|
||||||
)
|
|
||||||
|
|
||||||
app_name = "bookmarks"
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# Root view handling redirection based on user authentication
|
# Root view handling redirection based on user authentication
|
||||||
re_path(r"^$", views.root, name="root"),
|
re_path(r"^$", views.root, name="root"),
|
||||||
# Bookmarks
|
# Bookmarks
|
||||||
path("bookmarks", views.bookmarks.index, name="index"),
|
path("bookmarks", views.bookmarks.index, name="bookmarks.index"),
|
||||||
path("bookmarks/action", views.bookmarks.index_action, name="index.action"),
|
path(
|
||||||
path("bookmarks/archived", views.bookmarks.archived, name="archived"),
|
"bookmarks/action", views.bookmarks.index_action, name="bookmarks.index.action"
|
||||||
|
),
|
||||||
|
path("bookmarks/archived", views.bookmarks.archived, name="bookmarks.archived"),
|
||||||
path(
|
path(
|
||||||
"bookmarks/archived/action",
|
"bookmarks/archived/action",
|
||||||
views.bookmarks.archived_action,
|
views.bookmarks.archived_action,
|
||||||
name="archived.action",
|
name="bookmarks.archived.action",
|
||||||
),
|
),
|
||||||
path("bookmarks/shared", views.bookmarks.shared, name="shared"),
|
path("bookmarks/shared", views.bookmarks.shared, name="bookmarks.shared"),
|
||||||
path(
|
path(
|
||||||
"bookmarks/shared/action", views.bookmarks.shared_action, name="shared.action"
|
"bookmarks/shared/action",
|
||||||
|
views.bookmarks.shared_action,
|
||||||
|
name="bookmarks.shared.action",
|
||||||
|
),
|
||||||
|
path("bookmarks/new", views.bookmarks.new, name="bookmarks.new"),
|
||||||
|
path("bookmarks/close", views.bookmarks.close, name="bookmarks.close"),
|
||||||
|
path(
|
||||||
|
"bookmarks/<int:bookmark_id>/edit", views.bookmarks.edit, name="bookmarks.edit"
|
||||||
),
|
),
|
||||||
path("bookmarks/new", views.bookmarks.new, name="new"),
|
|
||||||
path("bookmarks/close", views.bookmarks.close, name="close"),
|
|
||||||
path("bookmarks/<int:bookmark_id>/edit", views.bookmarks.edit, name="edit"),
|
|
||||||
# Assets
|
# Assets
|
||||||
path(
|
path(
|
||||||
"assets/<int:asset_id>",
|
"assets/<int:asset_id>",
|
||||||
@@ -64,10 +66,14 @@ urlpatterns = [
|
|||||||
path("api/tags/", include(api_routes.tag_router.urls)),
|
path("api/tags/", include(api_routes.tag_router.urls)),
|
||||||
path("api/user/", include(api_routes.user_router.urls)),
|
path("api/user/", include(api_routes.user_router.urls)),
|
||||||
# Feeds
|
# Feeds
|
||||||
path("feeds/<str:feed_key>/all", AllBookmarksFeed(), name="feeds.all"),
|
path("feeds/<str:feed_key>/all", feeds.AllBookmarksFeed(), name="feeds.all"),
|
||||||
path("feeds/<str:feed_key>/unread", UnreadBookmarksFeed(), name="feeds.unread"),
|
path(
|
||||||
path("feeds/<str:feed_key>/shared", SharedBookmarksFeed(), name="feeds.shared"),
|
"feeds/<str:feed_key>/unread", feeds.UnreadBookmarksFeed(), name="feeds.unread"
|
||||||
path("feeds/shared", PublicSharedBookmarksFeed(), name="feeds.public_shared"),
|
),
|
||||||
|
path(
|
||||||
|
"feeds/<str:feed_key>/shared", feeds.SharedBookmarksFeed(), name="feeds.shared"
|
||||||
|
),
|
||||||
|
path("feeds/shared", feeds.PublicSharedBookmarksFeed(), name="feeds.public_shared"),
|
||||||
# Health check
|
# Health check
|
||||||
path("health", views.health, name="health"),
|
path("health", views.health, name="health"),
|
||||||
# Manifest
|
# Manifest
|
||||||
@@ -75,3 +81,47 @@ urlpatterns = [
|
|||||||
# Custom CSS
|
# Custom CSS
|
||||||
path("custom_css", views.custom_css, name="custom_css"),
|
path("custom_css", views.custom_css, name="custom_css"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Put all linkding URLs into a linkding namespace
|
||||||
|
urlpatterns = [path("", include((urlpatterns, "linkding")))]
|
||||||
|
|
||||||
|
# Auth
|
||||||
|
urlpatterns += [
|
||||||
|
path(
|
||||||
|
"login/",
|
||||||
|
views.auth.LinkdingLoginView.as_view(redirect_authenticated_user=True),
|
||||||
|
name="login",
|
||||||
|
),
|
||||||
|
path("logout/", auth_views.LogoutView.as_view(), name="logout"),
|
||||||
|
path(
|
||||||
|
"change-password/",
|
||||||
|
views.auth.LinkdingPasswordChangeView.as_view(),
|
||||||
|
name="change_password",
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"password-change-done/",
|
||||||
|
auth_views.PasswordChangeDoneView.as_view(),
|
||||||
|
name="password_change_done",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Admin
|
||||||
|
urlpatterns.append(path("admin/", linkding_admin_site.urls))
|
||||||
|
|
||||||
|
# OIDC
|
||||||
|
if settings.LD_ENABLE_OIDC:
|
||||||
|
urlpatterns.append(path("oidc/", include("mozilla_django_oidc.urls")))
|
||||||
|
|
||||||
|
# Debug toolbar
|
||||||
|
if settings.DEBUG:
|
||||||
|
import debug_toolbar
|
||||||
|
|
||||||
|
urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))
|
||||||
|
|
||||||
|
# Registration
|
||||||
|
if settings.ALLOW_REGISTRATION:
|
||||||
|
urlpatterns.append(path("", include("django_registration.backends.one_step.urls")))
|
||||||
|
|
||||||
|
# Context path
|
||||||
|
if settings.LD_CONTEXT_PATH:
|
||||||
|
urlpatterns = [path(settings.LD_CONTEXT_PATH, include(urlpatterns))]
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
from .assets import *
|
from .assets import *
|
||||||
|
from .auth import *
|
||||||
from .bookmarks import *
|
from .bookmarks import *
|
||||||
from .settings import *
|
from .settings import *
|
||||||
from .toasts import *
|
from .toasts import *
|
||||||
|
37
bookmarks/views/auth.py
Normal file
37
bookmarks/views/auth.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.auth import views as auth_views
|
||||||
|
|
||||||
|
|
||||||
|
class LinkdingLoginView(auth_views.LoginView):
|
||||||
|
"""
|
||||||
|
Custom login view to lazily add additional context data
|
||||||
|
Allows to override settings in tests
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
context["allow_registration"] = settings.ALLOW_REGISTRATION
|
||||||
|
context["enable_oidc"] = settings.LD_ENABLE_OIDC
|
||||||
|
return context
|
||||||
|
|
||||||
|
def form_invalid(self, form):
|
||||||
|
"""
|
||||||
|
Return 401 status code on failed login. Should allow integrating with
|
||||||
|
tools like Fail2Ban. Also, Hotwired Turbo requires a non 2xx status
|
||||||
|
code to handle failed form submissions.
|
||||||
|
"""
|
||||||
|
response = super().form_invalid(form)
|
||||||
|
response.status_code = 401
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class LinkdingPasswordChangeView(auth_views.PasswordChangeView):
|
||||||
|
def form_invalid(self, form):
|
||||||
|
"""
|
||||||
|
Hotwired Turbo requires a non 2xx status code to handle failed form
|
||||||
|
submissions.
|
||||||
|
"""
|
||||||
|
response = super().form_invalid(form)
|
||||||
|
response.status_code = 422
|
||||||
|
return response
|
@@ -105,7 +105,7 @@ def shared(request):
|
|||||||
"tag_cloud": tag_cloud,
|
"tag_cloud": tag_cloud,
|
||||||
"details": bookmark_details,
|
"details": bookmark_details,
|
||||||
"users": users,
|
"users": users,
|
||||||
"rss_feed_url": reverse("bookmarks:feeds.public_shared"),
|
"rss_feed_url": reverse("linkding:feeds.public_shared"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -167,9 +167,9 @@ def new(request):
|
|||||||
tag_string = convert_tag_string(form.data["tag_string"])
|
tag_string = convert_tag_string(form.data["tag_string"])
|
||||||
create_bookmark(form.save(commit=False), tag_string, current_user)
|
create_bookmark(form.save(commit=False), tag_string, current_user)
|
||||||
if auto_close:
|
if auto_close:
|
||||||
return HttpResponseRedirect(reverse("bookmarks:close"))
|
return HttpResponseRedirect(reverse("linkding:bookmarks.close"))
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect(reverse("bookmarks:index"))
|
return HttpResponseRedirect(reverse("linkding:bookmarks.index"))
|
||||||
else:
|
else:
|
||||||
form = BookmarkForm()
|
form = BookmarkForm()
|
||||||
if initial_url:
|
if initial_url:
|
||||||
@@ -189,7 +189,7 @@ def new(request):
|
|||||||
context = {
|
context = {
|
||||||
"form": form,
|
"form": form,
|
||||||
"auto_close": initial_auto_close,
|
"auto_close": initial_auto_close,
|
||||||
"return_url": reverse("bookmarks:index"),
|
"return_url": reverse("linkding:bookmarks.index"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return render(request, "bookmarks/new.html", context, status=status)
|
return render(request, "bookmarks/new.html", context, status=status)
|
||||||
@@ -202,7 +202,7 @@ def edit(request, bookmark_id: int):
|
|||||||
except Bookmark.DoesNotExist:
|
except Bookmark.DoesNotExist:
|
||||||
raise Http404("Bookmark does not exist")
|
raise Http404("Bookmark does not exist")
|
||||||
return_url = get_safe_return_url(
|
return_url = get_safe_return_url(
|
||||||
request.GET.get("return_url"), reverse("bookmarks:index")
|
request.GET.get("return_url"), reverse("linkding:bookmarks.index")
|
||||||
)
|
)
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
@@ -327,7 +327,7 @@ def index_action(request):
|
|||||||
if turbo.accept(request):
|
if turbo.accept(request):
|
||||||
return partials.active_bookmark_update(request)
|
return partials.active_bookmark_update(request)
|
||||||
|
|
||||||
return utils.redirect_with_query(request, reverse("bookmarks:index"))
|
return utils.redirect_with_query(request, reverse("linkding:bookmarks.index"))
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@@ -342,7 +342,7 @@ def archived_action(request):
|
|||||||
if turbo.accept(request):
|
if turbo.accept(request):
|
||||||
return partials.archived_bookmark_update(request)
|
return partials.archived_bookmark_update(request)
|
||||||
|
|
||||||
return utils.redirect_with_query(request, reverse("bookmarks:archived"))
|
return utils.redirect_with_query(request, reverse("linkding:bookmarks.archived"))
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@@ -357,7 +357,7 @@ def shared_action(request):
|
|||||||
if turbo.accept(request):
|
if turbo.accept(request):
|
||||||
return partials.shared_bookmark_update(request)
|
return partials.shared_bookmark_update(request)
|
||||||
|
|
||||||
return utils.redirect_with_query(request, reverse("bookmarks:shared"))
|
return utils.redirect_with_query(request, reverse("linkding:bookmarks.shared"))
|
||||||
|
|
||||||
|
|
||||||
def handle_action(request, query: QuerySet[Bookmark] = None):
|
def handle_action(request, query: QuerySet[Bookmark] = None):
|
||||||
|
@@ -25,8 +25,8 @@ CJK_RE = re.compile(r"[\u4e00-\u9fff]+")
|
|||||||
|
|
||||||
|
|
||||||
class RequestContext:
|
class RequestContext:
|
||||||
index_view = "bookmarks:index"
|
index_view = "linkding:bookmarks.index"
|
||||||
action_view = "bookmarks:index.action"
|
action_view = "linkding:bookmarks.index.action"
|
||||||
|
|
||||||
def __init__(self, request: WSGIRequest):
|
def __init__(self, request: WSGIRequest):
|
||||||
self.request = request
|
self.request = request
|
||||||
@@ -62,8 +62,8 @@ class RequestContext:
|
|||||||
|
|
||||||
|
|
||||||
class ActiveBookmarksContext(RequestContext):
|
class ActiveBookmarksContext(RequestContext):
|
||||||
index_view = "bookmarks:index"
|
index_view = "linkding:bookmarks.index"
|
||||||
action_view = "bookmarks:index.action"
|
action_view = "linkding:bookmarks.index.action"
|
||||||
|
|
||||||
def get_bookmark_query_set(self, search: BookmarkSearch):
|
def get_bookmark_query_set(self, search: BookmarkSearch):
|
||||||
return queries.query_bookmarks(
|
return queries.query_bookmarks(
|
||||||
@@ -77,8 +77,8 @@ class ActiveBookmarksContext(RequestContext):
|
|||||||
|
|
||||||
|
|
||||||
class ArchivedBookmarksContext(RequestContext):
|
class ArchivedBookmarksContext(RequestContext):
|
||||||
index_view = "bookmarks:archived"
|
index_view = "linkding:bookmarks.archived"
|
||||||
action_view = "bookmarks:archived.action"
|
action_view = "linkding:bookmarks.archived.action"
|
||||||
|
|
||||||
def get_bookmark_query_set(self, search: BookmarkSearch):
|
def get_bookmark_query_set(self, search: BookmarkSearch):
|
||||||
return queries.query_archived_bookmarks(
|
return queries.query_archived_bookmarks(
|
||||||
@@ -92,8 +92,8 @@ class ArchivedBookmarksContext(RequestContext):
|
|||||||
|
|
||||||
|
|
||||||
class SharedBookmarksContext(RequestContext):
|
class SharedBookmarksContext(RequestContext):
|
||||||
index_view = "bookmarks:shared"
|
index_view = "linkding:bookmarks.shared"
|
||||||
action_view = "bookmarks:shared.action"
|
action_view = "linkding:bookmarks.shared.action"
|
||||||
|
|
||||||
def get_bookmark_query_set(self, search: BookmarkSearch):
|
def get_bookmark_query_set(self, search: BookmarkSearch):
|
||||||
user = User.objects.filter(username=search.user).first()
|
user = User.objects.filter(username=search.user).first()
|
||||||
|
@@ -10,9 +10,9 @@ def root(request):
|
|||||||
settings = request.global_settings
|
settings = request.global_settings
|
||||||
|
|
||||||
if settings.landing_page == GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS:
|
if settings.landing_page == GlobalSettings.LANDING_PAGE_SHARED_BOOKMARKS:
|
||||||
return HttpResponseRedirect(reverse("bookmarks:shared"))
|
return HttpResponseRedirect(reverse("linkding:bookmarks.shared"))
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect(reverse("login"))
|
return HttpResponseRedirect(reverse("login"))
|
||||||
|
|
||||||
# Redirect authenticated users to the bookmarks page
|
# Redirect authenticated users to the bookmarks page
|
||||||
return HttpResponseRedirect(reverse("bookmarks:index"))
|
return HttpResponseRedirect(reverse("linkding:bookmarks.index"))
|
||||||
|
@@ -94,7 +94,7 @@ def update(request):
|
|||||||
request, "No missing snapshots found.", "settings_success_message"
|
request, "No missing snapshots found.", "settings_success_message"
|
||||||
)
|
)
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse("bookmarks:settings.general"))
|
return HttpResponseRedirect(reverse("linkding:settings.general"))
|
||||||
|
|
||||||
|
|
||||||
def update_profile(request):
|
def update_profile(request):
|
||||||
@@ -113,7 +113,7 @@ def update_profile(request):
|
|||||||
if profile.enable_preview_images and not previews_were_enabled:
|
if profile.enable_preview_images and not previews_were_enabled:
|
||||||
tasks.schedule_bookmarks_without_previews(request.user)
|
tasks.schedule_bookmarks_without_previews(request.user)
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse("bookmarks:settings.general"))
|
return HttpResponseRedirect(reverse("linkding:settings.general"))
|
||||||
|
|
||||||
messages.error(
|
messages.error(
|
||||||
request,
|
request,
|
||||||
@@ -165,20 +165,20 @@ def get_ttl_hash(seconds=3600):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def integrations(request):
|
def integrations(request):
|
||||||
application_url = request.build_absolute_uri(reverse("bookmarks:new"))
|
application_url = request.build_absolute_uri(reverse("linkding:bookmarks.new"))
|
||||||
api_token = Token.objects.get_or_create(user=request.user)[0]
|
api_token = Token.objects.get_or_create(user=request.user)[0]
|
||||||
feed_token = FeedToken.objects.get_or_create(user=request.user)[0]
|
feed_token = FeedToken.objects.get_or_create(user=request.user)[0]
|
||||||
all_feed_url = request.build_absolute_uri(
|
all_feed_url = request.build_absolute_uri(
|
||||||
reverse("bookmarks:feeds.all", args=[feed_token.key])
|
reverse("linkding:feeds.all", args=[feed_token.key])
|
||||||
)
|
)
|
||||||
unread_feed_url = request.build_absolute_uri(
|
unread_feed_url = request.build_absolute_uri(
|
||||||
reverse("bookmarks:feeds.unread", args=[feed_token.key])
|
reverse("linkding:feeds.unread", args=[feed_token.key])
|
||||||
)
|
)
|
||||||
shared_feed_url = request.build_absolute_uri(
|
shared_feed_url = request.build_absolute_uri(
|
||||||
reverse("bookmarks:feeds.shared", args=[feed_token.key])
|
reverse("linkding:feeds.shared", args=[feed_token.key])
|
||||||
)
|
)
|
||||||
public_shared_feed_url = request.build_absolute_uri(
|
public_shared_feed_url = request.build_absolute_uri(
|
||||||
reverse("bookmarks:feeds.public_shared")
|
reverse("linkding:feeds.public_shared")
|
||||||
)
|
)
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@@ -205,7 +205,7 @@ def bookmark_import(request):
|
|||||||
messages.error(
|
messages.error(
|
||||||
request, "Please select a file to import.", "settings_error_message"
|
request, "Please select a file to import.", "settings_error_message"
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(reverse("bookmarks:settings.general"))
|
return HttpResponseRedirect(reverse("linkding:settings.general"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = import_file.read().decode()
|
content = import_file.read().decode()
|
||||||
@@ -226,7 +226,7 @@ def bookmark_import(request):
|
|||||||
"settings_error_message",
|
"settings_error_message",
|
||||||
)
|
)
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse("bookmarks:settings.general"))
|
return HttpResponseRedirect(reverse("linkding:settings.general"))
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@@ -17,6 +17,6 @@ def acknowledge(request):
|
|||||||
toast.save()
|
toast.save()
|
||||||
|
|
||||||
return_url = get_safe_return_url(
|
return_url = get_safe_return_url(
|
||||||
request.GET.get("return_url"), reverse("bookmarks:index")
|
request.GET.get("return_url"), reverse("linkding:bookmarks.index")
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(return_url)
|
return HttpResponseRedirect(return_url)
|
||||||
|
13
bookmarks/wsgi.py
Normal file
13
bookmarks/wsgi.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
"""
|
||||||
|
WSGI config for linkding.
|
||||||
|
|
||||||
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bookmarks.settings")
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
@@ -5,7 +5,7 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'siteroot.settings')
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bookmarks.settings")
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
@@ -17,5 +17,5 @@ def main():
|
|||||||
execute_from_command_line(sys.argv)
|
execute_from_command_line(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
DJANGO_SETTINGS_MODULE = siteroot.settings.dev
|
DJANGO_SETTINGS_MODULE = bookmarks.settings.dev
|
||||||
# -- recommended but optional:
|
# -- recommended but optional:
|
||||||
python_files = tests.py test_*.py *_tests.py
|
python_files = tests.py test_*.py *_tests.py
|
||||||
|
@@ -1,83 +0,0 @@
|
|||||||
"""siteroot URL Configuration
|
|
||||||
|
|
||||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
||||||
https://docs.djangoproject.com/en/2.2/topics/http/urls/
|
|
||||||
Examples:
|
|
||||||
Function views
|
|
||||||
1. Add an import: from my_app import views
|
|
||||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
||||||
Class-based views
|
|
||||||
1. Add an import: from other_app.views import Home
|
|
||||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
||||||
Including another URLconf
|
|
||||||
1. Import the include() function: from django.urls import include, path
|
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
||||||
"""
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.contrib.auth import views as auth_views
|
|
||||||
from django.urls import path, include
|
|
||||||
|
|
||||||
from bookmarks.admin import linkding_admin_site
|
|
||||||
|
|
||||||
|
|
||||||
class LinkdingLoginView(auth_views.LoginView):
|
|
||||||
"""
|
|
||||||
Custom login view to lazily add additional context data
|
|
||||||
Allows to override settings in tests
|
|
||||||
"""
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super().get_context_data(**kwargs)
|
|
||||||
|
|
||||||
context["allow_registration"] = settings.ALLOW_REGISTRATION
|
|
||||||
context["enable_oidc"] = settings.LD_ENABLE_OIDC
|
|
||||||
return context
|
|
||||||
|
|
||||||
def form_invalid(self, form):
|
|
||||||
response = super().form_invalid(form)
|
|
||||||
response.status_code = 401
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
class LinkdingPasswordChangeView(auth_views.PasswordChangeView):
|
|
||||||
def form_invalid(self, form):
|
|
||||||
response = super().form_invalid(form)
|
|
||||||
response.status_code = 422
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
path("admin/", linkding_admin_site.urls),
|
|
||||||
path(
|
|
||||||
"login/",
|
|
||||||
LinkdingLoginView.as_view(redirect_authenticated_user=True),
|
|
||||||
name="login",
|
|
||||||
),
|
|
||||||
path("logout/", auth_views.LogoutView.as_view(), name="logout"),
|
|
||||||
path(
|
|
||||||
"change-password/",
|
|
||||||
LinkdingPasswordChangeView.as_view(),
|
|
||||||
name="change_password",
|
|
||||||
),
|
|
||||||
path(
|
|
||||||
"password-change-done/",
|
|
||||||
auth_views.PasswordChangeDoneView.as_view(),
|
|
||||||
name="password_change_done",
|
|
||||||
),
|
|
||||||
path("", include("bookmarks.urls")),
|
|
||||||
]
|
|
||||||
|
|
||||||
if settings.LD_ENABLE_OIDC:
|
|
||||||
urlpatterns.append(path("oidc/", include("mozilla_django_oidc.urls")))
|
|
||||||
|
|
||||||
if settings.LD_CONTEXT_PATH:
|
|
||||||
urlpatterns = [path(settings.LD_CONTEXT_PATH, include(urlpatterns))]
|
|
||||||
|
|
||||||
if settings.DEBUG:
|
|
||||||
import debug_toolbar
|
|
||||||
|
|
||||||
urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))
|
|
||||||
|
|
||||||
if settings.ALLOW_REGISTRATION:
|
|
||||||
urlpatterns.append(path("", include("django_registration.backends.one_step.urls")))
|
|
@@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
WSGI config for siteroot project.
|
|
||||||
|
|
||||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "siteroot.settings")
|
|
||||||
|
|
||||||
application = get_wsgi_application()
|
|
@@ -1,6 +1,6 @@
|
|||||||
[uwsgi]
|
[uwsgi]
|
||||||
module = siteroot.wsgi:application
|
module = bookmarks.wsgi:application
|
||||||
env = DJANGO_SETTINGS_MODULE=siteroot.settings.prod
|
env = DJANGO_SETTINGS_MODULE=bookmarks.settings.prod
|
||||||
static-map = /static=static
|
static-map = /static=static
|
||||||
static-map = /static=data/favicons
|
static-map = /static=data/favicons
|
||||||
static-map = /static=data/previews
|
static-map = /static=data/previews
|
||||||
|
Reference in New Issue
Block a user