diff --git a/r2/r2/controllers/promotecontroller.py b/r2/r2/controllers/promotecontroller.py index 9d15b9bfe..f21083ec4 100644 --- a/r2/r2/controllers/promotecontroller.py +++ b/r2/r2/controllers/promotecontroller.py @@ -44,6 +44,7 @@ from r2.lib.pages import ( PromotePage, PromoteLinkForm, PromoteLinkFormCpm, + PromoteLinkNew, PromoteReport, Reddit, Roadblocks, @@ -227,22 +228,16 @@ class PromoteController(ListingController): @validate(VSponsor()) def GET_new_promo(self): - return PromotePage('content', content=PromoteLinkForm()).render() + return PromotePage('content', content=PromoteLinkNew()).render() @validate(VSponsor('link'), link=VLink('link')) def GET_edit_promo(self, link): if not link or link.promoted is None: return self.abort404() - rendered = wrap_links(link, wrapper=promote.sponsor_wrapper, - skip=False) - - form = PromoteLinkForm(link=link, - listing=rendered, - timedeltatext="") - + rendered = wrap_links(link, wrapper=promote.sponsor_wrapper, skip=False) + form = PromoteLinkForm(link, rendered) page = PromotePage('new_promo', content=form) - return page.render() diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index a6fe5a964..7c00396df 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -3308,14 +3308,16 @@ class PromotePage(Reddit): kw['show_sidebar'] = False Reddit.__init__(self, title, nav_menus = nav_menus, *a, **kw) +class PromoteLinkNew(Templated): pass + class PromoteLinkForm(Templated): - def __init__(self, link=None, listing='', *a, **kw): + def __init__(self, link, listing, *a, **kw): self.setup(link, listing) Templated.__init__(self, *a, **kw) def setup(self, link, listing): self.bids = [] - if c.user_is_sponsor and link: + if c.user_is_sponsor: self.author = Account._byID(link.author_id) try: bids = bidding.Bid.lookup(thing_id=link._id) @@ -3357,13 +3359,11 @@ class PromoteLinkForm(Templated): self.mindate = mindate.strftime("%m/%d/%Y") - self.link = None + self.link = promote.wrap_promoted(link) self.listing = listing - if link: - self.link = promote.wrap_promoted(link) - campaigns = PromoCampaign._by_link(link._id) - self.campaigns = promote.get_renderable_campaigns(link, campaigns) - self.promotion_log = PromotionLog.get(link) + campaigns = PromoCampaign._by_link(link._id) + self.campaigns = promote.get_renderable_campaigns(link, campaigns) + self.promotion_log = PromotionLog.get(link) self.min_daily_bid = 0 if c.user_is_admin else g.min_promote_bid diff --git a/r2/r2/templates/promotelinkform.html b/r2/r2/templates/promotelinkform.html index 068dfc69e..a7af57347 100644 --- a/r2/r2/templates/promotelinkform.html +++ b/r2/r2/templates/promotelinkform.html @@ -66,21 +66,15 @@ ${self.javascript_setup()}
-

${_("create a promotion") if not thing.link else _("edit promotion")}

+

${_("edit promotion")}

- %if thing.link: - ${thing.listing} - %endif + ${thing.listing}
- %if thing.link: - ${campaign_dashboard()} - %endif + ${campaign_dashboard()}
- %if thing.link: - - %endif + <% trusted = c.user_is_sponsor or c.user.trusted_sponsor @@ -90,36 +84,23 @@ ${self.javascript_setup()} ${title_field(thing.link, editable=editable)} ${url_field(thing.link, editable=editable, enable_override=c.user_is_sponsor)} - %if thing.link and editable: + %if editable: ${image_field(thing.link)} ${commenting_field(thing.link)} %if trusted: ${media_field(thing.link)} %endif - %else: -
- By clicking "next" you agree to the Self Serve Advertising Rules. -
%endif
- <% - if thing.link: - name = "save" - text = _("save options") - else: - name = "create" - text = _("next") - %> - ${error_field("RATELIMIT", "ratelimit")} ${error_field("RATELIMIT", "ratelimit")} -
@@ -454,7 +435,7 @@ ${self.javascript_setup()} <%def name="right_panel()"> - %if thing.link and c.user_is_sponsor: + %if c.user_is_sponsor:
%if thing.bids: <%utils:line_field title="${_('bidding history')}" css_class="rounded"> diff --git a/r2/r2/templates/promotelinknew.html b/r2/r2/templates/promotelinknew.html new file mode 100644 index 000000000..fd392572c --- /dev/null +++ b/r2/r2/templates/promotelinknew.html @@ -0,0 +1,55 @@ +## 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-2013 +## reddit Inc. All Rights Reserved. +############################################################################### + +<%namespace file="promotelinkform.html" import="title_field, url_field" /> +<%namespace file="utils.html" import="error_field" /> +<%namespace name="utils" file="utils.html"/> + + +
+

${_("create a promotion")}

+ +
+ +
+ + ${title_field(None, editable=True)} + ${url_field(None, editable=True, enable_override=c.user_is_sponsor)} + +
+ By clicking "next" you agree to the Self Serve Advertising Rules. +
+ +
+ ${error_field("RATELIMIT", "ratelimit")} + + + ${error_field("RATELIMIT", "ratelimit")} + +
+ +
+
+