## The contents of this file are subject to the Common Public Attribution ## License Version 1.0. (the "License"); you may not use this file except in ## compliance with the License. You may obtain a copy of the License at ## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public ## License Version 1.1, but Sections 14 and 15 have been added to cover use of ## software over a computer network and provide for limited attribution for the ## Original Developer. In addition, Exhibit A has been modified to be ## consistent with Exhibit B. ## ## Software distributed under the License is distributed on an "AS IS" basis, ## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for ## the specific language governing rights and limitations under the License. ## ## The Original Code is reddit. ## ## The Original Developer is the Initial Developer. The Initial Developer of ## the Original Code is reddit Inc. ## ## All portions of the code written by reddit are Copyright (c) 2006-2012 ## reddit Inc. All Rights Reserved. ############################################################################### <%! from r2.lib.utils import to36 from r2.lib.media import thumbnail_url from r2.lib.template_helpers import static from r2.lib import promote from r2.lib.strings import strings from r2.models import Account from r2.lib import js import simplejson %> <%namespace file="utils.html" import="error_field, checkbox, image_upload, reddit_selector" /> <%namespace name="utils" file="utils.html"/> ${unsafe(js.use('sponsored'))} ## Create a datepicker for a form. min/maxDateSrc are the id of the ## element containing the min/max date - the '#' is added automatically ## here (as a workaround for babel message extraction not handling it ## properly if passed in when the function is called <%def name="datepicker(name, value, minDateSrc = '', maxDateSrc ='', initfuncname = '', min_date_offset=0)">
<% title = _("create a promotion") if not thing.link else _("edit promotion") %>

${title}

%if thing.link: ${thing.listing} %endif
%if thing.link:
<%utils:line_field title="${_('campaign dashboard')}" id="campaign-field" css_class="rounded">

This dashboard allows you to easily place ads on reddit. You can target a specific community or simply run on the main page.

<% start_title = "Date when your sponsored link will start running. We start new campaigns at midnight UTC+5" end_title = "Date when your sponsored link will end (at midnight UTC+5)" targeting_title = "name of the community that you are targeting. A blank entry here means that the ad is untargeted and will run site-wise " newcamp_title = "click to create a new campaign. To edit an existing campaing in the table below, click the 'edit' button." %>
duration <% mindate = thing.startdate if c.user_is_sponsor: mindate = thing.promote_date_today.strftime('%m/%d/%Y') %> <%self:datepicker name="startdate", value="${thing.startdate}" minDateSrc="date-min" initfuncname="init_startdate"> function(elem) { var other = $("#enddate"); if(dateFromInput("#startdate") >= dateFromInput("#enddate")) { var newd = new Date(); newd.setTime($(elem).datepicker('getDate').getTime() + 86400*1000); $("#enddate").val((newd.getMonth()+1) + "/" + newd.getDate() + "/" + newd.getFullYear()); } $("#datepicker-enddate").datepicker("destroy"); update_bid(elem); } - <%self:datepicker name="enddate", value="${thing.enddate}" minDateSrc="startdate" initfuncname="init_enddate" min_date_offset="86400000"> function(elem) { update_bid(elem); } ${error_field("BAD_DATE", "startdate", "div")} ${error_field("BAD_FUTURE_DATE", "startdate", "div")} ${error_field("BAD_DATE", "enddate", "div")} ${error_field("BAD_FUTURE_DATE", "enddate", "div")} ${error_field("BAD_DATE_RANGE", "enddate", "div")}
total bid ${error_field("BAD_BID", "bid", "div")} $
targeting

minimum $20 / day

minimum $30 / day

start end duration bid targeting

You don't have any campaigns for this link yet. You should add one.

%endif
%if thing.link: %endif <% trusted = c.user_is_sponsor or c.user.trusted_sponsor %> <%utils:line_field title="${_('title')}" id="title-field" css_class="rounded"> ${error_field("NO_TEXT", "title", "div")} ${error_field("TOO_LONG", "title", "div")}

A good title is important to the success of your campaign. reddit users are an intelligent, thoughtful group, and reward those who engage them

