def POST_traffic_viewer(self, form, jquery, user, thing): """ Adds a user to the list of users allowed to view a promoted link's traffic page. """ if not form.has_errors("name", errors.USER_DOESNT_EXIST, errors.NO_USER): form.set_inputs(name="") form.set_html(".status:first", _("added")) if promote.add_traffic_viewer(thing, user): user_row = TrafficViewerList(thing).user_row( 'traffic_viewer', user) jquery(".traffic_viewer-table").show().find( "table").insert_table_rows(user_row) # send the user a message msg = user_added_messages['traffic']['pm']['msg'] subj = user_added_messages['traffic']['pm']['subject'] if msg and subj: d = dict(url=thing.make_permalink_slow(), traffic_url=promote.promo_traffic_url(thing), title=thing.title) msg = msg % d item, inbox_rel = Message._new(c.user, user, subj, msg, request.ip) queries.new_message(item, inbox_rel)
def POST_traffic_viewer(self, form, jquery, user, thing): """ Adds a user to the list of users allowed to view a promoted link's traffic page. """ if not form.has_errors("name", errors.USER_DOESNT_EXIST, errors.NO_USER): form.set_inputs(name="") form.set_html(".status:first", _("added")) if promote.add_traffic_viewer(thing, user): user_row = TrafficViewerList(thing).user_row('traffic_viewer', user) jquery(".traffic_viewer-table").show( ).find("table").insert_table_rows(user_row) # send the user a message msg = user_added_messages['traffic']['pm']['msg'] subj = user_added_messages['traffic']['pm']['subject'] if msg and subj: d = dict(url=thing.make_permalink_slow(), traffic_url=promote.promo_traffic_url(thing), title=thing.title) msg = msg % d item, inbox_rel = Message._new(c.user, user, subj, msg, request.ip) queries.new_message(item, inbox_rel)
def __init__(self, thing, comments = True, delete = True, report = True): # is the current user the author? is_author = (c.user_is_loggedin and thing.author and c.user.name == thing.author.name) # do we show the report button? show_report = not is_author and report # do we show the delete button? show_delete = is_author and delete and not thing._deleted # do we show the distinguish button? among other things, # we never want it to appear on link listings -- only # comments pages show_distinguish = (is_author and thing.can_ban and getattr(thing, "expand_children", False)) kw = {} if thing.promoted is not None: now = datetime.now(g.tz) promotable = (thing._date <= now and thing.promote_until > now) kw = dict(promo_url = promo_edit_url(thing), promote_bid = thing.promote_bid, promote_status = getattr(thing, "promote_status", 0), user_is_sponsor = c.user_is_sponsor, promotable = promotable, traffic_url = promo_traffic_url(thing), is_author = thing.is_author) PrintableButtons.__init__(self, 'linkbuttons', thing, # user existence and preferences is_loggedin = c.user_is_loggedin, new_window = c.user.pref_newwindow, # comment link params comment_label = thing.comment_label, commentcls = thing.commentcls, permalink = thing.permalink, # button visibility saved = thing.saved, editable = thing.editable, hidden = thing.hidden, show_delete = show_delete, show_report = show_report, show_distinguish = show_distinguish, show_comments = comments, # promotion promoted = thing.promoted, **kw)