• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.HDLog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: post

    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() == "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() == "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":
                notify_owner_approved(event)
            if desc != "":
                log = HDLog(event=event, description=desc)
                log.put()
        self.redirect(event_path(event))
开发者ID:deanmao,项目名称:hd-events,代码行数:35,代码来源:main.py


示例2: post

 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,代码行数:59,代码来源:main.py


示例3: post

    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()))
开发者ID:jernst,项目名称:hd-events,代码行数:48,代码来源:main.py


示例4: post

    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()
        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()))
开发者ID:billsaysthis,项目名称:hd-events,代码行数:47,代码来源:main.py


示例5: get

 def get(self):
     user = users.get_current_user()
     logs = HDLog.get_logs_list()
     if user:
         logout_url = users.create_logout_url('/')
     else:
         login_url = users.create_login_url('/')
     show_all_nav = user
     self.response.out.write(template.render('templates/logs.html', locals()))
开发者ID:jernst,项目名称:hd-events,代码行数:9,代码来源:main.py


示例6: post

    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))
开发者ID:braghome,项目名称:hd-events,代码行数:44,代码来源:main.py


示例7: get

 def get(self):
     user = users.get_current_user()
     logs = HDLog.get_logs_list()
     if user:
         logout_url = users.create_logout_url("/")
     else:
         login_url = users.create_login_url("/")
     show_all_nav = user
     # this is not the permanent answer but just for now
     cdn = "http://cdn.hackerdojo.com"
     self.response.out.write(template.render("templates/logs.html", locals()))
开发者ID:billsaysthis,项目名称:hd-events,代码行数:11,代码来源:main.py


示例8: post

    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,代码行数:76,代码来源:main.py


示例9: post

 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,代码行数:70,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.History类代码示例发布时间:2022-05-27
下一篇:
Python models.Group类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap