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

Initialize setting review / proposal stage page #782

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1497d90
Initialize setting review / proposal stage page
alice6373 May 21, 2020
f3095e6
Alice fixup with love
alice6373 Jul 18, 2020
8bb98fb
Merge branch 'master' into page-for-setting-review-stage
alice6373 Aug 30, 2020
57d036c
Clear gui
alice6373 Sep 27, 2020
e3fcda2
Merge branch 'master' into page-for-setting-review-stage
alice6373 Sep 27, 2020
2881ea9
Default timezone sring handling
alice6373 Oct 2, 2020
db4fea7
rename to Review Stages
alice6373 Oct 4, 2020
6ef2f5b
Generating timezone dynamically with pytz
alice6373 Oct 12, 2020
211bf3c
Delete comment in review_stages.html
alice6373 Oct 12, 2020
048c941
Delete print() in view.py
alice6373 Oct 12, 2020
76c39dc
Merge branch 'master' into page-for-setting-review-stage
alice6373 Oct 12, 2020
fdd09ab
Update GUI
alice6373 Oct 13, 2020
8ade9c1
return value add reviews_state()
alice6373 Oct 26, 2020
cfb5fa1
Rename First Round Review_2 to First Round Review
alice6373 Oct 26, 2020
afaf6d5
Change the typography to vertical
alice6373 Dec 10, 2020
88ee598
Rename First Round Review_1 to Locked (proposal editing and reviewing…
alice6373 Dec 10, 2020
9ef909e
Enhance user friendliness : accepting pycontw-2020.proposals.disable.…
alice6373 Dec 15, 2020
d579e69
Enhance user friendliness : Try more django date format (DATETIME_INP…
alice6373 Dec 15, 2020
2fb312d
Enhance user friendliness : display current review stage setting
alice6373 Dec 22, 2020
500b9db
Enhance user friendliness : automatically load the current settings t…
alice6373 Dec 27, 2020
ced5b07
Move url.py & view.py to more precise folder
alice6373 Dec 27, 2020
928e2d1
Fix problem that current settings will not be loaded after submitting…
alice6373 Dec 28, 2020
32f30a1
Merge branch 'master' into page-for-setting-review-stage
alice6373 Jan 16, 2021
c4ef31e
proposals.disabled.after not be required
alice6373 Jan 16, 2021
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
18 changes: 18 additions & 0 deletions src/locale/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,24 @@ msgstr "更改密碼"
msgid "Reviews"
msgstr "審查"

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

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

#: templates/default/_includes/dashboard_tablist.html:28
#: templates/default/reviews/review_stages.html:12
#: templates/default/reviews/review_stages.html:18
msgid "Set Review Stage"
msgstr "設定審查階段"

#: templates/default/_includes/nav/dashboard_nav.html:10
msgid "Log out"
msgstr "登出"
Expand Down
7 changes: 6 additions & 1 deletion src/proposals/templatetags/proposals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.template import Library

from django.conf import settings
from proposals.utils import SEP_DEFAULT, SEP_LAST, format_names


Expand All @@ -11,3 +11,8 @@ def speaker_names_display(
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
6 changes: 4 additions & 2 deletions src/reviews/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from django.conf.urls import url

from .views import ReviewEditView, TalkProposalListView

from . import views

urlpatterns = [
url(r'^$', TalkProposalListView.as_view(), name='review_proposal_list'),
url(r'^talk/(?P<proposal_pk>\d+)/$',
ReviewEditView.as_view(), name='review_edit'),
ReviewEditView.as_view(),
name='review_edit'),
url(r'^review-stages/$', views.review_stages, name='review_stages'),
]
87 changes: 87 additions & 0 deletions src/reviews/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import random

from django.conf import settings
from django.conf.global_settings import DATETIME_INPUT_FORMATS
from django.core.exceptions import ValidationError
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib import messages
from django.urls import reverse
from django.db.models import Count
from django.http import Http404
from django.shortcuts import redirect, render
from django.views.generic import ListView, UpdateView

from core.utils import SequenceQuerySet
Expand All @@ -16,6 +20,10 @@
from .models import REVIEW_REQUIRED_PERMISSIONS, Review, TalkProposalSnapshot
from .context import reviews_state

from registry.helper import reg

import pytz
import datetime

class ReviewableMixin:
def dispatch(self, request, *args, **kwargs):
Expand Down Expand Up @@ -286,3 +294,82 @@ 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'
]

if request.method == 'POST':

for tag in review_stages_var:
key = settings.CONFERENCE_DEFAULT_SLUG + '.' + tag
if (tag == 'proposals.disable.after'):
if(request.POST['proposals.disable.after'] == ""):
tomatoprinx marked this conversation as resolved.
Show resolved Hide resolved
continue
else:
date_time_obj = date_preprocess(
DATETIME_INPUT_FORMATS,
request.POST['proposals.disable.after'])
if(date_time_obj is None):
messages.error(request,'Please input valid date format : " + "%Y-%m-%dT%H:%M')
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you go to this path, current_review_stages_setting will be empty, and all values are lost. If the user entered an invalid value for proposals.disable.after, and then corrected it, and press save, all previous states will be lost, which is dangerous.

I think this is some kind of duplicate code of the normal render() for this view. maybe you should make them the same code.

**reviews_state()._asdict()
})
continue
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

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

