Exemplo n.º 1
0
 def get(self, id):
     event = Event.get_by_id(int(id))
     user = users.get_current_user()
     show_all_nav = user
     access_rights = UserRights(user, event)
     if access_rights.can_edit:
         logout_url = users.create_logout_url('/')
         rooms = ROOM_OPTIONS
         hours = [1,2,3,4,5,6,7,8,9,10,11,12]
         self.response.out.write(template.render('templates/edit.html', locals()))
     else:
         self.response.out.write("Access denied")
Exemplo n.º 2
0
    def post(self, id):
        event = Event.get_by_id(int(id))
        user = users.get_current_user()
        access_rights = UserRights(user, event)

        state = self.request.get('state')
        if state:
            desc = ''
            if state.lower() == 'approve' and access_rights.can_approve:
                event.approve()
                desc = 'Approved event'
            if state.lower(
            ) == 'notapproved' and access_rights.can_not_approve:
                event.not_approved()
                desc = 'Event marked not approved'
            if state.lower() == 'rsvp' and user:
                event.rsvp()
                notify_owner_rsvp(event, user)
            if state.lower() == 'staff' and access_rights.can_staff:
                event.add_staff(user)
                desc = 'Added self as staff'
            if state.lower() == 'unstaff' and access_rights.can_unstaff:
                event.remove_staff(user)
                desc = 'Removed self as staff'
            if state.lower() == 'onhold' and access_rights.can_cancel:
                event.on_hold()
                desc = 'Put event on hold'
            if state.lower() == 'cancel' and access_rights.can_cancel:
                event.cancel()
                desc = 'Cancelled event'
            if state.lower() == 'delete' and access_rights.can_delete:
                event.delete()
                desc = 'Deleted event'
                notify_deletion(event, user)
            if state.lower() == 'undelete' and access_rights.can_undelete:
                event.undelete()
                desc = 'Undeleted event'
            if state.lower() == 'expire' and access_rights.is_admin:
                event.expire()
                desc = 'Expired event'
            if event.status == 'approved' and state.lower() == 'approve':
                notify_owner_approved(event)
            if desc != '':
                log = HDLog(event=event, description=desc)
                log.put()
        event.details = db.Text(event.details.replace('\n', '<br/>'))
        show_all_nav = user
        event.notes = db.Text(event.notes.replace('\n', '<br/>'))
        self.response.out.write(
            template.render('templates/event.html', locals()))
Exemplo n.º 3
0
 def get(self, id):
     event = Event.get_by_id(int(id))
     user = users.get_current_user()
     show_all_nav = user
     access_rights = UserRights(user, event)
     # this is not the permanent answer but just for now
     cdn = 'http://cdn.hackerdojo.com'
     if access_rights.can_edit:
         logout_url = users.create_logout_url('/')
         rooms = ROOM_OPTIONS
         hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
         self.response.out.write(
             template.render('templates/edit.html', locals()))
     else:
         self.response.out.write("Access denied")
Exemplo n.º 4
0
    def get(self, id):

        event = Event.get_by_id(int(id))
        if self.request.path.endswith('json'):
            self.response.headers['content-type'] = 'application/json'
            self.response.out.write(simplejson.dumps(event.to_dict()))
        else:
            user = users.get_current_user()
            if user:
                access_rights = UserRights(user, event)
                logout_url = users.create_logout_url('/')

            else:
                login_url = users.create_login_url('/')
            event.details = db.Text(event.details.replace('\n','<br/>'))
            show_all_nav = user
            event.notes = db.Text(event.notes.replace('\n','<br/>'))
            self.response.out.write(template.render('templates/event.html', locals()))
