Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Review Stages Setting #1204

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
04553f9
Initialize setting review / proposal stage page
alice6373 May 21, 2020
f195f71
Alice fixup with love
alice6373 Jul 18, 2020
69a7f07
Clear gui
alice6373 Sep 27, 2020
7300021
Default timezone sring handling
alice6373 Oct 2, 2020
a036250
rename to Review Stages
alice6373 Oct 4, 2020
81d875e
Generating timezone dynamically with pytz
alice6373 Oct 12, 2020
1397208
Delete comment in review_stages.html
alice6373 Oct 12, 2020
1f485a3
Delete print() in view.py
alice6373 Oct 12, 2020
db36ab6
Update GUI
alice6373 Oct 13, 2020
d867fc2
return value add reviews_state()
alice6373 Oct 26, 2020
65016fa
Rename First Round Review_2 to First Round Review
alice6373 Oct 26, 2020
95d6dc9
Change the typography to vertical
alice6373 Dec 10, 2020
b56946c
Rename First Round Review_1 to Locked (proposal editing and reviewing…
alice6373 Dec 10, 2020
663e433
Enhance user friendliness : accepting pycontw-2020.proposals.disable.…
alice6373 Dec 15, 2020
c2a6d53
Enhance user friendliness : Try more django date format (DATETIME_INP…
alice6373 Dec 15, 2020
cc7fc66
Enhance user friendliness : display current review stage setting
alice6373 Dec 22, 2020
8547598
Enhance user friendliness : automatically load the current settings t…
alice6373 Dec 27, 2020
aaa5034
Move url.py & view.py to more precise folder
alice6373 Dec 27, 2020
0ad9045
Fix problem that current settings will not be loaded after submitting…
alice6373 Dec 28, 2020
f2dd18e
proposals.disabled.after not be required
alice6373 Jan 16, 2021
eef9a46
Remove unnecessary parentheses and harcoded key
tomatoprinx Jun 2, 2024
4fac698
Fix duplicated return() and safeguard current_review_stages_setting f…
tomatoprinx Jul 20, 2024
4e0bcdd
Fix `proposals.disable.after` value rendering in input element
tomatoprinx Jul 20, 2024
d73d206
Update panel font color for user experience
tomatoprinx Jul 20, 2024
007022a
Update message files for translations
tomatoprinx Jul 20, 2024
ef2e045
Fix ruff check errors
tomatoprinx Jul 21, 2024
8b9d274
Fix element id
tomatoprinx Jul 21, 2024
1edd88c
Add test method for configuration_switch
tomatoprinx Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions src/locale/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PyCon TW\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-21 07:48+0800\n"
"POT-Creation-Date: 2024-07-20 15:33+0800\n"
"PO-Revision-Date: 2022-07-11 02:23+0800\n"
"Last-Translator: Tom Chen <[email protected]>\n"
"Language-Team: English (United States) (http://www.transifex.com/pycon-"
Expand Down Expand Up @@ -1563,6 +1563,14 @@ msgstr "Change Password"
msgid "Reviews"
msgstr "Reviews"

#: templates/default/_includes/dashboard_tablist.html:28
#: templates/default/reviews/review_stages.html:16
#: templates/default/reviews/review_stages.html:44
#, fuzzy
#| msgid "Reviews"
msgid "Review Stages"
msgstr "Reviews"

#: templates/default/_includes/nav/dashboard_nav.html:10
msgid "Log out"
msgstr "Log out"
Expand Down Expand Up @@ -1791,6 +1799,7 @@ msgstr "Change Log In Password"

#: templates/default/registration/password_change_form.html:22
#: templates/default/reviews/review_form.html:101
#: templates/default/reviews/review_stages.html:114
msgid "Submit"
msgstr "Submit"

Expand Down Expand Up @@ -2010,6 +2019,18 @@ msgstr "My Previous Reviews"
msgid "Review Proposal"
msgstr "Review Proposal"

#: templates/default/reviews/review_stages.html:23
#, fuzzy
#| msgid "Current Review Stage: %(review_stage)s"
msgid "Current Review Stage Setting"
msgstr "Current Review Stage: %(review_stage)s"

#: templates/default/reviews/review_stages.html:35
#, fuzzy
#| msgid "Personal Review Stats"
msgid "Set Review Stage"
msgstr "Personal Review Stats"

#: templates/default/reviews/talk_proposal_list.html:14
#, python-format
msgid "Current Review Stage: %(review_stage)s"
Expand Down Expand Up @@ -5108,36 +5129,36 @@ msgstr "latest agreed CoC version"
msgid "agreed at"
msgstr "agreed at"

#: users/views.py:44
#: users/views.py:48
msgid "Sign up successful. You are now logged in."
msgstr "Sign up successful. You are now logged in."

#: users/views.py:61
#: users/views.py:65
msgid "Email verification successful."
msgstr "Email verification successful."

#: users/views.py:73
#: users/views.py:77
#, python-brace-format
msgid "A verification email has been sent to {email}"
msgstr "A verification email has been sent to {email}"

#: users/views.py:103
#: users/views.py:107
msgid "Your profile has been updated successfully."
msgstr "Your profile has been updated successfully."

#: users/views.py:116
#: users/views.py:120
msgid "Your new password has been applied successfully."
msgstr "Your new password has been applied successfully."

#: users/views.py:123
#: users/views.py:127
msgid ""
"An email is sent to your email account. Please check your inbox for furthur "
"instructions to reset your password."
msgstr ""
"An email is sent to your email account. Please check your inbox for furthur "
"instructions to reset your password."

#: users/views.py:131
#: users/views.py:135
msgid "Password reset successful. You can now login."
msgstr "Password reset successful. You can now login."

Expand Down
31 changes: 23 additions & 8 deletions src/locale/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PyCon TW\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-21 07:48+0800\n"
"POT-Creation-Date: 2024-07-20 15:33+0800\n"
"PO-Revision-Date: 2022-07-11 02:25+0800\n"
"Last-Translator: Tom Chen <[email protected]>\n"
"Language-Team: Chinese Traditional (http://www.transifex.com/pycon-taiwan/"
Expand Down Expand Up @@ -1516,6 +1516,12 @@ msgstr "更改密碼"
msgid "Reviews"
msgstr "審查"

#: templates/default/_includes/dashboard_tablist.html:28
#: templates/default/reviews/review_stages.html:16
#: templates/default/reviews/review_stages.html:44
msgid "Review Stages"
msgstr "審查階段"

#: templates/default/_includes/nav/dashboard_nav.html:10
msgid "Log out"
msgstr "登出"
Expand Down Expand Up @@ -1739,6 +1745,7 @@ msgstr "更改密碼"

#: templates/default/registration/password_change_form.html:22
#: templates/default/reviews/review_form.html:101
#: templates/default/reviews/review_stages.html:114
msgid "Submit"
msgstr "送出"

Expand Down Expand Up @@ -1952,6 +1959,14 @@ msgstr "我之前的審查意見"
msgid "Review Proposal"
msgstr "審查提案"

#: templates/default/reviews/review_stages.html:23
msgid "Current Review Stage Setting"
msgstr "目前審查階段設定"

#: templates/default/reviews/review_stages.html:35
msgid "Set Review Stage"
msgstr "設定審查階段"

#: templates/default/reviews/talk_proposal_list.html:14
#, python-format
msgid "Current Review Stage: %(review_stage)s"
Expand Down Expand Up @@ -4983,35 +4998,35 @@ msgstr "最後同意的 CoC 版本"
msgid "agreed at"
msgstr "同意於"

#: users/views.py:44
#: users/views.py:48
msgid "Sign up successful. You are now logged in."
msgstr "註冊成功。您現在已被登入。"

#: users/views.py:61
#: users/views.py:65
msgid "Email verification successful."
msgstr "Email 認證成功。"

#: users/views.py:73
#: users/views.py:77
#, python-brace-format
msgid "A verification email has been sent to {email}"
msgstr "一封認證用的 email 已經寄送至 {email}"

#: users/views.py:103
#: users/views.py:107
msgid "Your profile has been updated successfully."
msgstr "您的講者資訊已成功地更新。"

#: users/views.py:116
#: users/views.py:120
msgid "Your new password has been applied successfully."
msgstr "已成功地使用您的新密碼。"

#: users/views.py:123
#: users/views.py:127
msgid ""
"An email is sent to your email account. Please check your inbox for furthur "
"instructions to reset your password."
msgstr ""
"一封電子郵件已經發送至您的信箱。請檢查您的收件匣並參照信中指示重設密碼。"

#: users/views.py:131
#: users/views.py:135
msgid "Password reset successful. You can now login."
msgstr "密碼重設成功。您現在即可登入。"

Expand Down
8 changes: 7 additions & 1 deletion src/proposals/templatetags/proposals.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.template import Library

from proposals.utils import SEP_DEFAULT, SEP_LAST, format_names
Expand All @@ -7,6 +8,11 @@

@register.filter
def speaker_names_display(
proposal, sep_default=SEP_DEFAULT, sep_last=SEP_LAST):
proposal, sep_default=SEP_DEFAULT, sep_last=SEP_LAST):
names = [info.user.speaker_name for info in proposal.speakers]
return format_names(names, sep_default=sep_default, sep_last=sep_last)


@register.filter
def configuration_switch(value):
return settings.CONFERENCE_DEFAULT_SLUG + value
31 changes: 31 additions & 0 deletions src/proposals/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,34 @@ def test_speaker_names_display(talk_proposals, parser):
</ul>
""")
assert actual == expected

@pytest.fixture
def review_stage_keys():
review_stage_keys = [
'.proposals.creatable', '.proposals.editable', '.proposals.withdrawable',
'.reviews.visible.to.submitters', '.reviews.stage',
'.proposals.disable.after'
]
return review_stage_keys

def test_configuration_switch(review_stage_keys, parser):
result = render_template(
'{% load proposals %}'
'<ul>'
'{% for review_stage_key in proposals %}'
'<li>{{ review_stage_key|configuration_switch }}</li>'
'{% endfor %}'
'</ul>', {'proposals': review_stage_keys},
)
actual = parser.arrange(parser.parse(text=result, create_parent=False))
expected = parser.arrange("""
<ul>
<li>pycontw-2021.proposals.creatable</li>
<li>pycontw-2021.proposals.editable</li>
<li>pycontw-2021.proposals.withdrawable</li>
<li>pycontw-2021.reviews.visible.to.submitters</li>
<li>pycontw-2021.reviews.stage</li>
<li>pycontw-2021.proposals.disable.after</li>
</ul>
""")
assert actual == expected
2 changes: 2 additions & 0 deletions src/reviews/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.conf.urls import url

from . import views
from .views import ReviewEditView, TalkProposalListView

urlpatterns = [
url(r'^$', TalkProposalListView.as_view(), name='review_proposal_list'),
url(r'^talk/(?P<proposal_pk>\d+)/$',
ReviewEditView.as_view(), name='review_edit'),
url(r'^review-stages/$', views.review_stages, name='review_stages'),
]
89 changes: 84 additions & 5 deletions src/reviews/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import collections
import datetime
import json
import random

import pytz
from django.conf import settings
from django.conf.global_settings import DATETIME_INPUT_FORMATS
from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.db.models import Count
from django.http import Http404
from django.shortcuts import render
from django.urls import reverse
from django.views.generic import ListView, UpdateView
from registry.helper import reg

from core.utils import SequenceQuerySet
from proposals.models import TalkProposal
Expand All @@ -26,7 +33,6 @@ def dispatch(self, request, *args, **kwargs):


class TalkProposalListView(ReviewableMixin, PermissionRequiredMixin, ListView):

model = TalkProposal
permission_required = REVIEW_REQUIRED_PERMISSIONS
template_name = 'reviews/talk_proposal_list.html'
Expand Down Expand Up @@ -170,9 +176,9 @@ def get_stage_1_reviews(self):
review__stage=1,
review__reviewer=self.request.user
) & TalkProposal.objects.filter(
review__stage=2,
review__reviewer=self.request.user
)
review__stage=2,
review__reviewer=self.request.user
)
)
stage_1_reviews = (
Review.objects
Expand Down Expand Up @@ -200,7 +206,6 @@ def get_stage_2_reviews(self):


class ReviewEditView(ReviewableMixin, PermissionRequiredMixin, UpdateView):

form_class = ReviewForm
permission_required = REVIEW_REQUIRED_PERMISSIONS
template_name = 'reviews/review_form.html'
Expand Down Expand Up @@ -327,3 +332,77 @@ def get_success_url(self):
if query_string:
return url + '?' + query_string
return url


def review_stages(request):
current_review_stages_setting = {}
review_stages_list = [
'Call for Proposals',
'Locked (proposal editing and reviewing disabled)',
'First Round Review', 'Modification Stage', 'Second Round Review',
'Internal Decision', 'Announcement of Acceptance'
]
review_stages_var = [
'proposals.creatable', 'proposals.editable', 'proposals.withdrawable',
'reviews.visible.to.submitters', 'reviews.stage',
'proposals.disable.after'
]

# Initialize current setting with existing value
for tag in review_stages_var:
key = settings.CONFERENCE_DEFAULT_SLUG + '.' + tag
value = reg.get(key, '')
update_current_review_stages_setting(tag, value, current_review_stages_setting)

if request.method == 'POST':
for tag in review_stages_var:
key = settings.CONFERENCE_DEFAULT_SLUG + '.' + tag
if tag == 'proposals.disable.after':
if request.POST[tag] == "":
continue
else:
date_time_obj = date_preprocess(DATETIME_INPUT_FORMATS, request.POST[tag])
if date_time_obj is None:
messages.error(request, 'Please input valid date format : " + "%Y-%m-%dT%H:%M')
value = None
else:
tz_selectd = pytz.timezone(request.POST['review_timezone'])
loc_dt = tz_selectd.localize(date_time_obj).strftime(
'%Y-%m-%d %H:%M:%S%z')
value = loc_dt
elif tag == 'reviews.stage':
value = int(request.POST[tag])
else:
value = request.POST[tag]
reg[key] = value
update_current_review_stages_setting(tag, value, current_review_stages_setting)

messages.info(request, 'This setting has been changed successfully.')

return render(
request, 'reviews/review_stages.html', {
'timezones': pytz.common_timezones,
'review_stages_list': review_stages_list,
'current_review_stages_setting': current_review_stages_setting,
**reviews_state()._asdict()
})


def update_current_review_stages_setting(tag, value, current_review_stages_setting):
# Django template language does not support dictionary keys containing "."
if "." in tag:
tag = tag.replace(".", "_")
current_review_stages_setting[tag] = value


def date_preprocess(datetime_input_format, value):
# Add defined datetime formatx
datetime_input_format += ['%Y-%m-%dT%H:%M:%S', '%Y-%m-%dT%H:%M']
value = value.strip()
# Try to strptime against each input format.
for format in datetime_input_format:
try:
return datetime.datetime.strptime(value, format)
except (ValueError, TypeError):
continue
return None
Loading