NP-8 Возможность создавать новую страницу
This commit is contained in:
@@ -76,13 +76,16 @@ class ItemData(models.Model):
|
||||
|
||||
@property
|
||||
def dict(self) -> typing.Dict[str, typing.Union[str, int, float, None]]:
|
||||
preview = self.preview or self.image
|
||||
if preview:
|
||||
preview = preview.url
|
||||
return {
|
||||
"id": self.id,
|
||||
"title": self.title,
|
||||
"image": None if not self.image else self.image.url,
|
||||
"description": self.description,
|
||||
"shortDescription": self.short_description,
|
||||
"preview": None if not self.preview else self.preview.url,
|
||||
"preview": preview,
|
||||
"createdAt": self.created_at.timestamp(),
|
||||
"updatedAt": self.updated_at.timestamp(),
|
||||
}
|
||||
@@ -109,10 +112,13 @@ class ItemData(models.Model):
|
||||
|
||||
@property
|
||||
def card_dict(self) -> typing.Dict[str, typing.Union[str, int, float, None]]:
|
||||
preview = self.preview or self.image or None
|
||||
if preview:
|
||||
preview = preview.url
|
||||
return {
|
||||
"id": self.id,
|
||||
"title": self.title,
|
||||
"preview": None if not self.preview else self.preview.url
|
||||
"preview": preview
|
||||
}
|
||||
|
||||
@property
|
||||
|
||||
@@ -79,7 +79,7 @@ def update_item(request):
|
||||
return NovelPlusHttpExceptionResponse(request, "Такого объекта не существует", status=403)
|
||||
|
||||
try:
|
||||
if not (user.id == int(data['author'][0]) == item.author.id):
|
||||
if not (user.id == int(data['author'][0]) == item.author.id or user.is_staff):
|
||||
return NovelPlusHttpExceptionResponse(request, "Вы не имеете право на эту операцию", status=403)
|
||||
except KeyError:
|
||||
return NovelPlusHttpExceptionResponse(request, "Вы не имеете право на эту операцию", status=403)
|
||||
|
||||
Submodule frontend/NovelPlus-frontend updated: 4bb343af06...7b12f197d9
2
frontend/static/frontend/css/main.908d9b15.css
Normal file
2
frontend/static/frontend/css/main.908d9b15.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -31,8 +31,8 @@
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="{% static '/misc/icon.ico' %}">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script defer="defer" src="{% static 'frontend/js/main.5dace672.js' %}"></script>
|
||||
<link rel="stylesheet" href="{% static 'frontend/css/main.a07a29e0.css' %}">
|
||||
<script defer="defer" src="{% static 'frontend/js/main.11488baa.js' %}"></script>
|
||||
<link rel="stylesheet" href="{% static 'frontend/css/main.908d9b15.css' %}">
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
||||
@@ -131,6 +131,12 @@ def update_profile(request):
|
||||
data = get_request_data(request)
|
||||
user: User = request.user
|
||||
|
||||
if user.is_staff:
|
||||
try:
|
||||
user = User.objects.get(id=data['id'][0])
|
||||
except User.DoesNotExist:
|
||||
return NovelPlusHttpExceptionResponse(request, "Пользователь не найден", status=403)
|
||||
|
||||
try:
|
||||
if user.id != int(data['id'][0]):
|
||||
return NovelPlusHttpExceptionResponse(request, "Вы не имеете право на эту операцию", status=403)
|
||||
|
||||
Reference in New Issue
Block a user