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