# Render current setting to frontend
for tag in review_stages_var:
key = settings.CONFERENCE_DEFAULT_SLUG + '.' + tag
value = reg.get(key, '')
# Django template language does not support dictionary keys containing "."
if "." in tag:
tag = tag.replace(".", "_")
current_review_stages_setting[tag] = value

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 date_preprocess(DATETIME_INPUT_FORMATS, value):
# Add defined datetime formatx
DATETIME_INPUT_FORMATS += ['%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_FORMATS:
try:
return datetime.datetime.strptime(value, format)
except (ValueError, TypeError):
continue
return None
# raise ValidationError("Please input valid date format : " + "%Y-%m-%dT%H:%M")
17 changes: 17 additions & 0 deletions src/static/css/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
@include button-variant($btn-natural-color, $btn-natural-bg, $btn-natural-border);
}

.btn-natural-noborder {
@include button-variant($btn-natural-color, $btn-natural-bg, $btn-natural-border);
}

.btn-action{
@include button-variant($btn-action-color, $btn-action-bg, $btn-action-border);
}
Expand Down Expand Up @@ -40,6 +44,19 @@
}
}

.btn-natural-noborder {
&:hover {
background-color: $btn-natural-hover-bg;
}
&,
&:focus,
&:active {
outline: none;
border-color: transparent;
}
margin-bottom: 20px;
}

.btn-natural.btn-withdraw {
&,
&:hover,
Expand Down
5 changes: 5 additions & 0 deletions src/static/css/components/_texts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
.text-emphasize {
@include roboto-medium();
}

.input-customized-size input{
width: 16.2em;
}

47 changes: 47 additions & 0 deletions src/static/css/components/_toggle.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.material-switch > input[type="checkbox"] {
display: none;
}

.material-switch > label {
cursor: pointer;
height: 0px;
position: relative;
width: 40px;
}

.material-switch > label::before {
background: rgb(0, 0, 0);
box-shadow: inset 0px 0px 10px rgba(0, 0, 0, 0.5);
border-radius: 8px;
content: '';
height: 16px;
margin-top: -8px;
position:absolute;
opacity: 0.3;
transition: all 0.4s ease-in-out;
width: 40px;
}

.material-switch > label::after {
background: rgb(255, 255, 255);
border-radius: 16px;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
content: '';
height: 24px;
left: -4px;
margin-top: -8px;
position: absolute;
top: -4px;
transition: all 0.3s ease-in-out;
width: 24px;
}

.material-switch > input[type="checkbox"]:checked + label::before {
background: inherit;
opacity: 0.5;
}

.material-switch > input[type="checkbox"]:checked + label::after {
background: inherit;
left: 20px;
}
alice6373 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/static/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@import "components/tables";
@import "components/texts";
@import "components/lists";
@import "components/toggle";

// Pages
@import "pages/proposals";
Expand Down
3 changes: 2 additions & 1 deletion src/static/css/vendors/bootstrap/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ a.btn {
&:hover,
&:focus,
&:active {
outline: none;
border-color: transparent;
}
&:hover,
Expand All @@ -128,7 +129,6 @@ a.btn {
}
}


// Button Sizes
// --------------------------------------------------

Expand Down Expand Up @@ -166,3 +166,4 @@ input[type="button"] {
width: 100%;
}
}

