Fixes for the selection of current rigs.

Added checked in field for dry hires
This commit is contained in:
tomtom5152
2015-01-28 16:30:32 +00:00
parent ca1fd274e2
commit 1c29b9275d
5 changed files with 64 additions and 30 deletions

View File

@@ -84,4 +84,4 @@ class EventForm(forms.ModelForm):
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']
'person', 'organisation', 'dry_hire', 'based_on', 'checked_in_by']

View File

@@ -175,7 +175,7 @@ class EventManager(models.Manager):
status=Event.CANCELLED)) | # Ends after
(models.Q(dry_hire=True, start_date__gte=datetime.date.today()) & ~models.Q(
status=Event.CANCELLED)) | # Active dry hire
(models.Q(dry_hire=True, checked_in_by__isnull=False) & (
(models.Q(dry_hire=True, checked_in_by__isnull=True) & (
models.Q(status=Event.BOOKED) | models.Q(status=Event.CONFIRMED))) | # Active dry hire GT
models.Q(status=Event.CANCELLED, start_date__gte=datetime.date.today()) # Canceled but not started
).order_by('meet_at', 'start_date').select_related('person', 'organisation', 'venue', 'mic')
@@ -183,14 +183,16 @@ class EventManager(models.Manager):
def rig_count(self):
event_count = self.filter(
models.Q(start_date__gte=datetime.date.today(), end_date__isnull=True,
is_rig=True) | # Starts after with no end
models.Q(end_date__gte=datetime.date.today(), is_rig=True) | # Ends after
models.Q(dry_hire=True, checked_in_by__isnull=False, status__lt=Event.CANCELLED,
is_rig=True) | # Active dry hire LT
models.Q(dry_hire=True, checked_in_by__isnull=False, status__gt=Event.CANCELLED, is_rig=True)
# Active dry hire GT
).order_by('meet_at', 'start_date').count()
(models.Q(start_date__gte=datetime.date.today(), end_date__isnull=True, dry_hire=False,
is_rig=True) & ~models.Q(
status=Event.CANCELLED)) | # Starts after with no end
(models.Q(end_date__gte=datetime.date.today(), dry_hire=False, is_rig=True) & ~models.Q(
status=Event.CANCELLED)) | # Ends after
(models.Q(dry_hire=True, start_date__gte=datetime.date.today(), is_rig=True) & ~models.Q(
status=Event.CANCELLED)) | # Active dry hire
(models.Q(dry_hire=True, checked_in_by__isnull=True, is_rig=True) & (
models.Q(status=Event.BOOKED) | models.Q(status=Event.CONFIRMED))) # Active dry hire GT
).count()
return event_count

View File

@@ -230,32 +230,44 @@
<label for="{{ form.start_date.id_for_label }}"
class="col-sm-4 control-label">{{ form.start_date.label }}</label>
<div class="col-sm-4">
<input type="date" name="{{ form.start_date.name }}"
id="{{ form.start_date.id_for_label }}"
class="form-control start_date" required
value="{{ form.start_date.value|date:"Y-m-d" }}"/>
</div>
<div class="col-sm-4">
{% render_field form.start_time type="time" class+="form-control" %}
<div class="col-sm-8">
<div class="row">
<div class="col-sm-12 col-md-7">
<input type="date" name="{{ form.start_date.name }}"
id="{{ form.start_date.id_for_label }}"
class="form-control start_date" required
value="{{ form.start_date.value|date:"Y-m-d" }}"/>
</div>
<div class="col-sm-12 col-md-5">
{% render_field form.start_time type="time" class+="form-control" %}
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="{{ form.end_date.id_for_label }}"
class="col-sm-4 control-label">{{ form.end_date.label }}</label>
<div class="col-sm-4">
<input type="date" name="{{ form.end_date.name }}" id="{{ form.end_date.id_for_label }}"
class="form-control end_date" required
value="{{ form.end_date.value|date:"Y-m-d" }}"/>
</div>
<div class="col-sm-4">
{% render_field form.end_time type="time" class+="form-control end_time" %}
</div>
<div class="col-sm-offset-8 col-sm-4">
<div class="btn-group btn-group-justified">
<btn class="btn btn-default btn-xs" onclick="setTime23Hours()">23:00</btn>
<btn class="btn btn-default btn-xs" onclick="setTime02Hours()">02:00</btn>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-12 col-md-7">
<input type="date" name="{{ form.end_date.name }}"
id="{{ form.end_date.id_for_label }}"
class="form-control end_date" required
value="{{ form.end_date.value|date:"Y-m-d" }}"/>
</div>
<div class="col-sm-12 col-md-5">
{% render_field form.end_time type="time" class+="form-control end_time" %}
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-offset-7 col-md-5">
<div class="btn-group btn-group-justified">
<btn class="btn btn-default btn-xs" onclick="setTime23Hours()">23:00</btn>
<btn class="btn btn-default btn-xs" onclick="setTime02Hours()">02:00</btn>
</div>
</div>
</div>
</div>
</div>
@@ -316,6 +328,25 @@
value="{{ object.mic.name|default_if_none:"" }}"/>
</div>
</div>
{% if object.dry_hire %}
<div class="form-group">
<label for="{{ form.checked_in_by.id_for_label }}"
class="col-sm-4 control-label">{{ form.checked_in_by.label }}</label>
<div class="col-sm-8">
<input type="hidden" id="{{ form.checked_in_by.id_for_label }}"
name="{{ form.checked_in_by.name }}"
value="{{ form.checked_in_by.value|default_if_none:"" }}"/>
<input type="text" id="{{ form.checked_in_by.id_for_label }}-input"
class="form-control autocomplete-json"
data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,username,initials"
data-target="{{ form.checked_in_by.id_for_label }}"
value="{{ object.checked_in_by.name|default_if_none:"" }}"/>
</div>
</div>
{% endif %}
</div>
</div>
</div>

View File

@@ -193,6 +193,7 @@ class SecureAPIRequest(generic.View):
'person': models.Person,
'organisation': models.Organisation,
'mic': models.Profile,
'profile': models.Profile,
}
'''

Binary file not shown.