Exemplo n.º 5
0
    def post(self, id):
        event = Event.get_by_id(int(id))
        user = users.get_current_user()
        access_rights = UserRights(user, event)

        state = self.request.get('state')
        if state:
            desc = ''
            if state.lower() == 'approve' and access_rights.can_approve:
                event.approve()
                desc = 'Approved event'
            if state.lower() == 'notapproved' and access_rights.can_not_approve:
                event.not_approved()
                desc = 'Event marked not approved'
            if state.lower() == 'rsvp' and user:
                event.rsvp()
                notify_owner_rsvp(event,user)
            if state.lower() == 'staff' and access_rights.can_staff:
                event.add_staff(user)
                desc = 'Added self as staff'
            if state.lower() == 'unstaff' and access_rights.can_unstaff:
                event.remove_staff(user)
                desc = 'Removed self as staff'
            if state.lower() == 'onhold' and access_rights.can_cancel:
                event.on_hold()
                desc = 'Put event on hold'
            if state.lower() == 'cancel' and access_rights.can_cancel:
                event.cancel()
                desc = 'Cancelled event'
            if state.lower() == 'delete' and access_rights.is_admin:
                event.delete()
                desc = 'Deleted event'
            if state.lower() == 'undelete' and access_rights.is_admin:
                event.undelete()
                desc = 'Undeleted event'
            if state.lower() == 'expire' and access_rights.is_admin:
                event.expire()
                desc = 'Expired event'
            if event.status == 'approved' and state.lower() == 'approve':
                notify_owner_approved(event)
            if desc != '':
                log = HDLog(event=event,description=desc)
                log.put()
        self.redirect(event_path(event))
