Commit 9be6a01d authored by Matthew Rodgers's avatar Matthew Rodgers Committed by David Haynes
Browse files

Added Custom Date Option

--Added bootstrap3_datetimepicker to requirements
--Added bootstrap3_datetimepicker to installed_apps
--Animated custom datetimepicker
--Closes #26
parent 38b61ca1
......@@ -64,7 +64,7 @@ class URLForm(forms.ModelForm):
(CUSTOM, CUSTOM),
)
# Add a custom expiration choice field.
# Add preset expiration choices.
expires = forms.ChoiceField(
required=True,
label='Expiration (Required)',
......@@ -73,8 +73,14 @@ class URLForm(forms.ModelForm):
widget=forms.RadioSelect(),
)
# Add a custom expiration choice.
expires_custom = forms.DateTimeField(
widget=DateTimePicker(options={"format": "YYYY-MM-DD", "pickTime": False})
required = False,
label='Custom Date',
widget=DateTimePicker(options={
"format": "YYYY-MM-DD",
"pickTime": False,
})
)
......
......@@ -9,14 +9,13 @@ Go - A University Branded URL Shortener
<script type="text/javascript">
$(function() {
$("#div_id_expires_custom").hide();
$("#div_id_expires").click(function() {
if ($("#id_expires_5").is(":checked")) {
$("#div_id_expires_custom").show();
} else {
$("#div_id_expires_custom").hide();
}
})
$("#div_id_expires").click(function() {
if ($("#id_expires_5").is(":checked")) {
$("#div_id_expires_custom").slideDown();
} else {
$("#div_id_expires_custom").slideUp();
}
})
})
</script>
......
......@@ -110,6 +110,8 @@ def index(request):
url.expires = timezone.now() + timedelta(weeks=1)
elif expires == URLForm.MONTH:
url.expires = timezone.now() + timedelta(weeks=3)
elif expires == URLForm.CUSTOM:
url.expires = url_form.cleaned_data.get('expires_custom')
else:
pass # leave the field NULL
......
......@@ -100,6 +100,7 @@ INSTALLED_APPS = (
'django.contrib.admin',
'qrcode',
'crispy_forms',
'bootstrap3_datetime',
)
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
......
......@@ -18,3 +18,4 @@ requests==2.9.1
simplejson==3.8.1
six==1.10.0
wheel==0.26.0
django-bootstrap3-datetimepicker==2.2.3
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment