-
Notifications
You must be signed in to change notification settings - Fork 112
Initialize setting review / proposal stage page #782
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
base: master
Are you sure you want to change the base?
Changes from all commits
1497d90
f3095e6
8bb98fb
57d036c
e3fcda2
2881ea9
db4fea7
6ef2f5b
211bf3c
048c941
76c39dc
fdd09ab
8ade9c1
cfb5fa1
afaf6d5
88ee598
9ef909e
d579e69
2fb312d
500b9db
ced5b07
928e2d1
32f30a1
c4ef31e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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'), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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): | ||
|
@@ -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'] == ""): | ||
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you go to this path, I think this is some kind of duplicate code of the normal |
||
**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") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,8 @@ | |
.text-emphasize { | ||
@include roboto-medium(); | ||
} | ||
|
||
.input-customized-size input{ | ||
width: 16.2em; | ||
} | ||
|
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
|
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; | ||
} | ||
|
||
}); |
Uh oh!
There was an error while loading. Please reload this page.