mirror of
https://github.com/ae-utbm/sith.git
synced 2026-11-07 01:39:32 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fef5f519c6 | ||
|
|
c33ec9bff9 |
No files matched your search
+2
-2
@@ -22,7 +22,7 @@ from ninja_extra.pagination import PageNumberPaginationExtra
|
|||||||
from ninja_extra.schemas import PaginatedResponseSchema
|
from ninja_extra.schemas import PaginatedResponseSchema
|
||||||
|
|
||||||
from api.auth import ApiKeyAuth
|
from api.auth import ApiKeyAuth
|
||||||
from api.permissions import CanAccessLookup, CanView, IsInGroup, IsRoot
|
from api.permissions import CanAccessLookup, CanView, HasPerm, IsInGroup, IsRoot
|
||||||
from counter.models import Counter, Product, ProductType
|
from counter.models import Counter, Product, ProductType
|
||||||
from counter.schemas import (
|
from counter.schemas import (
|
||||||
CounterFilterSchema,
|
CounterFilterSchema,
|
||||||
@@ -93,7 +93,7 @@ class ProductController(ControllerBase):
|
|||||||
@route.get(
|
@route.get(
|
||||||
"/search/detailed",
|
"/search/detailed",
|
||||||
response=PaginatedResponseSchema[ProductSchema],
|
response=PaginatedResponseSchema[ProductSchema],
|
||||||
permissions=[IsCounterAdmin],
|
permissions=[HasPerm("counter.view_product")],
|
||||||
url_name="search_products_detailed",
|
url_name="search_products_detailed",
|
||||||
)
|
)
|
||||||
@paginate(PageNumberPaginationExtra, page_size=50)
|
@paginate(PageNumberPaginationExtra, page_size=50)
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if not user.has_perm("counter.change_product") %}
|
||||||
<div class="alert alert-yellow">
|
<div class="alert alert-yellow">
|
||||||
<div class="alert-main">
|
<div class="alert-main">
|
||||||
{%- trans trimmed -%}
|
{%- trans trimmed -%}
|
||||||
@@ -92,6 +93,7 @@
|
|||||||
{%- endtrans -%}
|
{%- endtrans -%}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if object %}
|
{% if object %}
|
||||||
<h2>{{ object }}</h2>
|
<h2>{{ object }}</h2>
|
||||||
<p><i>{% trans %}Creation date{% endtrans %} : {{ object.created_at|date }}</i></p>
|
<p><i>{% trans %}Creation date{% endtrans %} : {{ object.created_at|date }}</i></p>
|
||||||
|
|||||||
@@ -181,6 +181,9 @@ class ProductEditView(CounterAdminTabsMixin, PermissionRequiredMixin, UpdateView
|
|||||||
permission_required = "counter.change_product"
|
permission_required = "counter.change_product"
|
||||||
|
|
||||||
def has_permission(self):
|
def has_permission(self):
|
||||||
|
# If users can see products but not edit them,
|
||||||
|
# still show them this form, as it is the place where all infos are,
|
||||||
|
# but forbid to save it.
|
||||||
return self.request.user.has_perm("counter.change_product") or (
|
return self.request.user.has_perm("counter.change_product") or (
|
||||||
self.request.method == "GET"
|
self.request.method == "GET"
|
||||||
and self.request.user.has_perm("counter.view_product")
|
and self.request.user.has_perm("counter.view_product")
|
||||||
|
|||||||
Reference in new issue
Block a user