def __init__(self, link): self.thing = link self.edit_url = promote.promo_edit_url(link) self.is_preliminary = False campaigns = PromoCampaign._by_link(link._id) camps = {} fullnames = [] for campaign in campaigns: campaign.imps = 0 campaign.clicks = 0 if not self.is_preliminary and is_preliminary(campaign.end_date): self.is_preliminary = True camps[campaign._fullname] = campaign fullnames.append(campaign._fullname) click_data = traffic.TargetedClickthroughsByCodename.total_by_codename( fullnames) for fullname, clicks in click_data: camps[fullname].clicks = clicks imp_data = traffic.TargetedImpressionsByCodename.total_by_codename( fullnames) for fullname, imps in imp_data: camps[fullname].imps = imps self.campaigns = camps.values() self.total_clicks = self.total_imps = self.total_spend = 0 for camp in self.campaigns: self.total_clicks += camp.clicks self.total_imps += camp.imps self.total_spend += camp.bid camp.ctr = ctr(camp.imps, camp.clicks) camp.cpc = cpc(camp.bid, camp.clicks) camp.cpm = cpm(camp.bid, camp.imps) self.total_ctr = ctr(self.total_imps, self.total_clicks) self.total_cpc = cpc(self.total_spend, self.total_clicks) self.total_cpm = cpm(self.total_spend, self.total_imps) Templated.__init__(self)
def __init__(self, user): Templated.__init__( self, deleted=user._deleted, name=user.name, fullname=user._fullname, )
def __init__(self, content, edit_by, edit_date, may_revise=False, page=None, diff=None, renderer='wiki', sr_path=True): self.page_content_md = content if renderer == 'wiki': self.page_content = wikimarkdown(content) elif renderer == 'reddit': self.page_content = safemarkdown(content) elif renderer == 'stylesheet': self.page_content = SubredditStylesheetSource(content).render() elif renderer == "automoderator": self.page_content = AutoModeratorConfig(content).render() elif renderer == "rawcode": self.page_content = RawCode(content).render() self.renderer = renderer self.page = page self.diff = diff self.edit_by = edit_by self.may_revise = may_revise self.edit_date = edit_date self.base_url = c.wiki_base_url self.sr_path = sr_path Templated.__init__(self)
def __init__(self, link): self.thing = link self.edit_url = promote.promo_edit_url(link) self.is_preliminary = False campaigns = PromoCampaign._by_link(link._id) camps = {} fullnames = [] for campaign in campaigns: campaign.imps = 0 campaign.clicks = 0 self.is_preliminary |= _is_promo_preliminary(campaign.end_date) camps[campaign._fullname] = campaign fullnames.append(campaign._fullname) click_data = traffic.TargetedClickthroughsByCodename.total_by_codename( fullnames) for fullname, clicks in click_data: camps[fullname].clicks = clicks imp_data = traffic.TargetedImpressionsByCodename.total_by_codename( fullnames) for fullname, imps in imp_data: camps[fullname].imps = imps self.campaigns = camps.values() self.total_clicks = self.total_imps = self.total_spend = 0 for camp in self.campaigns: self.total_clicks += camp.clicks self.total_imps += camp.imps self.total_spend += camp.bid camp.ctr = _clickthrough_rate(camp.imps, camp.clicks) camp.cpc = cost_per_click(camp.bid, camp.clicks) camp.cpm = cost_per_mille(camp.bid, camp.imps) self.total_ctr = _clickthrough_rate(self.total_imps, self.total_clicks) self.total_cpc = cost_per_click(self.total_spend, self.total_clicks) self.total_cpm = cost_per_mille(self.total_spend, self.total_imps) Templated.__init__(self)
def __init__(self, thing, campaign, before, after): self.thing = thing self.campaign = campaign self.before = before self.after = after self.prev = None self.next = None self.has_live_campaign = False self.has_early_campaign = False self.detail_name = ('campaign %s' % campaign._id36 if campaign else 'all campaigns') self.has_adserver_reporting = feature.is_enabled("adserver_reporting") self.use_adserver_reporting = _use_adserver_reporting(thing) self.has_spent = self.use_adserver_reporting editable = c.user_is_sponsor or c.user._id == thing.author_id if self.use_adserver_reporting: # can't get this info from adserver self.traffic_last_modified = False else: self.traffic_last_modified = traffic.get_traffic_last_modified() self.traffic_lag = (datetime.datetime.utcnow() - self.traffic_last_modified) self.interval = self.get_interval(thing) self.period = datetime.timedelta(days=30 if self.interval == "day" else 7) self.make_table(campaign or thing) self.make_campaign_table() Templated.__init__(self)
def __init__(self, thing, campaign, before, after): self.thing = thing self.campaign = campaign self.before = before self.after = after self.prev = None self.next = None self.has_live_campaign = False self.has_early_campaign = False self.detail_name = ('campaign %s' % campaign._id36 if campaign else 'all campaigns') self.has_adserver_reporting = feature.is_enabled("adserver_reporting") self.use_adserver_reporting = _use_adserver_reporting(thing) self.has_spent = self.use_adserver_reporting editable = c.user_is_sponsor or c.user._id == thing.author_id if self.use_adserver_reporting: # can't get this info from adserver self.traffic_last_modified = False else: self.traffic_last_modified = traffic.get_traffic_last_modified() self.traffic_lag = (datetime.datetime.utcnow() - self.traffic_last_modified) self.interval = self.get_interval(thing) self.period = datetime.timedelta( days=30 if self.interval == "day" else 7) self.make_table(campaign or thing) self.make_campaign_table() Templated.__init__(self)
def __init__(self, system, subject): self.chat_channel = quote(g.live_config['chat_channel_name_prefix'] + subject + g.live_config['chat_channel_name_suffix']) # CUSTOM - chat plugin upgrade script if c.user_is_loggedin and c.user.pref_chat_client_user == "guest": # g.log.warning("!!! chat plugin: upgrading chat preferences for user: %s" % c.user.name) prefs = { 'pref_chat_client_user': "".join(random.choice(string.ascii_letters+string.digits) for i in range(20)), 'pref_chat_client_password': "".join(random.choice(string.ascii_letters+string.digits) for i in range(20)) } if c.user.pref_chat_user == "guest": # g.log.warning("!!! chat plugin: upgrading chat user for user: %s" % c.user.name) prefs["pref_chat_user"] = c.user.name set_prefs(c.user, prefs) c.user._commit() self.chat_user = c.user.pref_chat_user self.chat_client_user = c.user.pref_chat_client_user self.chat_client_password = c.user.pref_chat_client_password self.chat_client = g.live_config['chat_client'] self.chat_client_url = g.live_config['chat_client_url'] self.user_is_loggedin = c.user_is_loggedin Templated.__init__(self)
def __init__(self, settings, mayedit, show_editors=True, show_settings=True, page=None, **context): self.permlevel = settings["permlevel"] self.show_settings = show_settings self.show_editors = show_editors self.page = page self.base_url = c.wiki_base_url self.mayedit = mayedit Templated.__init__(self)
def __init__(self, content, edit_by, edit_date, diff=None): self.page_content = wikimarkdown(content) if content else '' self.page_content_md = content self.diff = diff self.edit_by = edit_by self.edit_date = edit_date self.base_url = c.wiki_base_url self.may_revise = this_may_revise(c.page_obj) Templated.__init__(self)
def __init__(self): links = self.get_links(c.liveupdate_event._id) self.more_links = len(links) > self.max_links self.links = links[: self.max_links] self.submit_url = "/submit?" + urllib.urlencode( {"url": make_event_url(c.liveupdate_event._id), "title": c.liveupdate_event.title.encode("utf-8")} ) Templated.__init__(self)
def __init__(self, content, edit_by, edit_date, may_revise=False, page=None, diff=None): self.page_content_md = content self.page = page self.diff = diff self.edit_by = edit_by self.may_revise = may_revise self.edit_date = edit_date self.base_url = c.wiki_base_url Templated.__init__(self)
def __init__(self): builder = get_discussions(c.liveupdate_event, limit=self.max_links + 1) links, prev, next, bcount, acount = builder.get_items() self.more_links = len(links) > self.max_links self.links = links[:self.max_links] self.submit_url = make_submit_url(c.liveupdate_event) Templated.__init__(self)
def __init__(self): # convert language codes to real names language_summary = traffic.PageviewsByLanguage.top_last_month() locale = c.locale self.language_summary = [] for language_code, data in language_summary: name = LanguageTraffic.get_language_name(language_code, locale) self.language_summary.append(((language_code, name), data)) Templated.__init__(self)
def __init__(self, place): self.place = place self.traffic_last_modified = traffic.get_traffic_last_modified() self.traffic_lag = datetime.datetime.utcnow() - self.traffic_last_modified self.make_tables() Templated.__init__(self)
def __init__(self): builder = get_discussions(c.liveupdate_event, limit=self.max_links+1) links, prev, next, bcount, acount = builder.get_items() self.more_links = len(links) > self.max_links self.links = links[:self.max_links] self.submit_url = make_submit_url(c.liveupdate_event) Templated.__init__(self)
def __init__(self): links = self.get_links(c.liveupdate_event._id) self.more_links = len(links) > self.max_links self.links = links[:self.max_links] self.submit_url = "/submit?" + urllib.urlencode({ "url": make_event_url(c.liveupdate_event._id), "title": c.liveupdate_event.title.encode("utf-8"), }) Templated.__init__(self)
def __init__(self, place): self.place = place self.traffic_last_modified = traffic.get_traffic_last_modified() self.traffic_lag = (datetime.datetime.utcnow() - self.traffic_last_modified) self.make_tables() Templated.__init__(self)
def __init__(self, settings, mayedit, show_editors=True, show_settings=True, page=None, **context): self.permlevel = settings['permlevel'] self.listed = settings['listed'] self.show_settings = show_settings self.show_editors = show_editors self.page = page self.base_url = c.wiki_base_url self.mayedit = mayedit Templated.__init__(self)
def __init__(self, system, subject): from r2.models.admin_notes import AdminNotesBySystem self.system = system self.subject = subject self.author = c.user.name self.notes = AdminNotesBySystem.in_display_order(system, subject) # Convert timestamps for easier reading/translation for note in self.notes: note["timesince"] = timesince(note["when"]) Templated.__init__(self)
def __init__(self, link): self.thing = link self.summary_tab = PromoLinkTrafficSummary(link) # any traffic viewer can see summary, details, and help tabs but the # settings tab is only visible to owners and admins tabs = [('summary', 'summary', self.summary_tab), ('details', 'traffic by campaign', PromoCampaignTrafficTable(link))] if c.user_is_sponsor or c.user._id == link.author_id: tabs.append(('settings', 'settings', PromoTrafficSettings(link))) tabs.append(('help', 'help', PromoTrafficHelp())) Templated.__init__(self, tabs=TabbedPane(tabs, True))
def __init__(self, system, subject, subject_user=None): from r2.models.admin_notes import AdminNotesBySystem self.system = system self.subject = subject self.author = c.user.name self.notes = AdminNotesBySystem.in_display_order(system, subject) self.global_ban = 'yes' if subject_user and subject_user.is_global_banned else 'no' # Convert timestamps for easier reading/translation for note in self.notes: note["timesince"] = timesince(note["when"]) Templated.__init__(self)
def __init__(self): self.is_active = g.live_config['thebutton_is_active'] self.num_participants = get_num_participants() self.has_expired = has_timer_expired() if c.user_is_loggedin: self.too_new = c.user._date > ACCOUNT_CREATION_CUTOFF self.has_pressed = (ButtonPressByUser.has_pressed(c.user) and not c.user.employee) else: self.too_new = False self.has_pressed = False Templated.__init__(self)
def __init__(self): all_rooms = list(RobinRoom.generate_voting_rooms()) self.rooms = [] for room in all_rooms: participant_ids = room.get_all_participants() participants = Account._byID(participant_ids, data=True, return_dict=False) self.rooms.append( RoomDetails( id=room.id, participants=participants, level=room.level, )) Templated.__init__(self)
def __init__(self, content, action, pageactions, showtitle=False, description=None, **context): self.pageactions = pageactions self.base_url = c.wiki_base_url self.action = action self.description = description if showtitle: self.title = action[1] else: self.title = None self.content = content Templated.__init__(self)
def __init__(self, content, edit_by, edit_date, may_revise=False, page=None, diff=None, renderer='wiki'): self.page_content_md = content if renderer == 'wiki': self.page_content = wikimarkdown(content) elif renderer == 'reddit': self.page_content = safemarkdown(content) elif renderer == 'stylesheet': self.page_content = SubredditStylesheetSource(content).render() self.renderer = renderer self.page = page self.diff = diff self.edit_by = edit_by self.may_revise = may_revise self.edit_date = edit_date self.base_url = c.wiki_base_url Templated.__init__(self)
def __init__(self, event, listing, show_sidebar, report_type): self.event = event self.listing = listing if show_sidebar: self.discussions = LiveUpdateOtherDiscussions() self.show_sidebar = show_sidebar contributor_accounts = Account._byID(event.contributors.keys(), data=True, return_dict=False) self.contributors = sorted((LiveUpdateAccount(e) for e in contributor_accounts), key=lambda e: e.name) self.report_types = REPORT_TYPES self.report_type = report_type Templated.__init__(self)
def __init__(self, thing, campaign, before, after): self.thing = thing self.campaign = campaign self.before = before self.after = after self.period = datetime.timedelta(days=7) self.prev = None self.next = None self.has_live_campaign = False self.has_early_campaign = False self.detail_name = ('campaign %s' % campaign._id36 if campaign else 'all campaigns') editable = c.user_is_sponsor or c.user._id == thing.author_id self.traffic_last_modified = traffic.get_traffic_last_modified() self.traffic_lag = (datetime.datetime.utcnow() - self.traffic_last_modified) self.make_hourly_table(campaign or thing) self.make_campaign_table() Templated.__init__(self)
def __init__(self): self.srs, self.invalid_srs, self.report = [], [], [] self.textarea = request.params.get("subreddits") if self.textarea: requested_srs = [srname.strip() for srname in self.textarea.splitlines()] subreddits = Subreddit._by_name(requested_srs) for srname in requested_srs: if srname in subreddits: self.srs.append(srname) else: self.invalid_srs.append(srname) if subreddits: self.report = make_subreddit_traffic_report(subreddits.values()) param = urllib.quote(self.textarea) self.csv_url = "/traffic/subreddits/report.csv?subreddits=" + param Templated.__init__(self)
def __init__(self, link, *a, **kw): Templated.__init__(self, *a, **kw) self.link = link
def __init__(self, user): Templated.__init__(self) self.user = user
def __init__(self, event, enable_logo=True): self.event = event self.enable_logo = enable_logo Templated.__init__(self)
def __init__(self, url): self.url = url Templated.__init__(self)
def __init__(self, listing, page=None): self.listing = listing self.page = page Templated.__init__(self)
def __init__(self, page): self.page = page self.base_url = c.wiki_base_url Templated.__init__(self)
def __init__(self, pages, linear_pages, page=None): self.pages = pages self.page = page self.linear_pages = linear_pages self.base_url = c.wiki_base_url Templated.__init__(self)
def __init__(self, page_content='', previous='', page=None): self.page_content = page_content self.page = page self.previous = previous self.base_url = c.wiki_base_url Templated.__init__(self)