当前位置: 首页>>代码示例>>Python>>正文


Python Event.check_conflict方法代码示例

本文整理汇总了Python中models.Event.check_conflict方法的典型用法代码示例。如果您正苦于以下问题:Python Event.check_conflict方法的具体用法?Python Event.check_conflict怎么用?Python Event.check_conflict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Event的用法示例。


在下文中一共展示了Event.check_conflict方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import check_conflict [as 别名]
 def post(self):
     user = users.get_current_user()
     try:
         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'))
         if conflicts:
           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 (end_time-start_time).days < 0:
             raise ValueError('End time must be after start time')
         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:
             event = Event(
                 name = cgi.escape(self.request.get('name')),
                 start_time = start_time,
                 end_time = end_time,
                 type = cgi.escape(self.request.get('type')),
                 estimated_size = cgi.escape(self.request.get('estimated_size')),
                 contact_name = cgi.escape(self.request.get('contact_name')),
                 contact_phone = cgi.escape(self.request.get('contact_phone')),
                 details = cgi.escape(self.request.get('details')),
                 url = cgi.escape(self.request.get('url')),
                 fee = cgi.escape(self.request.get('fee')),
                 notes = cgi.escape(self.request.get('notes')),
                 rooms = self.request.get_all('rooms'),
                 expired = local_today() + timedelta(days=PENDING_LIFETIME), # Set expected expiration date
                 )
             event.put()
             log = HDLog(event=event,description="Created new event")
             log.put()
             notify_owner_confirmation(event)
             notify_new_event(event)
             set_cookie(self.response.headers, 'formvalues', None)
             self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
     except Exception, e:
         message = str(e)
         if 'match format' in message:
             message = 'Date is required.'
         if message.startswith('Property'):
             message = message[9:].replace('_', ' ').capitalize()
         # This is NOT a reliable way to handle erorrs
         #set_cookie(self.response.headers, 'formerror', message)
         #set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
         #self.redirect('/new')
         error = message
         self.response.out.write(template.render('templates/error.html', locals()))
开发者ID:stighackvan,项目名称:hd-events,代码行数:61,代码来源:main.py

示例2: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import check_conflict [as 别名]
    def post(self):
        user = users.get_current_user()
        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')
            )
            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 (end_time-start_time).days < 0:
                raise ValueError('End time must be after start time')
            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:
                event = Event(
                    name = cgi.escape(self.request.get('name')),
                    start_time = start_time,
                    end_time = end_time,
                    type = cgi.escape(self.request.get('type')),
                    estimated_size = cgi.escape(self.request.get('estimated_size')),
                    contact_name = cgi.escape(self.request.get('contact_name')),
                    contact_phone = cgi.escape(self.request.get('contact_phone')),
                    details = cgi.escape(self.request.get('details')),
                    url = cgi.escape(self.request.get('url')),
                    fee = cgi.escape(self.request.get('fee')),
                    notes = cgi.escape(self.request.get('notes')),
                    rooms = self.request.get_all('rooms'),
                    expired = local_today() + timedelta(days=PENDING_LIFETIME), # Set expected expiration date
                    setup = int(self.request.get('setup') or 0),
                    teardown = int(self.request.get('teardown') or 0)
                )
                event.put()
                log = HDLog(event=event,description="Created new event")
                log.put()
                notify_owner_confirmation(event)
                notify_event_change(event)
                set_cookie(self.response.headers, 'formvalues', None)

                rules = memcache.get("rules")
                if(rules is None):
                    try:
                        rules = urlfetch.fetch("http://wiki.hackerdojo.com/api_v2/op/GetPage/page/Event+Policies/_type/html", "GET").content
                        memcache.add("rules", rules, 86400)
                    except Exception, e:
                        rules = "Error fetching rules.  Please report this error to [email protected]"
                self.response.out.write(template.render('templates/confirmation.html', locals()))


        except ValueError, e:
            message = str(e)
            if 'match format' in message:
                message = 'Date is required.'
            if message.startswith('Property'):
                message = message[9:].replace('_', ' ').capitalize()
            # This is NOT a reliable way to handle erorrs
            #set_cookie(self.response.headers, 'formerror', message)
            #set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
            #self.redirect('/new')
            error = message
            self.response.out.write(template.render('templates/error.html', locals()))
开发者ID:jernst,项目名称:hd-events,代码行数:83,代码来源:main.py