<%utils:line_field title="${_('url')}" id="url-field" css_class="rounded"> ${error_field("NO_URL", "url", "div")} ${error_field("BAD_URL", "url", "div")} ${error_field("ALREADY_SUB", "url", "div")}

Provide the URL of your ad. No redirects please!

%if c.user_is_sponsor:

Choose a different domain name to display on the site (the small grey text next to a link

%endif %if thing.link and (trusted or not promote.is_promoted(thing.link)): <%utils:line_field title="${_('look and feel')}" description="images will be resized if larger than 70 x 70 pixels" css_class="rounded">
<%utils:image_upload post_target="/api/link_thumb" current_image="${thumb}" label="${_('upload header image:')}"> ## overwrite the completed image function
<%utils:line_field title="${_('options')}" id="commenting-field" css_class="rounded">
<% clicks = views = 0 disable_comments = False if thing.link: disable_comments = getattr(thing.link, "disable_comments", False) clicks = getattr(thing.link, "maximum_clicks", 0) or 0 views = getattr(thing.link, "maximum_views", 0) or 0 %> ${checkbox("disable_comments", _("disable comments"), disable_comments)}
%if c.user_is_sponsor: ${checkbox("set_maximum_clicks", unsafe("maximum clicks: " + "" % clicks), clicks)}
${checkbox("set_maximum_views", unsafe("maximum views: " + "" % views), views)}
%endif

Comments are a great way to get feedback from customers, and the reddit community is known for being vocal in comment threads.

%if c.user_is_sponsor or c.user.trusted_sponsor: <%utils:line_field title="${_('media')}" id="commenting-field" css_class="rounded">
x

${checkbox("media-override", "media override (adds an onclick to the link to generate a drop-down rather than a link out)", getattr(thing.link, "media_override", False) or False)}
%endif %else:
By clicking "next" you agree to the Self Serve Advertising Rules.
%endif
<% if thing.link: name = "edit" text = _("save options") else: name = "create" text = _("next") %> ${error_field("RATELIMIT", "ratelimit")} ${error_field("RATELIMIT", "ratelimit")}
%if thing.link and not c.user_is_sponsor:
<%utils:line_field title="${_('promotion history')}" css_class="rounded"> <% import datetime pc_max = max(thing.promo_counter.values() or [1]) %>

Here is a summary of the data presented on the graph page. Remember: best to pick days with less competition.

%for i in xrange(0, 28): <% is_today = (i == 14) the_future = (i >= 14) day = (thing.now + datetime.timedelta(i-14)) CPC = CPM = imp_traffic = cli_traffic = "---" if thing.promo_traffic.has_key(day): imp_traffic, cli_traffic = thing.promo_traffic[day] if thing.market.has_key(i) and not the_future: CPM = "$%.2f" % (thing.market[i] * 1000./max(imp_traffic, 1)) CPC = "$%.2f" % (thing.market[i] * 1./max(cli_traffic, 1)) %>
date CPM CPC count
${unsafe("»" if is_today else '')} ${day.strftime("%m/%d/%Y")} ${CPM} ${CPC} ${thing.promo_counter.get(i, 0)}
%endfor
%endif %if thing.link and c.user_is_sponsor:
%if thing.bids: <%utils:line_field title="${_('bidding history')}" css_class="rounded"> <% from r2.models import Account, bidding accounts = Account._byID(set(x.account_id for x in thing.bids), True) %> %for bid in thing.bids: <% status = bidding.Bid.STATUS.name[bid.status].lower() %> %endfor
date user transaction id campaign id pay id amount status
${bid.date} ${accounts[bid.account_id].name} ${bid.transaction} ${bid.campaign} ${bid.pay_id} $${"%.2f" % bid.bid} ${status}
%endif
<%utils:line_field title="${_('promotion history')}" css_class="rounded">
For correspondence, the email address of this author is ${thing.author.email}.
To check with authorize.net, use CustomerID ${thing.author._fullname} when searching by batch.
%for line in getattr(thing.link, "promotion_log", []):

${line}

%endfor
%endif