Merge pull request #26 from LQDJudge/edit_link

add edit link to authors
This commit is contained in:
Phuoc Dinh Le 2022-10-20 01:06:20 -05:00 committed by GitHub
commit b929964ae6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 562 deletions

View file

@ -1,4 +1,3 @@
from django.conf import settings
from django.db.models import Count, Max, Q from django.db.models import Count, Max, Q
from django.http import Http404 from django.http import Http404
from django.urls import reverse from django.urls import reverse
@ -206,6 +205,21 @@ class PostView(TitleMixin, CommentedDetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(PostView, self).get_context_data(**kwargs) context = super(PostView, self).get_context_data(**kwargs)
context["og_image"] = self.object.og_image context["og_image"] = self.object.og_image
context["valid_user_to_show_edit"] = False
context["valid_org_to_show_edit"] = []
if self.request.profile in self.object.authors.all():
context["valid_user_to_show_edit"] = True
for valid_org_to_show_edit in self.object.organizations.all():
if self.request.profile in valid_org_to_show_edit.admins.all():
context["valid_user_to_show_edit"] = True
if context["valid_user_to_show_edit"]:
for post_org in self.object.organizations.all():
if post_org in self.request.profile.organizations.all():
context["valid_org_to_show_edit"].append(post_org)
return context return context
def get_object(self, queryset=None): def get_object(self, queryset=None):

View file

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: lqdoj2\n" "Project-Id-Version: lqdoj2\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-10-18 07:01+0700\n" "POT-Creation-Date: 2022-10-18 07:19+0700\n"
"PO-Revision-Date: 2021-07-20 03:44\n" "PO-Revision-Date: 2021-07-20 03:44\n"
"Last-Translator: Icyene\n" "Last-Translator: Icyene\n"
"Language-Team: Vietnamese\n" "Language-Team: Vietnamese\n"
@ -2455,16 +2455,16 @@ msgstr "Giới thiệu"
msgid "Custom Checker Sample" msgid "Custom Checker Sample"
msgstr "Hướng dẫn viết trình chấm" msgstr "Hướng dẫn viết trình chấm"
#: judge/views/blog.py:114 #: judge/views/blog.py:110
#, python-format #, python-format
msgid "Page %d of Posts" msgid "Page %d of Posts"
msgstr "Trang %d" msgstr "Trang %d"
#: judge/views/blog.py:169 #: judge/views/blog.py:165
msgid "Ticket feed" msgid "Ticket feed"
msgstr "Báo cáo" msgstr "Báo cáo"
#: judge/views/blog.py:187 #: judge/views/blog.py:183
msgid "Comment feed" msgid "Comment feed"
msgstr "Bình luận" msgstr "Bình luận"
@ -3368,6 +3368,10 @@ msgstr "đã đăng vào %(time)s"
msgid "Edit" msgid "Edit"
msgstr "Chỉnh sửa" msgstr "Chỉnh sửa"
#: templates/blog/blog.html:33
msgid "Edit in"
msgstr "Chỉnh sửa"
#: templates/blog/dashboard.html:21 #: templates/blog/dashboard.html:21
#, python-format #, python-format
msgid "" msgid ""
@ -5528,8 +5532,9 @@ msgstr "Thông tin"
msgid "Check all" msgid "Check all"
msgstr "Chọn tất cả" msgstr "Chọn tất cả"
#~ msgid "Recently visited organizations" #, python-format
#~ msgstr "Các nhóm thăm gần đây" #~ msgid "Edit in %(org_slug)s"
#~ msgstr "Chỉnh sửa trong %(org_slug)s"
#~ msgid "Name and School" #~ msgid "Name and School"
#~ msgstr "Họ tên và Trường" #~ msgstr "Họ tên và Trường"

View file

@ -15,6 +15,9 @@ msgstr "Thành viên"
msgid "Contests" msgid "Contests"
msgstr "Kỳ thi" msgstr "Kỳ thi"
msgid "Chat"
msgstr ""
msgid "Groups" msgid "Groups"
msgstr "Nhóm" msgstr "Nhóm"
@ -24,563 +27,20 @@ msgstr "Giới thiệu"
msgid "Status" msgid "Status"
msgstr "Máy chấm" msgstr "Máy chấm"
msgid "Suggestions" msgid "Simple Math"
msgstr "Đề xuất ý tưởng"
msgid "Proposal"
msgstr "Đề xuất bài tập"
msgid "TanKhoa"
msgstr "Tân Khoa"
msgid "Name"
msgstr "Đăng ký tên"
msgid "Report"
msgstr "Báo cáo"
msgid "2sat"
msgstr ""
msgid "adhoc"
msgstr ""
msgid "aho-corasick"
msgstr ""
msgid "articulation-point"
msgstr ""
msgid "backtrack"
msgstr ""
msgid "bellman-ford"
msgstr ""
msgid "bfs-01"
msgstr ""
msgid "biconnected-component"
msgstr ""
msgid "bignum"
msgstr ""
msgid "binary-lifting"
msgstr ""
msgid "binary-search"
msgstr ""
msgid "binary-search-parallel"
msgstr ""
msgid "bit"
msgstr ""
msgid "bit2d"
msgstr ""
msgid "bitset"
msgstr ""
msgid "bitwise"
msgstr ""
msgid "block-cut-tree"
msgstr ""
msgid "boruvka"
msgstr ""
msgid "branch&bound"
msgstr ""
msgid "bridge"
msgstr ""
msgid "brute force"
msgstr ""
msgid "cactus-graph"
msgstr ""
msgid "casework"
msgstr ""
msgid "centroid"
msgstr ""
msgid "chinese-remainder"
msgstr ""
msgid "combinatorics"
msgstr ""
msgid "constructive"
msgstr ""
msgid "convex-hull"
msgstr ""
msgid "counting"
msgstr ""
msgid "cycle"
msgstr ""
msgid "data structures"
msgstr ""
msgid "deep-optimization"
msgstr ""
msgid "dfs/bfs/pfs"
msgstr ""
msgid "dijkstra"
msgstr ""
msgid "divide and conquer"
msgstr ""
msgid "dp-alien"
msgstr ""
msgid "dp-bitmask"
msgstr ""
msgid "dp-cc"
msgstr ""
msgid "dp-convexhull"
msgstr ""
msgid "dp-count"
msgstr ""
msgid "dp-dag"
msgstr ""
msgid "dp-digit"
msgstr ""
msgid "dp-dnc"
msgstr ""
msgid "dp-general"
msgstr ""
msgid "dp-knuth"
msgstr ""
msgid "dp-matrix"
msgstr ""
msgid "dp-openclose"
msgstr ""
msgid "dp-permutation"
msgstr ""
msgid "dp-slope"
msgstr ""
msgid "dp-sos"
msgstr ""
msgid "dp-swap-label"
msgstr ""
msgid "dp-tree"
msgstr ""
msgid "dsu"
msgstr ""
msgid "dsu-roll-back"
msgstr ""
msgid "dynamic programming"
msgstr ""
msgid "euler-path"
msgstr ""
msgid "euler-theorem"
msgstr ""
msgid "euler-tour"
msgstr ""
msgid "extgcd"
msgstr ""
msgid "Fenwick Tree (Binary Indexed Tree)"
msgstr ""
msgid "fft/ntt"
msgstr ""
msgid "flow-demands"
msgstr ""
msgid "flow-general"
msgstr ""
msgid "flow-mincost"
msgstr ""
msgid "flows"
msgstr ""
msgid "floyd"
msgstr ""
msgid "function-graph"
msgstr ""
msgid "game theory"
msgstr ""
msgid "game-ad-hoc"
msgstr ""
msgid "game-minimax"
msgstr ""
msgid "game-nim"
msgstr ""
msgid "game-sprague-grundy"
msgstr ""
msgid "gauss-elim"
msgstr ""
msgid "genetic"
msgstr ""
msgid "geometry"
msgstr ""
msgid "geometry-general"
msgstr ""
msgid "gomory-hu-tree"
msgstr ""
msgid "graph"
msgstr ""
msgid "graph theory"
msgstr ""
msgid "greedy"
msgstr ""
msgid "greedy-exchange"
msgstr ""
msgid "greedy-general"
msgstr ""
msgid "greedy-moore"
msgstr ""
msgid "hashing"
msgstr ""
msgid "heuristic"
msgstr ""
msgid "hld"
msgstr ""
msgid "HSG"
msgstr ""
msgid "ICPC"
msgstr ""
msgid "implementation"
msgstr "" msgstr ""
msgid "inclusion-exclusion" #~ msgid "Suggestions"
msgstr "" #~ msgstr "Đề xuất ý tưởng"
msgid "interactive"
msgstr ""
msgid "inversive-geometry"
msgstr ""
msgid "kd-tree"
msgstr ""
msgid "kirchoff"
msgstr ""
msgid "kmp"
msgstr ""
msgid "kruskal"
msgstr ""
msgid "lagrange-inter"
msgstr ""
msgid "language"
msgstr ""
msgid "lca"
msgstr ""
msgid "lichao-tree"
msgstr ""
msgid "local-search"
msgstr ""
msgid "ltt" #~ msgid "Proposal"
msgstr "" #~ msgstr "Đề xuất bài tập"
msgid "manacher"
msgstr ""
msgid "matching-bipartie"
msgstr ""
msgid "matching-general"
msgstr ""
msgid "matching-hall"
msgstr ""
msgid "matching-hungarian" #~ msgid "TanKhoa"
msgstr "" #~ msgstr "Tân Khoa"
msgid "matching-konig"
msgstr ""
msgid "math" #~ msgid "Name"
msgstr "" #~ msgstr "Đăng ký tên"
msgid "math-general"
msgstr ""
msgid "matrix multiplication"
msgstr ""
msgid "max-clique"
msgstr ""
msgid "meet-in-the-middle"
msgstr ""
msgid "Miscellaneous"
msgstr ""
msgid "mo-general" #~ msgid "Report"
msgstr "" #~ msgstr "Báo cáo"
msgid "mo-tree"
msgstr ""
msgid "mo-update"
msgstr ""
msgid "mobius"
msgstr ""
msgid "modular"
msgstr ""
msgid "modular-inverse"
msgstr ""
msgid "monotonic-queue"
msgstr ""
msgid "multiplicative"
msgstr ""
msgid "NEW"
msgstr ""
msgid "number theory"
msgstr ""
msgid "offline"
msgstr ""
msgid "order-statistic"
msgstr ""
msgid "output-only"
msgstr ""
msgid "palin-tree"
msgstr ""
msgid "picks-theorem"
msgstr ""
msgid "planar-graph"
msgstr ""
msgid "polygon-triangulation"
msgstr ""
msgid "precision-issue"
msgstr ""
msgid "prefix-sum"
msgstr ""
msgid "primality-test"
msgstr ""
msgid "probability"
msgstr ""
msgid "randomized"
msgstr ""
msgid "Range Queries"
msgstr ""
msgid "recursion"
msgstr ""
msgid "rmq"
msgstr ""
msgid "rmq-2d"
msgstr ""
msgid "rmq2d"
msgstr ""
msgid "scc"
msgstr ""
msgid "scheduling"
msgstr ""
msgid "search"
msgstr ""
msgid "segtree-2d"
msgstr ""
msgid "segtree-beats"
msgstr ""
msgid "segtree-dynamic"
msgstr ""
msgid "segtree-general"
msgstr ""
msgid "segtree-persistent"
msgstr ""
msgid "segtree-walk"
msgstr ""
msgid "sequence"
msgstr ""
msgid "sieve"
msgstr ""
msgid "sieve-segment"
msgstr ""
msgid "small-to-large"
msgstr ""
msgid "sortings"
msgstr ""
msgid "spanning-tree"
msgstr ""
msgid "sparse-table"
msgstr ""
msgid "spfa"
msgstr ""
msgid "sqrt"
msgstr ""
msgid "sqrt-babygiant"
msgstr ""
msgid "sqrt-buckets"
msgstr ""
msgid "sqrt-buffer"
msgstr ""
msgid "sqrt-time"
msgstr ""
msgid "stack-queue"
msgstr ""
msgid "static-data"
msgstr ""
msgid "stl"
msgstr ""
msgid "string"
msgstr ""
msgid "suffix-array"
msgstr ""
msgid "sweep-line"
msgstr ""
msgid "ternary-search"
msgstr ""
msgid "topo-sort"
msgstr ""
msgid "tortoise-hare"
msgstr ""
msgid "treap/splay"
msgstr ""
msgid "Tree - general"
msgstr ""
msgid "tree-isomorphism"
msgstr ""
msgid "trie"
msgstr ""
msgid "TSP"
msgstr ""
msgid "TST"
msgstr ""
msgid "two-pointers"
msgstr ""
msgid "VOI"
msgstr ""
msgid "voronoi"
msgstr ""
msgid "z-function"
msgstr ""

View file

@ -28,6 +28,10 @@
</span> </span>
{% if post.is_editable_by(request.user) %} {% if post.is_editable_by(request.user) %}
<span> [<a href="{{ url('admin:judge_blogpost_change', post.id) }}">{{ _('Edit') }}</a>]</span> <span> [<a href="{{ url('admin:judge_blogpost_change', post.id) }}">{{ _('Edit') }}</a>]</span>
{% elif valid_user_to_show_edit %}
{% for org in valid_org_to_show_edit %}
<span> [<a href="{{ url('edit_organization_blog', org.id , org.slug , post.id) }}">{{ _('Edit in') }} {{org.slug}}</a>]</span>
{% endfor %}
{% endif %} {% endif %}
</div> </div>
<div class="body content-description"> <div class="body content-description">