def create_comment(store, wbtip_id, request): wbtip = db_access_wbtip(store, wbtip_id) wbtip.internaltip.update_date = datetime_now() comment = Comment() comment.content = request['content'] comment.internaltip_id = wbtip.id comment.type = u'whistleblower' wbtip.internaltip.comments.add(comment) return serialize_comment(comment)
def create_comment_receiver(store, user_id, tip_id, request): rtip = db_access_tip(store, user_id, tip_id) comment = Comment() comment.content = request['content'] comment.internaltip_id = rtip.internaltip.id comment.author = rtip.receiver.name comment.type = u'receiver' rtip.internaltip.comments.add(comment) return receiver_serialize_comment(comment)
def create_comment_receiver(store, user_id, tip_id, request): rtip = access_tip(store, user_id, tip_id) comment = Comment() comment.content = request['content'] comment.internaltip_id = rtip.internaltip.id comment.author = rtip.receiver.name # The printed line comment.type = Comment._types[0] # Receiver comment.mark = Comment._marker[0] # Not notified rtip.internaltip.comments.add(comment) return receiver_serialize_comment(comment)
def create_comment(store, user_id, rtip_id, request): rtip = db_access_rtip(store, user_id, rtip_id) rtip.internaltip.update_date = datetime_now() comment = Comment() comment.content = request['content'] comment.internaltip_id = rtip.internaltip.id comment.author = rtip.receiver.user.name comment.type = u'receiver' rtip.internaltip.comments.add(comment) return serialize_comment(comment)
def create_comment_receiver(store, user_id, tip_id, request): rtip = access_tip(store, user_id, tip_id) comment = Comment() comment.content = request['content'] comment.internaltip_id = rtip.internaltip.id comment.author = rtip.receiver.name # The printed line comment.type = u'receiver' comment.mark = u'not notified' rtip.internaltip.comments.add(comment) return receiver_serialize_comment(comment)
def create_comment_wb(store, wb_tip_id, request): wbtip = store.find(WhistleblowerTip, WhistleblowerTip.id == unicode(wb_tip_id)).one() if not wbtip: raise errors.TipReceiptNotFound comment = Comment() comment.content = request['content'] comment.internaltip_id = wbtip.internaltip.id comment.author = u'whistleblower' comment.type = u'whistleblower' wbtip.internaltip.comments.add(comment) return wb_serialize_comment(comment)
def create_comment_wb(store, wb_tip_id, request): wbtip = store.find(WhistleblowerTip, WhistleblowerTip.id == unicode(wb_tip_id)).one() if not wbtip: raise errors.TipReceiptNotFound comment = Comment() comment.content = request['content'] comment.internaltip_id = wbtip.internaltip.id comment.author = u'whistleblower' # The printed line comment.type = Comment._types[1] # WB comment.mark = Comment._marker[0] # Not notified wbtip.internaltip.comments.add(comment) return wb_serialize_comment(comment)
def postpone_expiration_date(store, user_id, tip_id): rtip = access_tip(store, user_id, tip_id) node = store.find(Node).one() if not (node.postpone_superpower or rtip.internaltip.context.postpone_superpower or rtip.receiver.postpone_superpower): raise errors.ExtendTipLifeNotEnabled() else: log.debug("Postpone check: Node %s, Context %s, Receiver %s" %( "True" if node.postpone_superpower else "False", "True" if rtip.internaltip.context.postpone_superpower else "False", "True" if rtip.receiver.postpone_superpower else "False" )) rtip.internaltip.expiration_date = \ utc_future_date(seconds=rtip.internaltip.context.tip_timetolive) log.debug(" [%s] in %s has extended expiration time to %s" % ( rtip.receiver.name, datetime_to_pretty_str(datetime_now()), datetime_to_pretty_str(rtip.internaltip.expiration_date))) comment = Comment() comment.system_content = dict({ 'type': "1", # the first kind of structured system_comments 'receiver_name': rtip.receiver.name, 'expire_on' : datetime_to_ISO8601(rtip.internaltip.expiration_date) }) # remind: this is put just for debug, it's never used in the flow # and a system comment may have nothing to say except the struct comment.content = "%s %s %s (UTC)" % ( rtip.receiver.name, datetime_to_pretty_str(datetime_now()), datetime_to_pretty_str(rtip.internaltip.expiration_date)) comment.internaltip_id = rtip.internaltip.id comment.author = u'System' # The printed line comment.type = Comment._types[2] # System comment.mark = Comment._marker[4] # skipped rtip.internaltip.comments.add(comment)
def postpone_expiration_date(store, user_id, tip_id): rtip = access_tip(store, user_id, tip_id) node = store.find(Node).one() if not (node.postpone_superpower or rtip.internaltip.context.postpone_superpower or rtip.receiver.postpone_superpower): raise errors.ExtendTipLifeNotEnabled() else: log.debug("Postpone check: Node %s, Context %s, Receiver %s" % ("True" if node.postpone_superpower else "False", "True" if rtip.internaltip.context.postpone_superpower else "False", "True" if rtip.receiver.postpone_superpower else "False")) rtip.internaltip.expiration_date = \ utc_future_date(seconds=rtip.internaltip.context.tip_timetolive) log.debug(" [%s] in %s has extended expiration time to %s" % (rtip.receiver.name, datetime_to_pretty_str(datetime_now()), datetime_to_pretty_str(rtip.internaltip.expiration_date))) comment = Comment() comment.system_content = dict({ 'type': "1", # the first kind of structured system_comments 'receiver_name': rtip.receiver.name, 'expire_on': datetime_to_ISO8601(rtip.internaltip.expiration_date) }) # remind: this is put just for debug, it's never used in the flow # and a system comment may have nothing to say except the struct comment.content = "%s %s %s (UTC)" % ( rtip.receiver.name, datetime_to_pretty_str(datetime_now()), datetime_to_pretty_str(rtip.internaltip.expiration_date)) comment.internaltip_id = rtip.internaltip.id comment.author = u'System' comment.type = u'system' comment.mark = u'skipped' rtip.internaltip.comments.add(comment)
def delete_receiver_tip(store, user_id, tip_id): """ This operation is permitted to every receiver, and trigger a System comment on the Tip history. """ rtip = access_tip(store, user_id, tip_id) comment = Comment() comment.content = "%s personally remove from this Tip" % rtip.receiver.name comment.system_content = dict({ "type" : 2, "receiver_name" : rtip.receiver.name}) comment.internaltip_id = rtip.internaltip.id comment.author = u'System' # The printed line comment.type = u'system' # Comment._types[2] comment.mark = u'not notified' # Comment._marker[0] rtip.internaltip.comments.add(comment) store.remove(rtip)
def delete_receiver_tip(store, user_id, tip_id): """ This operation is permitted to every receiver, and trigger a System comment on the Tip history. """ rtip = access_tip(store, user_id, tip_id) comment = Comment() comment.content = "%s personally remove from this Tip" % rtip.receiver.name comment.system_content = dict({ "type": 2, "receiver_name": rtip.receiver.name }) comment.internaltip_id = rtip.internaltip.id comment.author = u'system' # The printed line comment.type = u'system' comment.mark = u'not notified' rtip.internaltip.comments.add(comment) store.remove(rtip)