85 changes: 85 additions & 0 deletions src/static/js/reviews/review_stages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

var proposals_creatable = document.getElementById("proposals.creatable");
var proposals_editable = document.getElementById("proposals.editable");
var proposals_withdrawable = document.getElementById("proposals.withdrawable");
var reviews_stage = document.getElementById("reviews.stage");
var reviews_visible_to_submitters = document.getElementById("reviews.visible.to.submitters");

$('.hotkey').click(function () {
if ($(this).val() == "Call for Proposals") {
Call_for_Proposals();
}
else if ($(this).val() == "Locked (proposal editing and reviewing disabled)") {
Locked()
}
else if ($(this).val() == "First Round Review") {
First_Round_Review()
}
else if ($(this).val() == "Modification Stage") {
Modification_Stage()
}
else if ($(this).val() == "Second Round Review") {
Second_Round_Review()
}
else if ($(this).val() == "Internal Decision") {
Internal_Decision()
}
else {
Announcement_of_Acceptance()
}

/*
Proposal Review Stage Setting
Reference : https://github.com/pycontw/pycon.tw/blob/master/src/reviews/README.md
*/
function Call_for_Proposals(){
proposals_creatable.checked = true;
proposals_editable.checked = true;
proposals_withdrawable.checked = true;
reviews_stage.value = "0";
reviews_visible_to_submitters.checked = false;
}
function Locked() {
proposals_creatable.checked = false;
proposals_editable.checked = false;
proposals_withdrawable.checked = false;
reviews_stage.value = "0";
reviews_visible_to_submitters.checked = false;
}
function First_Round_Review() {
proposals_creatable.checked = false;
proposals_editable.checked = false;
proposals_withdrawable.checked = false;
reviews_stage.value = "1";
reviews_visible_to_submitters.checked = false;
}
function Modification_Stage() {
proposals_creatable.checked = false;
proposals_editable.checked = true;
proposals_withdrawable.checked = false;
reviews_stage.value = "0";
reviews_visible_to_submitters.checked = true;
}
function Second_Round_Review() {
proposals_creatable.checked = false;
proposals_editable.checked = false;
proposals_withdrawable.checked = false;
reviews_stage.value = "2";
reviews_visible_to_submitters.checked = false;
}
function Internal_Decision() {
proposals_creatable.checked = false;
proposals_editable.checked = false;
proposals_withdrawable.checked = false;
reviews_stage.value = "0";
reviews_visible_to_submitters.checked = false;
}
function Announcement_of_Acceptance() {
proposals_creatable.checked = false;
proposals_editable.checked = true;
proposals_withdrawable.checked = false;
reviews_stage.value = "0";
reviews_visible_to_submitters.checked = true;
}

});
6 changes: 6 additions & 0 deletions src/templates/default/_includes/dashboard_tablist.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@
{% endif %}
</li>
{% endif %}

{% if user.is_superuser %}
<li class="{% if active == 'admin' %}active{% endif %}">
<a href="{% url 'review_stages' %}">{% trans 'Review Stages' %}</a>
</li>
{% endif %}
</ul>
Loading