Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
disable bootstrap tour, fix participant ready post
Browse files Browse the repository at this point in the history
Minor refactoring and disasee #69 for more details
  • Loading branch information
alee committed Dec 16, 2014
1 parent bc67ace commit 7e05b8a
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 155 deletions.
1 change: 1 addition & 0 deletions vcweb/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def participant_ready(request):
message = "Participant %s is ready." % request.user.participant

experiment.publish_to_participants(create_message_event(message, "participant_ready"))
experiment.publish_to_experimenter(create_message_event(message))

if experiment.all_participants_ready:
experiment.publish_to_experimenter(create_message_event(
Expand Down
134 changes: 52 additions & 82 deletions vcweb/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from django.conf import settings
from django.contrib.auth import authenticate
from django.contrib.auth.forms import PasswordResetForm
from django.contrib.auth.models import User
from django.core.validators import validate_email
from django.forms import widgets, ValidationError, CheckboxInput
from django.forms.util import ErrorDict
Expand All @@ -26,6 +25,7 @@

email_separator_re = re.compile(r'[^\w\.\-\+@_]+')


class NumberInput(widgets.Input):
input_type = 'number'

Expand All @@ -42,40 +42,43 @@ class URLInput(widgets.Input):
input_type = 'url'


#class BaseRegistrationForm(forms.Form):
# required_css_class = 'required'
#
# first_name = forms.CharField(widget=widgets.TextInput)
# last_name = forms.CharField(widget=widgets.TextInput)
# email = forms.EmailField(widget=EmailInput, help_text=_('Please enter a valid email.'))
# password = forms.CharField(widget=widgets.PasswordInput)
# confirm_password = forms.CharField(widget=widgets.PasswordInput)
# institution = forms.CharField(widget=autocomplete_light.TextWidget(InstitutionAutocomplete),
# help_text=_('The primary institution, if any, you are affiliated with.'))
#
# def clean_email(self):
# email_address = self.cleaned_data.get('email', '').lower()
# if not email_address:
# raise ValidationError(_("Please enter a valid email address."))
# try:
# User.objects.get(email=email_address)
# except User.DoesNotExist:
# return email_address
# raise forms.ValidationError(_("This email address is already registered in our system."),
# code='already-registered')
#
# def clean(self):
# cleaned_data = super(BaseRegistrationForm, self).clean()
# pw = cleaned_data['password']
# confirm_pw = cleaned_data['confirm_password']
# if pw == confirm_pw:
# return cleaned_data
# raise forms.ValidationError(_("Please make sure your passwords match."), code='invalid')


#class RegistrationForm(BaseRegistrationForm):
# experimenter = forms.BooleanField(required=False,
# help_text=_('Check this box if you would like to request experimenter access.'))
"""
XXX: open registration currently disabled.
class BaseRegistrationForm(forms.Form):
required_css_class = 'required'
first_name = forms.CharField(widget=widgets.TextInput)
last_name = forms.CharField(widget=widgets.TextInput)
email = forms.EmailField(widget=EmailInput, help_text=_('Please enter a valid email.'))
password = forms.CharField(widget=widgets.PasswordInput)
confirm_password = forms.CharField(widget=widgets.PasswordInput)
institution = forms.CharField(widget=autocomplete_light.TextWidget(InstitutionAutocomplete),
help_text=_('The primary institution, if any, you are affiliated with.'))
def clean_email(self):
email_address = self.cleaned_data.get('email', '').lower()
if not email_address:
raise ValidationError(_("Please enter a valid email address."))
try:
User.objects.get(email=email_address)
except User.DoesNotExist:
return email_address
raise forms.ValidationError(_("This email address is already registered in our system."),
code='already-registered')
def clean(self):
cleaned_data = super(BaseRegistrationForm, self).clean()
pw = cleaned_data['password']
confirm_pw = cleaned_data['confirm_password']
if pw == confirm_pw:
return cleaned_data
raise forms.ValidationError(_("Please make sure your passwords match."), code='invalid')
class RegistrationForm(BaseRegistrationForm):
experimenter = forms.BooleanField(required=False,
help_text=_('Check this box if you would like to request experimenter access.'))
"""


class VcwebPasswordResetForm(PasswordResetForm):
Expand Down Expand Up @@ -124,12 +127,13 @@ def __init__(self, *args, **kwargs):

class Meta:
model = Participant
fields = ['first_name', 'last_name', 'email', 'gender', 'institution', 'can_receive_invitations', 'class_status',
'major', 'favorite_sport', 'favorite_food', 'favorite_color', 'favorite_movie_genre']
fields = ['first_name', 'last_name', 'email', 'gender', 'institution', 'can_receive_invitations',
'class_status', 'major', 'favorite_sport', 'favorite_food', 'favorite_color', 'favorite_movie_genre']
widgets = {
'major': autocomplete_light.TextWidget(ParticipantMajorAutocomplete)
}


class AccountForm(forms.ModelForm):
required_css_class = 'required'

Expand Down Expand Up @@ -189,7 +193,7 @@ class ExperimenterAccountForm(AccountForm):

class Meta:
model = Experimenter
fields = ['first_name', 'last_name', 'email',]
fields = ['first_name', 'last_name', 'email']


class ExperimentConfigurationForm(forms.ModelForm):
Expand All @@ -211,7 +215,6 @@ def __init__(self, post_dict=None, instance=None, pk=None, **kwargs):
{'class': 'has-popover', 'data-content': help_text, 'data-placement': 'right',
'data-container': 'body'})


def save(self, commit=True):
ec = super(ExperimentConfigurationForm, self).save(commit=False)
if self.request_type == 'delete':
Expand Down Expand Up @@ -357,7 +360,7 @@ class EmailListField(forms.CharField):
def clean(self, value):
super(EmailListField, self).clean(value)
lines = value.split('\n')
#emails = email_separator_re.split(value)
# emails = email_separator_re.split(value)
if not lines:
raise ValidationError(_(u'You must enter at least one email address.'))
emails = []
Expand Down Expand Up @@ -446,15 +449,15 @@ class RegisterExcelParticipantsForm(RegisterParticipantsForm):
class ChatForm(forms.Form):
message = forms.CharField()
participant_group_id = forms.IntegerField(widget=forms.HiddenInput)
target_participant_group_id = forms.IntegerField(
widget=forms.HiddenInput, required=False)
target_participant_group_id = forms.IntegerField(widget=forms.HiddenInput, required=False)

def clean_message(self):
return self.cleaned_data['message']


class ParticipantGroupIdForm(forms.Form):
participant_group_id = forms.IntegerField(widget=forms.HiddenInput)
message = forms.CharField(required=False)


class GeoCheckinForm(forms.Form):
Expand Down Expand Up @@ -506,19 +509,6 @@ class CommentForm(forms.Form):
participant_group_id = forms.IntegerField(widget=forms.HiddenInput)


#class LogMessageForm(forms.Form):
# log_levels = [(getattr(logging, levelName), levelName) for levelName in ('DEBUG', 'INFO', 'WARNING',
# 'ERROR', 'CRITICAL')]
# level = forms.ChoiceField(choices=log_levels)
# message = forms.CharField()
#
# def clean_level(self):
# level = int(self.cleaned_data['level'])
# if level in dict(self.log_levels):
# return level
# raise ValidationError(_("invalid log level %s" % level))


class SingleIntegerDecisionForm(forms.Form):
integer_decision = forms.IntegerField(required=True, min_value=0)
participant_group_id = forms.IntegerField(
Expand All @@ -527,26 +517,6 @@ class SingleIntegerDecisionForm(forms.Form):
required=False, widget=forms.widgets.HiddenInput)


#class QuizForm(forms.Form):
# name_question = forms.CharField(
# max_length=64, label=_("What is your name?"))
#
# def __init__(self, *args, **kwargs):
# quiz_questions = []
# try:
# quiz_questions = kwargs.pop('quiz_questions')
# finally:
# super(QuizForm, self).__init__(*args, **kwargs)
# for quiz_question in quiz_questions:
# self.fields['quiz_question_%d' % quiz_question.pk] = forms.CharField(
# label=quiz_question.label)
#
# def extra_questions(self):
# for name, value in self.cleaned_data.items():
# if name.startswith('quiz_question_'):
# yield (self.fields[name].label, value)


class AntiSpamForm(forms.Form):
timestamp = forms.IntegerField(widget=forms.HiddenInput)
security_hash = forms.CharField(min_length=40, max_length=40, widget=forms.HiddenInput)
Expand Down Expand Up @@ -624,10 +594,10 @@ def from_email(self):
return self.cleaned_data.get('email', settings.DEFAULT_FROM_EMAIL)


#class BugReportForm(AntiSpamForm):
#
# def __init__(self, *args, **kwargs):
# super(BugReportForm, self).__init__(*args, **kwargs)
#
# title = forms.CharField(max_length=512)
# body = forms.CharField(widget=forms.Textarea, label=u'Description')
class BugReportForm(AntiSpamForm):

def __init__(self, *args, **kwargs):
super(BugReportForm, self).__init__(*args, **kwargs)

title = forms.CharField(max_length=512)
body = forms.CharField(widget=forms.Textarea, label=u'Description')
21 changes: 2 additions & 19 deletions vcweb/core/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ <h4 class="modal-title" id='bugModalLabel'>Report Bug</h4>
<script src='{% static "js/ko/knockout.mapping.min.js" %}'></script>
<script src='{% static "js/ko/knockout.helper.js" %}'></script>
<script src='{% static "js/common.js" %}'></script>
{% if not DEBUG %}
<script src="//cdn.ravenjs.com/{{ravenjs_version}}/jquery,native/raven.min.js"></script>
<script>
var options = { tags: { git_commit: '{{ REVISION }}'} }
Raven.config('{% sentry_public_dsn %}', options).install();
</script>
{% endif %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand All @@ -172,25 +174,6 @@ <h4 class="modal-title" id='bugModalLabel'>Report Bug</h4>
ga('create', 'UA-321755-10', 'auto');
ga('send', 'pageview');
</script>
<script>
$("#report-issue").click(function(e) {
e.preventDefault();
$.get('/bug-report')
.done( function(data) {
$("#bugModal .modal-body").html(data);
});
});
$("#bugModal").on('submit', '#bug-form', function(e) {
e.preventDefault();
var data = $("#bugModal form").serialize() + "&url="+window.location;
$.post('/bug-report', data)
.done(function(data) {
if(data.success) {
$('#bugModal').modal('hide');
}
});
});
</script>
{% block javascript %}
{% endblock %}
</body>
Expand Down
2 changes: 1 addition & 1 deletion vcweb/core/templates/includes/bootstrap-tour.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<link href="{{STATIC_URL}}css/bootstrap-tour.min.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="{{STATIC_URL}}js/bootstrap-tour.js"></script>
<script src="{{STATIC_URL}}js/bootstrap-tour.js"></script>
2 changes: 1 addition & 1 deletion vcweb/core/templates/includes/jquery.validate.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% with jqv_version="1.13.0" %}
{% with jqv_version="1.13.1" %}
<script type='text/javascript' src='//ajax.aspnetcdn.com/ajax/jquery.validate/{{jqv_version}}/jquery.validate.min.js'></script>
{% endwith %}
Loading

0 comments on commit 7e05b8a

Please sign in to comment.