Fixed issue with datetime fields

This commit is contained in:
Tom Price
2014-12-03 11:50:24 +00:00
parent 91f6bb5557
commit 1368224be6
5 changed files with 36 additions and 6 deletions

View File

@@ -110,6 +110,8 @@ USE_L10N = True
USE_TZ = True
DATETIME_INPUT_FORMATS = ('%Y-%m-%dT%H:%M','%Y-%m-%dT%H:%M:%S')
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",

17
RIGS/forms.py Normal file
View File

@@ -0,0 +1,17 @@
__author__ = 'Ghost'
from django import forms
from django.utils import formats
from RIGS import models
from django.conf import settings
# Events Shit
class EventForm(forms.ModelForm):
datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS
meet_at = forms.DateTimeField(input_formats=datetime_input_formats, required=False)
access_at = forms.DateTimeField(input_formats=datetime_input_formats, required=False)
name = forms.CharField(min_length=3)
class Meta:
model = models.Event
fields = ['is_rig', 'name', 'venue', 'start_date', 'start_time', 'end_date',
'end_time', 'meet_at', 'access_at', 'description', 'notes', 'mic',
'person', 'organisation', 'dry_hire', 'based_on']

View File

@@ -1,7 +1,7 @@
from django.views import generic
from django.core.urlresolvers import reverse_lazy
from RIGS import models
from RIGS import models, forms
__author__ = 'ghost'
@@ -25,6 +25,7 @@ class EventDetail(generic.DetailView):
class EventCreate(generic.CreateView):
model = models.Event
form_class = forms.EventForm
def get_context_data(self, **kwargs):
context = super(EventCreate, self).get_context_data(**kwargs)
@@ -37,6 +38,7 @@ class EventCreate(generic.CreateView):
class EventUpdate(generic.UpdateView):
model = models.Event
form_class = forms.EventForm
def get_context_data(self, **kwargs):
context = super(EventUpdate, self).get_context_data(**kwargs)

View File

@@ -110,7 +110,8 @@
data-target="{{ form.person.id_for_label }}"/>
</div>
<div class="col-xs-3 align-right">
<a href="{% url 'person_create' %}" class="btn btn-default modal-href" data-target="#{{ form.person.id_for_label }}">
<a href="{% url 'person_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.person.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
</div>
@@ -135,7 +136,8 @@
data-target="{{ form.organisation.id_for_label }}"/>
</div>
<div class="col-xs-3 align-right">
<a href="{% url 'organisation_create' %}" class="btn btn-default modal-href" data-target="#{{ form.organisation.id_for_label }}">
<a href="{% url 'organisation_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.organisation.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
</div>
@@ -194,7 +196,8 @@
data-target="{{ form.venue.id_for_label }}"/>
</div>
<div class="col-xs-3 align-right">
<a href="{% url 'venue_create' %}" class="btn btn-default modal-href" data-target="#{{ form.venue.id_for_label }}">
<a href="{% url 'venue_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.venue.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
</div>
@@ -242,7 +245,10 @@
class="col-sm-4 control-label">{{ form.access_at.label }}</label>
<div class="col-sm-8">
{% render_field form.access_at type="datetime-local" class+="form-control" %}
<input type="datetime-local" name="{{ form.access_at.name }}"
id="{{ form.access_at.id_for_label }}"
class="form-control"
value="{{ form.access_at.value|date:"c" }}"/>
</div>
</div>
<div class="form-group">
@@ -250,7 +256,10 @@
class="col-sm-4 control-label">{{ form.meet_at.label }}</label>
<div class="col-sm-8">
{% render_field form.meet_at type="datetime-local" class+="form-control" %}
<input type="datetime-local" name="{{ form.meet_at.name }}"
id="{{ form.meet_at.id_for_label }}"
class="form-control"
value="{{ form.meet_at.value|date:"c" }}"/>
</div>
</div>
<div class="form-group">

Binary file not shown.