Changed the permission to the offset matcher so that editors can use it.

This commit is contained in:
依瑪貓 2023-04-08 19:03:13 +08:00
parent 1218b224fc
commit df240472a4
3 changed files with 12 additions and 12 deletions

View File

@ -34,7 +34,7 @@ from accounting.report.utils.unapplied import get_accounts_with_unapplied
from accounting.report.utils.urls import unapplied_url from accounting.report.utils.urls import unapplied_url
from accounting.utils.offset_matcher import OffsetMatcher from accounting.utils.offset_matcher import OffsetMatcher
from accounting.utils.pagination import Pagination from accounting.utils.pagination import Pagination
from accounting.utils.permission import can_admin from accounting.utils.permission import can_edit
class CSVRow(BaseCSVRow): class CSVRow(BaseCSVRow):
@ -158,7 +158,7 @@ class UnappliedOriginalLineItems(BaseReport):
= offset_matcher.unapplied = offset_matcher.unapplied
"""The line items.""" """The line items."""
self.__is_mark_matches: bool \ self.__is_mark_matches: bool \
= can_admin() and len(offset_matcher.unmatched_offsets) > 0 = can_edit() and len(offset_matcher.unmatched_offsets) > 0
"""Whether to mark the matched offsets.""" """Whether to mark the matched offsets."""
def csv(self) -> Response: def csv(self) -> Response:

View File

@ -51,6 +51,12 @@ First written: 2023/1/26
{{ A_("Currencies") }} {{ A_("Currencies") }}
</a> </a>
</li> </li>
<li>
<a class="dropdown-item {% if request.endpoint and request.endpoint.startswith("accounting.unmatched-offset.") %} active {% endif %}" href="{{ url_for("accounting.unmatched-offset.dashboard") }}">
<i class="fa-solid fa-link-slash"></i>
{{ A_("Unmatched Offsets") }}
</a>
</li>
{% if accounting_can_admin() %} {% if accounting_can_admin() %}
<li> <li>
<a class="dropdown-item {% if request.endpoint and request.endpoint.startswith("accounting.option.") %} active {% endif %}" href="{{ url_for("accounting.option.detail") }}"> <a class="dropdown-item {% if request.endpoint and request.endpoint.startswith("accounting.option.") %} active {% endif %}" href="{{ url_for("accounting.option.detail") }}">
@ -58,12 +64,6 @@ First written: 2023/1/26
{{ A_("Settings") }} {{ A_("Settings") }}
</a> </a>
</li> </li>
<li>
<a class="dropdown-item {% if request.endpoint and request.endpoint.startswith("accounting.unmatched-offset.") %} active {% endif %}" href="{{ url_for("accounting.unmatched-offset.dashboard") }}">
<i class="fa-solid fa-link-slash"></i>
{{ A_("Unmatched Offsets") }}
</a>
</li>
{% endif %} {% endif %}
</ul> </ul>
</li> </li>

View File

@ -25,7 +25,7 @@ from accounting.models import JournalEntryLineItem, Account
from accounting.utils.cast import s from accounting.utils.cast import s
from accounting.utils.offset_matcher import OffsetMatcher from accounting.utils.offset_matcher import OffsetMatcher
from accounting.utils.pagination import Pagination from accounting.utils.pagination import Pagination
from accounting.utils.permission import has_permission, can_admin from accounting.utils.permission import has_permission, can_edit
from .queries import get_accounts_with_unmatched_offsets from .queries import get_accounts_with_unmatched_offsets
bp: Blueprint = Blueprint("unmatched-offset", __name__) bp: Blueprint = Blueprint("unmatched-offset", __name__)
@ -33,7 +33,7 @@ bp: Blueprint = Blueprint("unmatched-offset", __name__)
@bp.get("", endpoint="dashboard") @bp.get("", endpoint="dashboard")
@has_permission(can_admin) @has_permission(can_edit)
def show_offset_dashboard() -> str: def show_offset_dashboard() -> str:
"""Shows the dashboard about offsets. """Shows the dashboard about offsets.
@ -44,7 +44,7 @@ def show_offset_dashboard() -> str:
@bp.get("<needOffsetAccount:account>", endpoint="list") @bp.get("<needOffsetAccount:account>", endpoint="list")
@has_permission(can_admin) @has_permission(can_edit)
def show_unmatched_offsets(account: Account) -> str: def show_unmatched_offsets(account: Account) -> str:
"""Shows the unmatched offsets in an account. """Shows the unmatched offsets in an account.
@ -60,7 +60,7 @@ def show_unmatched_offsets(account: Account) -> str:
@bp.post("<needOffsetAccount:account>", endpoint="match") @bp.post("<needOffsetAccount:account>", endpoint="match")
@has_permission(can_admin) @has_permission(can_edit)
def match_offsets(account: Account) -> redirect: def match_offsets(account: Account) -> redirect:
"""Matches the original line items with their offsets. """Matches the original line items with their offsets.