Fix recently visited organization
This commit is contained in:
parent
512bc92116
commit
87eb082a18
6 changed files with 104 additions and 85 deletions
|
@ -39,7 +39,7 @@ from judge.models.problem_data import (
|
|||
problem_data_storage,
|
||||
problem_directory_file,
|
||||
)
|
||||
from judge.models.profile import Organization, OrganizationRequest, Profile, Friend
|
||||
from judge.models.profile import Organization, OrganizationRequest, Profile, Friend, OrganizationProfile
|
||||
from judge.models.runtime import Judge, Language, RuntimeVersion
|
||||
from judge.models.submission import (
|
||||
SUBMISSION_RESULT,
|
||||
|
|
|
@ -9,7 +9,6 @@ from django.urls import reverse
|
|||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from requests import delete
|
||||
from fernet_fields import EncryptedCharField
|
||||
from sortedm2m.fields import SortedManyToManyField
|
||||
|
||||
|
@ -438,35 +437,24 @@ class OrganizationProfile(models.Model):
|
|||
verbose_name=_("organization"),
|
||||
related_name="last_vist",
|
||||
on_delete=models.CASCADE,
|
||||
db_index=True,
|
||||
)
|
||||
last_visit = models.AutoField(
|
||||
verbose_name=_("last visit"),
|
||||
verbose_name=_("last visit"),
|
||||
primary_key=True,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def is_organization(self, users, organization):
|
||||
return (
|
||||
self.objects.filter(users=users)
|
||||
.filter(organization=organization)
|
||||
.exists()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def remove_organization(self, users, organization):
|
||||
organizationprofile = self.objects.filter(users=users).filter(
|
||||
organization=organization
|
||||
)
|
||||
organizationprofile.delete()
|
||||
organizationprofile = self.objects.filter(users=users, organization=organization)
|
||||
if organizationprofile.exists():
|
||||
organizationprofile.delete()
|
||||
|
||||
@classmethod
|
||||
def add_organization(self, users, organization):
|
||||
if self.is_organization(users, organization):
|
||||
self.remove_organization(users, organization)
|
||||
self.remove_organization(users, organization)
|
||||
new_organization = OrganizationProfile(users=users, organization=organization)
|
||||
new_organization.save()
|
||||
|
||||
@classmethod
|
||||
def get_organization(self, users):
|
||||
def get_most_recent_organizations(self, users):
|
||||
return self.objects.filter(users=users).order_by("-last_visit")[:5]
|
||||
|
|
|
@ -80,7 +80,7 @@ class FeedView(ListView):
|
|||
start_time__lte=now, end_time__gt=now
|
||||
)
|
||||
context["future_contests"] = visible_contests.filter(start_time__gt=now)
|
||||
context["recent_organizations"] = OrganizationProfile.get_organization(self.request.profile)
|
||||
context["recent_organizations"] = OrganizationProfile.get_most_recent_organizations(self.request.profile)
|
||||
context["top_rated"] = Profile.objects.filter(is_unlisted=False).order_by(
|
||||
"-rating"
|
||||
)[:10]
|
||||
|
|
|
@ -35,7 +35,6 @@ from django.views.generic.detail import (
|
|||
SingleObjectTemplateResponseMixin,
|
||||
)
|
||||
from django.core.paginator import Paginator
|
||||
from judge.models.profile import OrganizationProfile
|
||||
from reversion import revisions
|
||||
|
||||
from judge.forms import (
|
||||
|
@ -58,6 +57,7 @@ from judge.models import (
|
|||
Contest,
|
||||
Notification,
|
||||
ContestProblem,
|
||||
OrganizationProfile,
|
||||
)
|
||||
from judge import event_poster as event
|
||||
from judge.utils.ranker import ranker
|
||||
|
|
|
@ -2,7 +2,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: lqdoj2\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-10-16 00:26+0700\n"
|
||||
"POT-Creation-Date: 2022-10-18 05:05+0700\n"
|
||||
"PO-Revision-Date: 2021-07-20 03:44\n"
|
||||
"Last-Translator: Icyene\n"
|
||||
"Language-Team: Vietnamese\n"
|
||||
|
@ -21,6 +21,7 @@ msgstr ""
|
|||
#: chat_box/models.py:31 chat_box/models.py:52 chat_box/models.py:63
|
||||
#: judge/admin/interface.py:150 judge/models/contest.py:622
|
||||
#: judge/models/contest.py:815 judge/models/profile.py:354
|
||||
#: judge/models/profile.py:430
|
||||
msgid "user"
|
||||
msgstr "người dùng"
|
||||
|
||||
|
@ -474,7 +475,7 @@ msgstr "Đăng ký để nhận thông báo về các kỳ thi"
|
|||
msgid "Enable experimental features"
|
||||
msgstr "Sử dụng các tính năng thử nghiệm"
|
||||
|
||||
#: judge/forms.py:108 judge/views/organization.py:513
|
||||
#: judge/forms.py:108 judge/views/organization.py:514
|
||||
#: judge/views/register.py:68
|
||||
#, python-brace-format
|
||||
msgid "You may not be part of more than {count} public groups."
|
||||
|
@ -1765,7 +1766,7 @@ msgid ""
|
|||
msgstr "Ảnh này sẽ thay thế logo mặc định khi ở trong tổ chức."
|
||||
|
||||
#: judge/models/profile.py:125 judge/models/profile.py:154
|
||||
#: judge/models/profile.py:360
|
||||
#: judge/models/profile.py:360 judge/models/profile.py:437
|
||||
msgid "organization"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1899,6 +1900,12 @@ msgstr "đơn đăng ký tham gia"
|
|||
msgid "organization join requests"
|
||||
msgstr "đơn đăng ký tham gia"
|
||||
|
||||
#: judge/models/profile.py:442
|
||||
#, fuzzy
|
||||
#| msgid "last seen"
|
||||
msgid "last visit"
|
||||
msgstr "xem lần cuối"
|
||||
|
||||
#: judge/models/runtime.py:21
|
||||
msgid "short identifier"
|
||||
msgstr "tên ngắn"
|
||||
|
@ -2448,16 +2455,16 @@ msgstr "Giới thiệu"
|
|||
msgid "Custom Checker Sample"
|
||||
msgstr "Hướng dẫn viết trình chấm"
|
||||
|
||||
#: judge/views/blog.py:111
|
||||
#: judge/views/blog.py:114
|
||||
#, python-format
|
||||
msgid "Page %d of Posts"
|
||||
msgstr "Trang %d"
|
||||
|
||||
#: judge/views/blog.py:166
|
||||
#: judge/views/blog.py:169
|
||||
msgid "Ticket feed"
|
||||
msgstr "Báo cáo"
|
||||
|
||||
#: judge/views/blog.py:184
|
||||
#: judge/views/blog.py:187
|
||||
msgid "Comment feed"
|
||||
msgstr "Bình luận"
|
||||
|
||||
|
@ -2473,8 +2480,8 @@ msgstr "Bạn phải giải ít nhất 1 bài trước khi được vote."
|
|||
msgid "You already voted."
|
||||
msgstr "Bạn đã vote."
|
||||
|
||||
#: judge/views/comment.py:155 judge/views/organization.py:813
|
||||
#: judge/views/organization.py:959 judge/views/organization.py:1124
|
||||
#: judge/views/comment.py:155 judge/views/organization.py:814
|
||||
#: judge/views/organization.py:960 judge/views/organization.py:1125
|
||||
msgid "Edited from site"
|
||||
msgstr "Chỉnh sửa từ web"
|
||||
|
||||
|
@ -2652,91 +2659,91 @@ msgstr "Runtimes"
|
|||
msgid "Notifications (%d unseen)"
|
||||
msgstr "Thông báo (%d chưa xem)"
|
||||
|
||||
#: judge/views/organization.py:140 judge/views/organization.py:146
|
||||
#: judge/views/organization.py:142 judge/views/organization.py:148
|
||||
msgid "No such organization"
|
||||
msgstr "Không có tổ chức như vậy"
|
||||
|
||||
#: judge/views/organization.py:141
|
||||
#: judge/views/organization.py:143
|
||||
#, python-format
|
||||
msgid "Could not find an organization with the key \"%s\"."
|
||||
msgstr "Không tìm thấy tổ chức với mã \"%s\"."
|
||||
|
||||
#: judge/views/organization.py:147
|
||||
#: judge/views/organization.py:149
|
||||
msgid "Could not find such organization."
|
||||
msgstr ""
|
||||
|
||||
#: judge/views/organization.py:165
|
||||
#: judge/views/organization.py:167
|
||||
msgid "Can't edit organization"
|
||||
msgstr "Không thể chỉnh sửa tổ chức"
|
||||
|
||||
#: judge/views/organization.py:166
|
||||
#: judge/views/organization.py:168
|
||||
msgid "You are not allowed to edit this organization."
|
||||
msgstr "Bạn không được phép chỉnh sửa tổ chức này."
|
||||
|
||||
#: judge/views/organization.py:178 judge/views/organization.py:323
|
||||
#: judge/views/organization.py:180 judge/views/organization.py:324
|
||||
#, fuzzy
|
||||
#| msgid "Can't edit organization"
|
||||
msgid "Can't access organization"
|
||||
msgstr "Không thể chỉnh sửa tổ chức"
|
||||
|
||||
#: judge/views/organization.py:179 judge/views/organization.py:324
|
||||
#: judge/views/organization.py:181 judge/views/organization.py:325
|
||||
msgid "You are not allowed to access this organization."
|
||||
msgstr "Bạn không được phép chỉnh sửa tổ chức này."
|
||||
|
||||
#: judge/views/organization.py:237 judge/views/register.py:49
|
||||
#: judge/views/organization.py:239 judge/views/register.py:49
|
||||
#: judge/views/stats.py:184 templates/contest/list.html:87
|
||||
#: templates/problem/list-base.html:104 templates/stats/site.html:33
|
||||
#: templates/user/user-left-sidebar.html:4 templates/user/user-list-tabs.html:6
|
||||
msgid "Groups"
|
||||
msgstr "Nhóm"
|
||||
|
||||
#: judge/views/organization.py:330
|
||||
#: judge/views/organization.py:331
|
||||
#, python-format
|
||||
msgid "%s Members"
|
||||
msgstr "%s Thành viên"
|
||||
|
||||
#: judge/views/organization.py:469
|
||||
#: judge/views/organization.py:470
|
||||
#, python-brace-format
|
||||
msgid "All submissions in <a href=\"{1}\">{0}</a>"
|
||||
msgstr "Bài nộp trong <a href=\"{1}\">{0}</a>"
|
||||
|
||||
#: judge/views/organization.py:499 judge/views/organization.py:505
|
||||
#: judge/views/organization.py:512
|
||||
#: judge/views/organization.py:500 judge/views/organization.py:506
|
||||
#: judge/views/organization.py:513
|
||||
msgid "Joining group"
|
||||
msgstr "Tham gia nhóm"
|
||||
|
||||
#: judge/views/organization.py:500
|
||||
#: judge/views/organization.py:501
|
||||
msgid "You are already in the group."
|
||||
msgstr "Bạn đã ở trong nhóm."
|
||||
|
||||
#: judge/views/organization.py:505
|
||||
#: judge/views/organization.py:506
|
||||
msgid "This group is not open."
|
||||
msgstr "Nhóm này là nhóm kín."
|
||||
|
||||
#: judge/views/organization.py:528
|
||||
#: judge/views/organization.py:529
|
||||
msgid "Leaving group"
|
||||
msgstr "Rời nhóm"
|
||||
|
||||
#: judge/views/organization.py:529
|
||||
#: judge/views/organization.py:530
|
||||
#, python-format
|
||||
msgid "You are not in \"%s\"."
|
||||
msgstr "Bạn không ở trong \"%s\"."
|
||||
|
||||
#: judge/views/organization.py:554
|
||||
#: judge/views/organization.py:555
|
||||
#, python-format
|
||||
msgid "Request to join %s"
|
||||
msgstr "Đăng ký tham gia %s"
|
||||
|
||||
#: judge/views/organization.py:585
|
||||
#: judge/views/organization.py:586
|
||||
msgid "Join request detail"
|
||||
msgstr "Chi tiết đơn đăng ký"
|
||||
|
||||
#: judge/views/organization.py:633
|
||||
#: judge/views/organization.py:634
|
||||
#, python-format
|
||||
msgid "Managing join requests for %s"
|
||||
msgstr "Quản lý đơn đăng ký cho %s"
|
||||
|
||||
#: judge/views/organization.py:673
|
||||
#: judge/views/organization.py:674
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Your organization can only receive %d more members. You cannot approve %d "
|
||||
|
@ -2745,96 +2752,96 @@ msgstr ""
|
|||
"Tổ chức chỉ có thể chứa %d thành viên. Bạn không thể chấp thuận nhiều hơn %d "
|
||||
"người."
|
||||
|
||||
#: judge/views/organization.py:691
|
||||
#: judge/views/organization.py:692
|
||||
#, python-format
|
||||
msgid "Approved %d user."
|
||||
msgid_plural "Approved %d users."
|
||||
msgstr[0] "Đã chấp thuận %d người."
|
||||
|
||||
#: judge/views/organization.py:694
|
||||
#: judge/views/organization.py:695
|
||||
#, python-format
|
||||
msgid "Rejected %d user."
|
||||
msgid_plural "Rejected %d users."
|
||||
msgstr[0] "Đã từ chối %d người."
|
||||
|
||||
#: judge/views/organization.py:734
|
||||
#: judge/views/organization.py:735
|
||||
#, python-format
|
||||
msgid "Add member for %s"
|
||||
msgstr "Thêm thành viên cho %s"
|
||||
|
||||
#: judge/views/organization.py:746
|
||||
#: judge/views/organization.py:747
|
||||
#, fuzzy
|
||||
#| msgid "Edited from site"
|
||||
msgid "Added members from site"
|
||||
msgstr "Chỉnh sửa từ web"
|
||||
|
||||
#: judge/views/organization.py:766 judge/views/organization.py:774
|
||||
#: judge/views/organization.py:767 judge/views/organization.py:775
|
||||
msgid "Can't kick user"
|
||||
msgstr "Không thể đuổi"
|
||||
|
||||
#: judge/views/organization.py:767
|
||||
#: judge/views/organization.py:768
|
||||
msgid "The user you are trying to kick does not exist!"
|
||||
msgstr ""
|
||||
|
||||
#: judge/views/organization.py:775
|
||||
#: judge/views/organization.py:776
|
||||
#, python-format
|
||||
msgid "The user you are trying to kick is not in organization: %s."
|
||||
msgstr ""
|
||||
|
||||
#: judge/views/organization.py:796 judge/views/organization.py:948
|
||||
#: judge/views/organization.py:797 judge/views/organization.py:949
|
||||
#, fuzzy, python-format
|
||||
#| msgid "Editing %s"
|
||||
msgid "Edit %s"
|
||||
msgstr "Đang chỉnh sửa %s"
|
||||
|
||||
#: judge/views/organization.py:824 templates/organization/list.html:59
|
||||
#: judge/views/organization.py:825 templates/organization/list.html:59
|
||||
msgid "Create group"
|
||||
msgstr "Tạo nhóm"
|
||||
|
||||
#: judge/views/organization.py:839
|
||||
#: judge/views/organization.py:840
|
||||
msgid "Exceeded limit"
|
||||
msgstr ""
|
||||
|
||||
#: judge/views/organization.py:840
|
||||
#: judge/views/organization.py:841
|
||||
#, python-format
|
||||
msgid "You created too many groups. You can only create at most %d groups"
|
||||
msgstr ""
|
||||
|
||||
#: judge/views/organization.py:845 judge/views/organization.py:870
|
||||
#: judge/views/organization.py:1014
|
||||
#: judge/views/organization.py:846 judge/views/organization.py:871
|
||||
#: judge/views/organization.py:1015
|
||||
msgid "Added from site"
|
||||
msgstr "Thêm từ web"
|
||||
|
||||
#: judge/views/organization.py:861
|
||||
#: judge/views/organization.py:862
|
||||
#: templates/organization/org-right-sidebar.html:55
|
||||
msgid "Add contest"
|
||||
msgstr "Thêm kỳ thi"
|
||||
|
||||
#: judge/views/organization.py:904 judge/views/organization.py:1066
|
||||
#: judge/views/organization.py:905 judge/views/organization.py:1067
|
||||
msgid "Permission denied"
|
||||
msgstr "Truy cập bị từ chối"
|
||||
|
||||
#: judge/views/organization.py:905
|
||||
#: judge/views/organization.py:906
|
||||
#, fuzzy
|
||||
#| msgid "You are not allowed to edit this organization."
|
||||
msgid "You are not allowed to edit this contest"
|
||||
msgstr "Bạn không được phép chỉnh sửa tổ chức này."
|
||||
|
||||
#: judge/views/organization.py:1003
|
||||
#: judge/views/organization.py:1004
|
||||
#, python-format
|
||||
msgid "Add blog for %s"
|
||||
msgstr "Thêm bài đăng cho %s"
|
||||
|
||||
#: judge/views/organization.py:1067
|
||||
#: judge/views/organization.py:1068
|
||||
msgid "Not allowed to edit this blog"
|
||||
msgstr "Bạn không được phép chỉnh sửa bài đăng này."
|
||||
|
||||
#: judge/views/organization.py:1099
|
||||
#: judge/views/organization.py:1100
|
||||
#, python-format
|
||||
msgid "Edit blog %s"
|
||||
msgstr "Chỉnh sửa %s"
|
||||
|
||||
#: judge/views/organization.py:1150
|
||||
#: judge/views/organization.py:1151
|
||||
#, python-format
|
||||
msgid "Pending blogs in %s"
|
||||
msgstr "Bài đang đợi duyệt trong %s"
|
||||
|
@ -4738,6 +4745,10 @@ msgstr "Không có máy chấm có thể chấm bài này."
|
|||
msgid "Submit!"
|
||||
msgstr "Nộp bài!"
|
||||
|
||||
#: templates/recent-organization.html:30
|
||||
msgid "Recently visited organizations"
|
||||
msgstr "Các nhóm thăm gần đây"
|
||||
|
||||
#: templates/registration/activate.html:3
|
||||
#, python-format
|
||||
msgid "%(key)s is an invalid activation key."
|
||||
|
|
|
@ -1,20 +1,40 @@
|
|||
{% block two_col_media %}
|
||||
<style>
|
||||
.organization-row {
|
||||
display: block;
|
||||
padding: 0.5em;
|
||||
border-bottom: 1px gray solid;
|
||||
border-top: none;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
}
|
||||
.organization-row:hover {
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
.org-logo {
|
||||
vertical-align: middle;
|
||||
height: 2em;
|
||||
width: 2em;
|
||||
display: inline-block;
|
||||
margin-right: 0.5em;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
.toggle {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% if recent_organizations %}
|
||||
<div class="blog-sidebox sidebox">
|
||||
<h3>{{ _('Recent Organization') }} <i class="fa fa-trophy"></i></h3>
|
||||
<div class="sidebox-content" style="padding: 0; border: 0">
|
||||
<table class="table feed-table">
|
||||
<tbody>
|
||||
{% for organization in recent_organizations %}
|
||||
<tr>
|
||||
<td style="padding: 7px 2px">
|
||||
<a href="{{ url('organization_home', organization.organization.pk, organization.organization.slug) }}">
|
||||
<b> {{organization.organization}} </b>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<h3>{{ _('Recently visited organizations') }} <i class="fa fa-users"></i></h3>
|
||||
<div class="organization-container toggled">
|
||||
{% for organization in recent_organizations %}
|
||||
<a href="{{ url('organization_home', organization.organization.pk, organization.organization.slug) }}" class="sidebox-content organization-row" title="{{organization.organization.about}}">
|
||||
<img class="org-logo" src="{{ organization.organization.logo_override_image or static('icons/icon.png') }}">
|
||||
<span>{{ organization.organization }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
Loading…
Reference in a new issue