mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Fixed issue with datetime fields
This commit is contained in:
@@ -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
17
RIGS/forms.py
Normal 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']
|
||||
@@ -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)
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user