mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 11:59:23 +00:00
Use group permissions
This commit is contained in:
@ -11,7 +11,7 @@ from ninja_extra.pagination import PageNumberPaginationExtra
|
|||||||
from ninja_extra.schemas import PaginatedResponseSchema
|
from ninja_extra.schemas import PaginatedResponseSchema
|
||||||
|
|
||||||
from club.models import Mailing
|
from club.models import Mailing
|
||||||
from core.auth.api_permissions import CanAccessLookup, CanView, IsOldSubscriber
|
from core.auth.api_permissions import CanAccessLookup, CanView, HasPerm
|
||||||
from core.models import Group, QuickUploadImage, SithFile, User
|
from core.models import Group, QuickUploadImage, SithFile, User
|
||||||
from core.schemas import (
|
from core.schemas import (
|
||||||
FamilyGodfatherSchema,
|
FamilyGodfatherSchema,
|
||||||
@ -44,7 +44,7 @@ class UploadController(ControllerBase):
|
|||||||
422: dict[Literal["detail"], list[dict[str, Any]]],
|
422: dict[Literal["detail"], list[dict[str, Any]]],
|
||||||
403: dict[Literal["detail"], str],
|
403: dict[Literal["detail"], str],
|
||||||
},
|
},
|
||||||
permissions=[IsOldSubscriber],
|
permissions=[HasPerm("core.add_quickuploadimage")],
|
||||||
url_name="quick_upload_image",
|
url_name="quick_upload_image",
|
||||||
)
|
)
|
||||||
def upload_image(self, file: File[UploadedImage]):
|
def upload_image(self, file: File[UploadedImage]):
|
||||||
|
@ -828,6 +828,7 @@ Welcome to the wiki page!
|
|||||||
"view_peoplepicturerelation",
|
"view_peoplepicturerelation",
|
||||||
"add_peoplepicturerelation",
|
"add_peoplepicturerelation",
|
||||||
"add_page",
|
"add_page",
|
||||||
|
"add_quickuploadimage",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1148,15 +1148,15 @@ class QuickUploadImage(models.Model):
|
|||||||
identifier = str(uuid4())
|
identifier = str(uuid4())
|
||||||
name = Path(image.name).stem[: cls.IMAGE_NAME_SIZE - 1]
|
name = Path(image.name).stem[: cls.IMAGE_NAME_SIZE - 1]
|
||||||
file = File(convert_image(image), name=f"{identifier}.webp")
|
file = File(convert_image(image), name=f"{identifier}.webp")
|
||||||
image = Image.open(file)
|
width, height = Image.open(file).size
|
||||||
|
|
||||||
return cls.objects.create(
|
return cls.objects.create(
|
||||||
uuid=identifier,
|
uuid=identifier,
|
||||||
name=name,
|
name=name,
|
||||||
image=file,
|
image=file,
|
||||||
uploader=uploader,
|
uploader=uploader,
|
||||||
width=image.width,
|
width=width,
|
||||||
height=image.height,
|
height=height,
|
||||||
size=file.size,
|
size=file.size,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ const loadEasyMde = (textarea: HTMLTextAreaElement) => {
|
|||||||
.join(" ; "),
|
.join(" ; "),
|
||||||
);
|
);
|
||||||
} else if (response.response.status === 403) {
|
} else if (response.response.status === 403) {
|
||||||
onError(gettext("Not authorized, you need to have subscribed at least once"));
|
onError(gettext("You are not authorized to use this feature"));
|
||||||
} else {
|
} else {
|
||||||
onError(gettext("Could not upload image"));
|
onError(gettext("Could not upload image"));
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2025-04-09 22:12+0200\n"
|
"POT-Creation-Date: 2025-04-09 23:23+0200\n"
|
||||||
"PO-Revision-Date: 2024-09-17 11:54+0200\n"
|
"PO-Revision-Date: 2024-09-17 11:54+0200\n"
|
||||||
"Last-Translator: Sli <antoine@bartuccio.fr>\n"
|
"Last-Translator: Sli <antoine@bartuccio.fr>\n"
|
||||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||||
@ -64,8 +64,8 @@ msgid "No results found"
|
|||||||
msgstr "Aucun résultat trouvé"
|
msgstr "Aucun résultat trouvé"
|
||||||
|
|
||||||
#: core/static/bundled/core/components/easymde-index.ts
|
#: core/static/bundled/core/components/easymde-index.ts
|
||||||
msgid "Not authorized, you need to have subscribed at least once"
|
msgid "You are not authorized to use this feature"
|
||||||
msgstr ""
|
msgstr "Vous n'êtes pas autorisé à utilisé cette fonctionalité"
|
||||||
|
|
||||||
#: core/static/bundled/core/components/easymde-index.ts
|
#: core/static/bundled/core/components/easymde-index.ts
|
||||||
msgid "Could not upload image"
|
msgid "Could not upload image"
|
||||||
|
Reference in New Issue
Block a user