Commit da314e13 authored by Felizia Tiburcio's avatar Felizia Tiburcio

jquery datepicker plugin

parent 94336cf2
......@@ -70,7 +70,13 @@
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="{% static 'slick/slick.min.js' %}"></script>
<!-- <link rel="stylesheet" type="text/css" href="{% static ' build/jquery.datetimepicker.css' %}"/ >
<script src="{% static '/build/jquery.datetimepicker.full.min.js' %}"></script> -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.min.css" integrity="sha256-DOS9W6NR+NFe1fUhEE0PGKY/fubbUCnOfTje2JMDw3Y=" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.min.js" integrity="sha256-FEqEelWI3WouFOo2VWP/uJfs1y8KJ++FLh2Lbqc8SJk=" crossorigin="anonymous"></script>
</body>
......
......@@ -14,10 +14,22 @@
{% csrf_token %}
{{ form.as_p }}
<button type="submit" name="savesauction">Save Auction</button>
<button type="submit" name="savesauction">Start Auction</button>
</form>
</div>
<input id="datetimepicker" type="text">
<script>
$(function () {
$("#id_auctionstart").datetimepicker();
});
$(function () {
$("#id_auctionend").datetimepicker();
});
</script>
<!-- Form fields:
[Auction Title]
[Auction Description]
......
......@@ -59,8 +59,12 @@ class DeleteItemForm(forms.Form):
class StartAuctionForm(forms.ModelForm):
# the widget is supposed to have a pop up but not showing, keeping here bc it separates date and time nicely
auctionstart = forms.SplitDateTimeField(widget=AdminSplitDateTime())
auctionend = forms.SplitDateTimeField(widget=AdminSplitDateTime())
# auctionstart = forms.SplitDateTimeField(widget=AdminSplitDateTime())
# auctionend = forms.SplitDateTimeField(widget=AdminSplitDateTime())
# auctionstart = forms.DateTimeField(input_formats=['%d/%m/%Y %H:%M'])
# auctionend = forms.DateTimeField(input_formats=['%d/%m/%Y %H:%M'])
class Meta:
......@@ -75,17 +79,12 @@ class StartAuctionForm(forms.ModelForm):
'itemid': _('Item up for auction')
}
# datetime_format = ['%Y-%m-%d %H:%M']
# widgets = { 'auctionstart' : forms.AdminSplitDateTime()} #, 'auctionend' : forms.SplitDateTimeField()}
# vv fix later, is missing time widget
# widgets = { 'auctionstart' : forms.SelectDateWidget, 'auctionend':forms.SelectDateWidget}
# 'itemid': forms.HiddenInput()}
def clean(self):
super().clean()
end_time = self.cleaned_data['auctionend']
start_time = self.cleaned_data['auctionstart']
print(self.cleaned_data)
end_time = self.cleaned_data.get('auctionend')
start_time = self.cleaned_data.get('auctionstart')
current_date = timezone.now()
auctioned_item = self.cleaned_data['itemid']
......@@ -95,7 +94,7 @@ class StartAuctionForm(forms.ModelForm):
if start_time > end_time:
raise ValidationError('Start date should be before end date.')
elif start_time < current_date or end_time < current_date:
raise ValidationError('Date cannot be in the past')
raise ValidationError('Date cannot be in the past.')
else:
for auc in auctions:
if auc.itemid == auctioned_item:
......
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