Exemplo n.º 6
0
 def post(self, id):
     event = Event.get_by_id(int(id))
     user = users.get_current_user()
     access_rights = UserRights(user, event)
     if access_rights.can_edit:
         try:
             start_time = datetime.strptime('%s %s:%s %s' % (
                 self.request.get('start_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('end_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:
                 if "Deck" in self.request.get_all('rooms') or "Savanna" in self.request.get_all('rooms'):
                     raise ValueError('Room conflict detected <small>(Note: Deck &amp; Savanna share the same area, two events cannot take place at the same time in these rooms.)</small>')
                 else:
                     raise ValueError('Room conflict detected')
             if not self.request.get('estimated_size').isdigit():
                 raise ValueError('Estimated number of people must be a number')
             if not int(self.request.get('estimated_size')) > 0:
                 raise ValueError('Estimated number of people must be greater then zero')
             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> " + previous_object.roomlist() + "<br />"
                   log_desc = log_desc + "<strong>New room:</strong> " + event.roomlist() + "<br />"
                 event.put()
                 log = HDLog(event=event,description=log_desc)
                 log.put()
                 self.redirect(event_path(event))
         except ValueError, e:
             error = str(e)
             self.response.out.write(template.render('templates/error.html', locals()))
Exemplo n.º 7
0
    def post(self, id):
        event = Event.get_by_id(int(id))
        user = users.get_current_user()
        # this is not the permanent answer but just for now
        cdn = 'http://cdn.hackerdojo.com'
        access_rights = UserRights(user, event)
        formatted_url = cgi.escape(self.request.get('url'))
        if ("http://" not in event.url and "https://" not in event.url):
            formatted_url = "http://" + formatted_url

        if access_rights.can_edit:
            try:
                start_time = datetime.strptime(
                    '%s %s:%s %s' % (self.request.get('start_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('end_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:
                    if "Deck" in self.request.get_all(
                            'rooms') or "Savanna" in self.request.get_all(
                                'rooms'):
                        raise ValueError(
                            'Room conflict detected <small>(Note: Deck &amp; Savanna share the same area, two events cannot take place at the same time in these rooms.)</small>'
                        )
                    else:
                        raise ValueError('Room conflict detected')
                if not self.request.get('details'):
                    raise ValueError(
                        'You must provide a description of the event')
                if not self.request.get('estimated_size').isdigit():
                    raise ValueError(
                        'Estimated number of people must be a number')
                if not int(self.request.get('estimated_size')) > 0:
                    raise ValueError(
                        'Estimated number of people must be greater then zero')
                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 = ""
                    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 = formatted_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> " + previous_object.roomlist(
                        ) + "<br />"
                        log_desc = log_desc + "<strong>New room:</strong> " + event.roomlist(
                        ) + "<br />"
                    event.put()
                    log = HDLog(event=event,
                                description="Event edited<br />" + log_desc)
                    log.put()
                    show_all_nav = user
                    access_rights = UserRights(user, event)
                    if access_rights.can_edit:
                        logout_url = users.create_logout_url('/')
                        rooms = ROOM_OPTIONS
                        hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
                        if log_desc:
                            edited = "<u>Saved changes:</u><br>" + log_desc
                        self.response.out.write(
                            template.render('templates/edit.html', locals()))
                    else:
                        self.response.out.write("Access denied")

            except ValueError, e:
                error = str(e)
                # this is not the permanent answer but just for now
                cdn = 'http://cdn.hackerdojo.com'
                self.response.out.write(
                    template.render('templates/error.html', locals()))
Exemplo n.º 8
0
 def post(self, id):
     event = Event.get_by_id(int(id))
     user = users.get_current_user()
     access_rights = UserRights(user, event)
     if access_rights.can_edit:
         try:
             start_time = datetime.strptime(
                 '%s %s:%s %s' % (self.request.get('start_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('end_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('setup'),
                                              self.request.get('teardown'),
                                              self.request.get_all('rooms'),
                                              int(id))
             if conflicts:
                 raise ValueError('Room conflict detected')
             if not self.request.get('details'):
                 raise ValueError(
                     'You must provide a description of the event')
             if not self.request.get('estimated_size').isdigit():
                 raise ValueError(
                     'Estimated number of people must be a number')
             if not int(self.request.get('estimated_size')) > 0:
                 raise ValueError(
                     'Estimated number of people must be greater then zero')
             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')
             if start_time == end_time:
                 raise ValueError(
                     'End time for the event cannot be the same as the start time'
                 )
             else:
                 log_desc = ""
                 previous_object = Event.get_by_id(int(id))
                 event.status = 'pending'
                 event.name = self.request.get('name')
                 if (previous_object.name != event.name):
                     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 += "<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 += "<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 += "<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 += "<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 += "<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 += "<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 += "<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 += "<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 += "<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 += "<strong>Rooms changed</strong><br />"
                     log_desc += "<strong>Old room:</strong> " + previous_object.roomlist(
                     ) + "<br />"
                     log_desc += "<strong>New room:</strong> " + event.roomlist(
                     ) + "<br />"
                 setup = cgi.escape(self.request.get('setup')) or 0
                 event.setup = int(setup)
                 if (previous_object.setup != event.setup):
                     log_desc += "<strong>Setup time changed</strong><br />"
                     log_desc += "<strong>Old time:</strong> %s minutes<br/>" % previous_object.setup
                     log_desc += "<strong>New time:</strong> %s minutes<br/>" % event.setup
                 teardown = cgi.escape(self.request.get('teardown')) or 0
                 event.teardown = int(teardown)
                 if (previous_object.teardown != event.teardown):
                     log_desc += "<strong>Teardown time changed</strong><br />"
                     log_desc += "<strong>Old time:</strong> %s minutes<br/>" % previous_object.teardown
                     log_desc += "<strong>New time:</strong> %s minutes<br/>" % event.teardown
                 log = HDLog(event=event,
                             description="Event edited<br />" + log_desc)
                 log.put()
                 show_all_nav = user
                 access_rights = UserRights(user, event)
                 if access_rights.can_edit:
                     logout_url = users.create_logout_url('/')
                     rooms = ROOM_OPTIONS
                     hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
                     if log_desc:
                         edited = "<u>Saved changes:</u><br>" + log_desc
                     notify_event_change(event=event, modification=1)
                     event.put()
                     self.response.out.write(
                         template.render('templates/edit.html', locals()))
                 else:
                     self.response.out.write("Access denied")
         except NameError, e:
             logging.log(e)
             self.response.out.write(
                 template.render('templates/error.html', locals()))