Add time to Add Asset form.

The start and end date/time of the Asset is now saved to the database.
This commit is contained in:
Zachary Jones
2013-01-29 16:03:23 -06:00
parent 9a243eab74
commit 47dfdee1af
4 changed files with 52 additions and 8 deletions

View File

@@ -223,8 +223,18 @@ def prepare_asset(request):
if "video" in asset['mimetype']:
asset['duration'] = "N/A"
asset['start_date'] = ""
asset['end_date'] = ""
if get('duration'):
asset['duration'] = get('duration')
if get('start_date'):
asset['start_date'] = datetime.strptime(get('start_date'), '%m/%d/%Y %H:%M')
else:
asset['start_date'] = ""
if get('end_date'):
asset['end_date'] = datetime.strptime(get('end_date'), '%m/%d/%Y %H:%M')
else:
asset['end_date'] = ""
return asset
else:

View File

@@ -55,15 +55,42 @@ screenly.InactiveAssets = new InactiveAssets()
################################
class AddAssetModalView extends Backbone.View
events:
'click #add-button': 'addButtonWasClicked'
initialize: (options) ->
@template = _.template($('#add-asset-modal-template').html())
render: ->
$(@el).html(@template())
# setTimeout (=> @$(".date").datepicker()), 1000
@$("input.date").datepicker()
@$("input.date").datepicker({autoclose: true})
@$("input.date").datepicker('setValue', new Date())
@$('input.time').timepicker({
minuteStep: 5,
showInputs: false,
disableFocus: true,
defaultTime: 'current',
showMeridian: false
})
@
addButtonWasClicked: (event) ->
event.preventDefault()
console.log "You tried to add Asset"
start_date = $("input[name='start_date_date']").val() + " " + $("input[name='start_date_time']").val()
end_date = $("input[name='end_date_date']").val() + " " + $("input[name='end_date_time']").val()
$("input[name='start_date']").val(start_date)
$("input[name='end_date']").val(end_date)
@$("form").submit()
screenly.views.AddAssetModalView = AddAssetModalView
class EditAssetModalView extends Backbone.View

View File

File diff suppressed because one or more lines are too long

View File

@@ -8,6 +8,7 @@
%link(href="/static/css/bootstrap.css", rel="stylesheet")
%link(href="/static/css/screenly.css", rel="stylesheet")
%link(href="/static/css/datepicker.css", rel="stylesheet")
%link(href="/static/css/timepicker.css", rel="stylesheet")
%script(src="/static/js/jquery-1.8.0.min.js")
/ %script(src="/static/js/bootstrap-dropdown.js")
@@ -16,6 +17,7 @@
%script(src="/static/js/bootstrap-transition.js")
%script(src="/static/js/bootstrap-modal.js")
%script(src="/static/js/bootstrap-datepicker.js")
%script(src="/static/js/bootstrap-timepicker.js")
%script(src="/static/js/screenly-ose.js")
%script(type="text/template", id="active-assets-template")
@@ -64,7 +66,7 @@
%script(type="text/template", id="add-asset-modal-template")
.modal.hide.fade(tabindex="-1", role="dialog", ariaLabelledby="myModalLabel", ariaHidden="true")
%form.form-horizontal(method="POST", action="/api/assets")
%form.form-horizontal#add-form(method="POST", action="/api/assets")
.modal-header
%button.close(type="button", dataDismiss="modal", ariaHidden="true") x
%h3#myModalLabel Add Asset
@@ -99,19 +101,24 @@
%label.control-label Start Date
.controls
%input.span2.date(type="text", name="start_date_date")
%input.span2.time(type="text", name="start_date_time")
%input(type="hidden", name="start_date")
.control-group
%label.control-label End Date
.controls
%input.span2.date(type="text", name="end_date_date")
%input.span2.time(type="text", name="end_date_time")
%input(type="hidden", name="end_date")
.control-group
%label.control-label Duration
.controls
%input.span5(type="text", name="duration", placeholder="Duration in seconds")
%input.span1(type="text", name="duration")
seconds
.modal-footer
%a.btn(href="#", dataDismiss="modal") Close
%input.btn.btn-primary(type="submit", value="Add Asset")
%input.btn.btn-primary#add-button(type="button", value="Add Asset")