示例3: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import check_conflict [as 别名]
    def post(self):
        user = users.get_current_user()
        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"))
            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 (end_time - start_time).days < 0:
                raise ValueError("End time must be after start time")
            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:
                event = Event(
                    name=cgi.escape(self.request.get("name")),
                    start_time=start_time,
                    end_time=end_time,
                    type=cgi.escape(self.request.get("type")),
                    estimated_size=cgi.escape(self.request.get("estimated_size")),
                    contact_name=cgi.escape(self.request.get("contact_name")),
                    contact_phone=cgi.escape(self.request.get("contact_phone")),
                    details=cgi.escape(self.request.get("details")),
                    url=cgi.escape(self.request.get("url")),
                    fee=cgi.escape(self.request.get("fee")),
                    notes=cgi.escape(self.request.get("notes")),
                    rooms=self.request.get_all("rooms"),
                    expired=local_today() + timedelta(days=PENDING_LIFETIME),  # Set expected expiration date
                )
                event.put()
                log = HDLog(event=event, description="Created new event")
                log.put()
                notify_owner_confirmation(event)
                notify_new_event(event)
                set_cookie(self.response.headers, "formvalues", None)

                rules = memcache.get("rules")
                if rules is None:
                    try:
                        rules = urlfetch.fetch(
                            "http://wiki.hackerdojo.com/api_v2/op/GetPage/page/Event+Policies/_type/html", "GET"
                        ).content
                        memcache.add("rules", rules, 86400)
                    except Exception, e:
                        rules = "Error fetching rules.  Please report this error to [email protected]"
                self.response.out.write(template.render("templates/confirmation.html", locals()))

        except Exception, e:
            message = str(e)
            if "match format" in message:
                message = "Date is required."
            if message.startswith("Property"):
                message = message[9:].replace("_", " ").capitalize()
            # This is NOT a reliable way to handle erorrs
            # set_cookie(self.response.headers, 'formerror', message)
            # set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
            # self.redirect('/new')
            error = message
            # 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()))
开发者ID:billsaysthis,项目名称:hd-events,代码行数:91,代码来源:main.py

示例4: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import check_conflict [as 别名]
    def post(self):
        user = users.get_current_user()
        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"))
            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 (end_time - start_time).days < 0:
                raise ValueError("End time must be after start time")
            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:
                event = Event(
                    name=cgi.escape(self.request.get("name")),
                    start_time=start_time,
                    end_time=end_time,
                    type=cgi.escape(self.request.get("type")),
                    estimated_size=cgi.escape(self.request.get("estimated_size")),
                    contact_name=cgi.escape(self.request.get("contact_name")),
                    contact_phone=cgi.escape(self.request.get("contact_phone")),
                    details=cgi.escape(self.request.get("details")),
                    url=cgi.escape(self.request.get("url")),
                    fee=cgi.escape(self.request.get("fee")),
                    notes=cgi.escape(self.request.get("notes")),
                    rooms=self.request.get_all("rooms"),
                    expired=local_today() + timedelta(days=PENDING_LIFETIME),  # Set expected expiration date
                )
                event.put()
                log = HDLog(event=event, description="Created new event")
                log.put()
                notify_owner_confirmation(event)
                notify_new_event(event)
                set_cookie(self.response.headers, "formvalues", None)
                # self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
                self.redirect("/confirm/%s-%s" % (event.key().id(), slugify(event.name)))

        except Exception, e:
            message = str(e)
            if "match format" in message:
                message = "Date is required."
            if message.startswith("Property"):
                message = message[9:].replace("_", " ").capitalize()
            # This is NOT a reliable way to handle erorrs
            # set_cookie(self.response.headers, 'formerror', message)
            # set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
            # self.redirect('/new')
            error = message
            self.response.out.write(template.render("templates/error.html", locals()))
开发者ID:kiwinoy,项目名称:hd-events,代码行数:78,代码来源:main.py

示例5: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import check_conflict [as 别名]
    def post(self):
        user = users.get_current_user()
        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'))
            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 int(self.request.get('estimated_size')) > 47:
                raise ValueError('Hacker Dojo temporarily is under order of the City of Mountain View to not allow assemblies larger than 49 persons.  Sorry, your event exceeds this size.  <p>NOTE: Lying about the event size to get around this restriction will result in membership ban plus possible legal action.  We will be fined $1500 for each violation, which will be passed on to the event host.')              
            if (end_time-start_time).days < 0:
                raise ValueError('End time must be after start time')
            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:
                event = Event(
                    name = cgi.escape(self.request.get('name')),
                    start_time = start_time,
                    end_time = end_time,
                    type = cgi.escape(self.request.get('type')),
                    estimated_size = cgi.escape(self.request.get('estimated_size')),
                    contact_name = cgi.escape(self.request.get('contact_name')),
                    contact_phone = cgi.escape(self.request.get('contact_phone')),
                    details = cgi.escape(self.request.get('details')),
                    url = cgi.escape(self.request.get('url')),
                    fee = cgi.escape(self.request.get('fee')),
                    notes = cgi.escape(self.request.get('notes')),
                    rooms = self.request.get_all('rooms'),
                    expired = local_today() + timedelta(days=PENDING_LIFETIME), # Set expected expiration date
                    )
                event.put()
                log = HDLog(event=event,description="Created new event")
                log.put()
                notify_owner_confirmation(event)
                notify_new_event(event)
                set_cookie(self.response.headers, 'formvalues', None)
                #self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
                self.redirect('/confirm/%s-%s' % (event.key().id(), slugify(event.name)))

        except Exception, e:
            message = str(e)
            if 'match format' in message:
                message = 'Date is required.'
            if message.startswith('Property'):
                message = message[9:].replace('_', ' ').capitalize()
            # This is NOT a reliable way to handle erorrs
            #set_cookie(self.response.headers, 'formerror', message)
            #set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
            #self.redirect('/new')
            error = message
            self.response.out.write(template.render('templates/error.html', locals()))
开发者ID:braghome,项目名称:hd-events,代码行数:68,代码来源:main.py

示例6: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import check_conflict [as 别名]
 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('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')
             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()))
开发者ID:bluehat,项目名称:hd-events,代码行数:72,代码来源:main.py


注:本文中的models.Event.check_conflict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。