fix
This commit is contained in:
parent
b4ca90188b
commit
9a20711820
@ -7,6 +7,7 @@ from Main.models.settask import SetTask
|
||||
from Main.models.subscription import Subscription
|
||||
from Main.models.task import Task
|
||||
from Sprint.settings import CONSTS
|
||||
from SprintLib.language import languages
|
||||
|
||||
|
||||
class UserInfo(models.Model):
|
||||
@ -21,6 +22,16 @@ class UserInfo(models.Model):
|
||||
telegram_chat_id = models.TextField(default="")
|
||||
notification_solution_result = models.BooleanField(default=False)
|
||||
|
||||
@property
|
||||
def has_favourite_language(self):
|
||||
return self.favourite_language_id is not None
|
||||
|
||||
@property
|
||||
def favourite_language(self):
|
||||
if not self.has_favourite_language:
|
||||
return None
|
||||
return languages[self.favourite_language_id]
|
||||
|
||||
def _append_task(self, task, tasks):
|
||||
if task.creator == self.user or task.public or self.user.is_superuser:
|
||||
tasks.append(task)
|
||||
|
@ -1,5 +1,4 @@
|
||||
from django import template
|
||||
|
||||
from Main.models import SetTask, Subscription
|
||||
|
||||
register = template.Library()
|
||||
|
@ -28,7 +28,7 @@ class AccountView(BaseView):
|
||||
return "/account"
|
||||
|
||||
def post_set_language(self):
|
||||
lang_id = self.request.POST["language"]
|
||||
lang_id = int(self.request.POST["language"])
|
||||
self.request.user.userinfo.favourite_language_id = lang_id if lang_id != -1 else None
|
||||
self.request.user.userinfo.save()
|
||||
return "/account"
|
||||
|
@ -1,5 +1,6 @@
|
||||
from typing import Optional
|
||||
|
||||
from django.db import transaction
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render
|
||||
@ -20,6 +21,7 @@ class BaseView:
|
||||
view_file: Optional[str] = None
|
||||
|
||||
@classmethod
|
||||
@transaction.atomic
|
||||
def as_view(cls):
|
||||
def execute(request):
|
||||
if request.user.is_authenticated:
|
||||
|
@ -79,7 +79,7 @@
|
||||
<h2><i class="fa fa-desktop"></i></h2>
|
||||
</td>
|
||||
<td><div style="width: 20px;"></div></td>
|
||||
<td>
|
||||
<td><p style="padding-top: 8px; font-size: 24px;">
|
||||
{% if owner %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
@ -92,13 +92,13 @@
|
||||
</select>
|
||||
</form>
|
||||
{% else %}
|
||||
{% if account.favourite_language_id %}
|
||||
yes
|
||||
{% if account.userinfo.has_favourite_language %}
|
||||
<img src="{{ account.userinfo.favourite_language.logo_url }}" height="24px" width="24px"> {{ account.userinfo.favourite_language.name }}
|
||||
{% else %}
|
||||
no
|
||||
Предпочитаемый язык отсутствует
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</p></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
@ -17,8 +17,11 @@
|
||||
<td style="text-align: center; vertical-align: middle; width: 70px;">
|
||||
{{ u.userinfo.place }}
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<img src="{{ u.userinfo.profile_pic_url }}" width="50px" height="50px" style="border-radius: 50%;">
|
||||
<td style="vertical-align: middle; width: 800px;">
|
||||
<img src="{{ u.userinfo.profile_pic_url }}" width="50px" height="50px" style="border-radius: 50%; margin-right: 10px;">
|
||||
{% if u.userinfo.has_favourite_language %}
|
||||
<img src="{{ u.userinfo.favourite_language.logo_url }}" width="18px" height="18px" style="margin-top: 40px; margin-left: -30px;">
|
||||
{% endif %}
|
||||
<a href="/account?username={{ u.username }}">{{ u.username }}</a>
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
|
Loading…
Reference in New Issue
Block a user