Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

patch edit screen.. changed datepicker formatting to be cohesive.. fi…

…xed backend validation and add logging
  • Loading branch information...
commit 8aa7c21a5a37b95f7b8801ead1c38cf3b72dcc5b 1 parent 92d3c92
jonathan authored
View
57 main.py
@@ -159,21 +159,16 @@ def post(self, id):
access_rights = UserRights(user, event)
if access_rights.can_edit:
try:
- srg_date = self.request.get('date')
- if event.start_time == srg_date:
- start_time = start_time
- else:
- st_date = srg_date[0:len(srg_date)-9]
- start_time = datetime.strptime('%s %s:%s %s' % (
- st_date,
- self.request.get('start_time_hour'),
- self.request.get('start_time_minute'),
- self.request.get('start_time_ampm')), '%Y-%m-%d %I:%M %p')
- end_time = datetime.strptime('%s %s:%s %s' % (
- st_date,
- self.request.get('end_time_hour'),
- self.request.get('end_time_minute'),
- self.request.get('end_time_ampm')), '%Y-%m-%d %I:%M %p')
+ start_time = datetime.strptime('%s %s:%s %s' % (
+ self.request.get('date'),
+ self.request.get('start_time_hour'),
+ self.request.get('start_time_minute'),
+ self.request.get('start_time_ampm')), '%m/%d/%Y %I:%M %p')
+ end_time = datetime.strptime('%s %s:%s %s' % (
+ self.request.get('date'),
+ self.request.get('end_time_hour'),
+ self.request.get('end_time_minute'),
+ self.request.get('end_time_ampm')), '%m/%d/%Y %I:%M %p')
conflicts = Event.check_conflict(start_time,end_time,self.request.get_all('rooms'), int(id))
if conflicts:
raise ValueError('Room conflict detected')
@@ -184,19 +179,49 @@ def post(self, id):
if ( self.request.get( 'contact_phone' ) and not is_phone_valid( self.request.get( 'contact_phone' ) ) ):
raise ValueError( 'Phone number does not appear to be valid' )
else:
+ log_desc = "Event edited\n"
+ previous_object = Event.get_by_id(int(id))
event.name = self.request.get('name')
+ if (previous_object.name != event.name):
+ log_desc = log_desc + "Title: " + previous_object.name + " to " + event.name + "\n"
event.start_time = start_time
+ if (previous_object.start_time != event.start_time):
+ log_desc = log_desc + "Start time: " + str(previous_object.start_time) + " to " + str(event.start_time) + "\n"
event.end_time = end_time
+ if (previous_object.end_time != event.end_time):
+ log_desc = log_desc + "End time: " + str(previous_object.end_time) + " to " + str(event.end_time) + "\n"
event.estimated_size = cgi.escape(self.request.get('estimated_size'))
+ if (previous_object.estimated_size != event.estimated_size):
+ log_desc = log_desc + "Est. size: " + previous_object.estimated_size + " to " + event.estimated_size + "\n"
event.contact_name = cgi.escape(self.request.get('contact_name'))
+ if (previous_object.contact_name != event.contact_name):
+ log_desc = log_desc + "Contact: " + previous_object.contact_name + " to " + event.contact_name + "\n"
event.contact_phone = cgi.escape(self.request.get('contact_phone'))
+ if (previous_object.contact_phone != event.contact_phone):
+ log_desc = log_desc + "Contact phone: " + previous_object.contact_phone + " to " + event.contact_phone + "\n"
event.details = cgi.escape(self.request.get('details'))
+ if (previous_object.details != event.details):
+ log_desc = log_desc + "Details: " + previous_object.details + " to " + event.details + "\n"
event.url = cgi.escape(self.request.get('url'))
+ if (previous_object.url != event.url):
+ log_desc = log_desc + "Url: " + previous_object.url + " to " + event.url + "\n"
event.fee = cgi.escape(self.request.get('fee'))
+ if (previous_object.fee != event.fee):
+ log_desc = log_desc + "Fee: " + previous_object.fee + " to " + event.fee + "\n"
event.notes = cgi.escape(self.request.get('notes'))
+ if (previous_object.notes != event.notes):
+ log_desc = log_desc + "Notes: " + previous_object.notes + " to " + event.notes + "\n"
event.rooms = self.request.get_all('rooms')
+ if (previous_object.rooms != event.rooms):
+ log_desc = log_desc + "Rooms changed" + "\n"
+ log_desc = log_desc + "Old room " + "\n"
+ for room in previous_object.rooms:
+ log_desc = log_desc + room + ' '
+ log_desc = log_desc + "New room(s) " + "\n"
+ for room in event.rooms:
+ log_desc = log_desc + room + ' '
event.put()
- log = HDLog(event=event,description="Edited event")
+ log = HDLog(event=event,description=log_desc)
log.put()
self.redirect(event_path(event))
except ValueError, e:
View
2  models.py
@@ -224,7 +224,7 @@ class HDLog(db.Model):
event = db.ReferenceProperty(Event)
created = db.DateTimeProperty(auto_now_add=True)
user = db.UserProperty(auto_current_user_add=True)
- description = db.StringProperty(multiline=True)
+ description = db.TextProperty
@classmethod
def get_logs_list(cls):
View
2  static/js/edit.js
@@ -1,5 +1,5 @@
$(function() {
- $("#datepicker").datepicker({minDate: 0});
+ $("#datepicker").datepicker();
$('#datepicker, #roomlist input, #start_time_hour, #start_time_minute, #start_time_ampm, #end_time_hour, #end_time_minute, #end_time_ampm').blur(checkDup);
});
View
41 static/js/jquery.datePicker.js
@@ -3,7 +3,7 @@
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* .
- * $Id: jquery.datePicker.js 94 2010-01-25 02:25:27Z kelvin.luck $
+ * $Id: jquery.datePicker.js 102 2010-09-13 14:00:54Z kelvin.luck $
**/
(function($){
@@ -191,8 +191,9 @@
* @option Number horizontalPosition The horizontal alignment of the popped up date picker to the matched element. One of $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT.
* @option Number verticalOffset The number of pixels offset from the defined verticalPosition of this date picker that it should pop up in. Default in 0.
* @option Number horizontalOffset The number of pixels offset from the defined horizontalPosition of this date picker that it should pop up in. Default in 0.
- * @option (Function|Array) renderCallback A reference to a function (or an array of seperate functions) that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Each callback function will receive four arguments; a jquery object wrapping the created TD, a Date object containing the date this TD represents, a number giving the currently rendered month and a number giving the currently rendered year. Default is no callback.
+ * @option (Function|Array) renderCallback A reference to a function (or an array of separate functions) that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Each callback function will receive four arguments; a jquery object wrapping the created TD, a Date object containing the date this TD represents, a number giving the currently rendered month and a number giving the currently rendered year. Default is no callback.
* @option String hoverClass The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class.
+ * @option String autoFocusNextInput Whether focus should be passed onto the next input in the form (true) or remain on this input (false) when a date is selected and the calendar closes
* @type jQuery
* @name datePicker
* @cat plugins/datePicker
@@ -685,7 +686,7 @@
},
setSelected : function(d, v, moveToMonth, dispatchEvents)
{
- if (d < this.startDate || d > this.endDate) {
+ if (d < this.startDate || d.zeroTime() > this.endDate.zeroTime()) {
// Don't allow people to select dates outside range...
return;
}
@@ -746,7 +747,7 @@
getSelected : function()
{
var r = [];
- for(s in this.selectedDates) {
+ for(var s in this.selectedDates) {
if (this.selectedDates[s] == true) {
r.push(Date.fromString(s));
}
@@ -940,14 +941,27 @@
if (!$this.is('.disabled')) {
c.setSelected(d, !$this.is('.selected') || !c.selectMultiple, false, true);
if (c.closeOnSelect) {
+ // Focus the next input in the form…
+ if (c.settings.autoFocusNextInput) {
+ var ele = c.ele;
+ var found = false;
+ $(':input', ele.form).each(
+ function()
+ {
+ if (found) {
+ $(this).focus();
+ return false;
+ }
+ if (this == ele) {
+ found = true;
+ }
+ }
+ );
+ } else {
+ c.ele.focus();
+ }
c._closeCalendar();
}
- // TODO: Instead of this which doesn't work in IE anyway we should find the next focusable element in the document
- // and pass the focus onto that. That would allow the user to continue on the form as expected...
- if (!$.browser.msie)
- {
- $(c.ele).trigger('focus', [$.dpConst.DP_INTERNAL_FOCUS]);
- }
}
}
);
@@ -1149,7 +1163,7 @@
HEADER_FORMAT : 'mmmm yyyy'
};
// version
- $.dpVersion = '$Id: jquery.datePicker.js 94 2010-01-25 02:25:27Z kelvin.luck $';
+ $.dpVersion = '$Id: jquery.datePicker.js 102 2010-09-13 14:00:54Z kelvin.luck $';
$.fn.datePicker.defaults = {
month : undefined,
@@ -1172,7 +1186,8 @@
horizontalPosition : $.dpConst.POS_LEFT,
verticalOffset : 0,
horizontalOffset : 0,
- hoverClass : 'dp-hover'
+ hoverClass : 'dp-hover',
+ autoFocusNextInput : false
};
function _getController(ele)
@@ -1198,4 +1213,4 @@
});
-})(jQuery);
+})(jQuery);
View
6 templatefilters.py
@@ -2,6 +2,10 @@
register = webapp.template.create_template_register()
@register.filter
+def american_date(element):
+ return element.strftime('%m/%d/%Y')
+
+@register.filter
def check_filter(the_list, item):
if item in the_list:
cb = "checked='checked'"
@@ -36,4 +40,4 @@ def select_time(event,item,element):
half = "am" if event.hour < 12 else "pm"
if half == item:
st = "selected='selected'"
- return st
+ return st
View
2  templates/edit.html
@@ -14,7 +14,7 @@
<table style="margin: 0px;" class='b-data'>
<tr>
<td class="first"><label for="date">Date:</label>
- <input name="date" id="datepicker" value="{{event.start_time}}" readonly="readonly"/></td>
+ <input name="date" id="datepicker" value="{{event.start_time|american_date}}" readonly="readonly"/></td>
<td><label for="start_time">Start Time:</label>
<select name="start_time_hour" id="start_time_hour">
{% for hour in hours %}
Please sign in to comment.
Something went wrong with that request. Please try again.