Skip to content
Browse files

Merge branch 'master' of https://github.com/mindynamics/hd-events int…

…o mindynamics-master
  • Loading branch information...
2 parents 74fcda7 + a4f9ae7 commit 253420a2d30924081290e390e54199a3583ae943 @dustball dustball committed Feb 27, 2011
Showing with 80 additions and 36 deletions.
  1. +41 −16 main.py
  2. +1 −1 models.py
  3. +1 −1 static/js/edit.js
  4. +28 −13 static/js/jquery.datePicker.js
  5. +5 −1 templatefilters.py
  6. +4 −4 templates/edit.html
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<br />"
+ previous_object = Event.get_by_id(int(id))
event.name = self.request.get('name')
+ if (previous_object.name != event.name):
+ log_desc = log_desc + "<strong>Title:</strong> " + previous_object.name + " to " + event.name + "<br />"
event.start_time = start_time
+ if (previous_object.start_time != event.start_time):
+ log_desc = log_desc + "<strong>Start time:</strong> " + str(previous_object.start_time) + " to " + str(event.start_time) + "<br />"
event.end_time = end_time
+ if (previous_object.end_time != event.end_time):
+ log_desc = log_desc + "<strong>End time:</strong> " + str(previous_object.end_time) + " to " + str(event.end_time) + "<br />"
event.estimated_size = cgi.escape(self.request.get('estimated_size'))
+ if (previous_object.estimated_size != event.estimated_size):
+ log_desc = log_desc + "<strong>Est. size:</strong> " + previous_object.estimated_size + " to " + event.estimated_size + "<br />"
event.contact_name = cgi.escape(self.request.get('contact_name'))
+ if (previous_object.contact_name != event.contact_name):
+ log_desc = log_desc + "<strong>Contact:</strong> " + previous_object.contact_name + " to " + event.contact_name + "<br />"
event.contact_phone = cgi.escape(self.request.get('contact_phone'))
+ if (previous_object.contact_phone != event.contact_phone):
+ log_desc = log_desc + "<strong>Contact phone:</strong> " + previous_object.contact_phone + " to " + event.contact_phone + "<br />"
event.details = cgi.escape(self.request.get('details'))
+ if (previous_object.details != event.details):
+ log_desc = log_desc + "<strong>Details:</strong> " + previous_object.details + " to " + event.details + "<br />"
event.url = cgi.escape(self.request.get('url'))
+ if (previous_object.url != event.url):
+ log_desc = log_desc + "<strong>Url:</strong> " + previous_object.url + " to " + event.url + "<br />"
event.fee = cgi.escape(self.request.get('fee'))
+ if (previous_object.fee != event.fee):
+ log_desc = log_desc + "<strong>Fee:</strong> " + previous_object.fee + " to " + event.fee + "<br />"
event.notes = cgi.escape(self.request.get('notes'))
+ if (previous_object.notes != event.notes):
+ log_desc = log_desc + "<strong>Notes:</strong> " + previous_object.notes + " to " + event.notes + "<br />"
event.rooms = self.request.get_all('rooms')
+ if (previous_object.rooms != event.rooms):
+ log_desc = log_desc + "<strong>Rooms changed</strong>" + "<br />"
+ log_desc = log_desc + "<strong>Old room</strong>" + "<br />"
+ for room in previous_object.rooms:
+ log_desc = log_desc + room + ' '
+ log_desc = log_desc + "<br /><strong>New room(s)</strong><br />"
+ 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
8 templates/edit.html
@@ -5,16 +5,16 @@
<form method=POST>
<div id="primary">
- <h3>Edit: {{event.name}}</h3>
- <div class='b-block'><div class='b-label'>Title:</div><div class='b-data'><input type="text" name="name" value="{{event.name}}"/></div></div>
+ <h3>Edit: {{event.name|title}}</h3>
+ <div class='b-block'><div class='b-label'>Title:</div><div class='b-data'><input type="text" name="name" value="{{event.name|title}}"/></div></div>
<div class='b-block' id="message">
</div>
<div class='b-block'>
<div class='b-label'>When:</div>
<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 %}
@@ -67,7 +67,7 @@
<div class='b-block'><div class='b-label'>More Info:</div><div class='b-data'><textarea rows=4 name="details">{{event.details}}</textarea></div></div>
<div class='b-block'><div class='b-label'>Notes:</div><div class='b-data'><textarea rows=3 name="notes">{{event.notes}}</textarea></div></div>
<div class='b-block'><div class='b-label'>Estimated Size:</div><div class='b-data'><input type="text" name="estimated_size" value="{{event.estimated_size}}"/></div></div>
- <div class='b-block'><div class='b-label'>Contact Name:</div><div class='b-data'><input type="text" name="contact_name" value="{{event.contact_name}}"/></div></div>
+ <div class='b-block'><div class='b-label'>Contact Name:</div><div class='b-data'><input type="text" name="contact_name" value="{{event.contact_name|title}}"/></div></div>
<div class='b-block'><div class='b-label'>Contact Phone:</div><div class='b-data'><input type="text" name="contact_phone" value="{{event.contact_phone}}"/></div></div>
<div class='b-block'><div class='b-label'>URL:</div><div class='b-data'><input type="text" name="url" value="{{event.url}}"/></div></div>
<div class='b-block'><div class='b-label'>Fee:</div><div class='b-data'><input type="text" name="fee" value="{{event.fee}}"/></div></div>

0 comments on commit 253420a

Please sign in to comment.
Something went wrong with that request. Please try again.