from pylons import c, g

from r2.lib.pages import Ads as BaseAds


class Ads(BaseAds):
    def __init__(self):
        BaseAds.__init__(self)
        adzerk_test_srs = g.live_config.get("adzerk_test_srs")
        if adzerk_test_srs and c.site.name in adzerk_test_srs:
            url_key = "adzerk_https_url" if c.secure else "adzerk_url"
            self.ad_url = g.config[url_key].format(
                origin=c.request_origin,
            )
            self.frame_id = "ad_main"

from urllib import quote

from pylons import c, g

from r2.lib.pages import Ads as BaseAds


class Ads(BaseAds):
    def __init__(self):
        BaseAds.__init__(self)
        adzerk_test_srs = g.live_config.get("adzerk_test_srs")
        if adzerk_test_srs and c.site.name in adzerk_test_srs:
            url_key = "adzerk_https_url" if c.secure else "adzerk_url"
            self.ad_url = g.config[url_key].format(
                subreddit=quote(c.site.name),
                origin=c.request_origin,
            )
            self.frame_id = "ad_main"

Add subreddit query param to adzerk frame.
Add subreddit query param to adzerk frame.

For tracking / targeting.

+ from urllib import quote
+ 
  from pylons import c, g
  
  from r2.lib.pages import Ads as BaseAds
  
  
  class Ads(BaseAds):
      def __init__(self):
          BaseAds.__init__(self)
          adzerk_test_srs = g.live_config.get("adzerk_test_srs")
          if adzerk_test_srs and c.site.name in adzerk_test_srs:
              url_key = "adzerk_https_url" if c.secure else "adzerk_url"
              self.ad_url = g.config[url_key].format(
+                 subreddit=quote(c.site.name),
                  origin=c.request_origin,
              )
              self.frame_id = "ad_main"
  
Add subreddit query param to adzerk frame.
## Code Before:
from pylons import c, g

from r2.lib.pages import Ads as BaseAds


class Ads(BaseAds):
    def __init__(self):
        BaseAds.__init__(self)
        adzerk_test_srs = g.live_config.get("adzerk_test_srs")
        if adzerk_test_srs and c.site.name in adzerk_test_srs:
            url_key = "adzerk_https_url" if c.secure else "adzerk_url"
            self.ad_url = g.config[url_key].format(
                origin=c.request_origin,
            )
            self.frame_id = "ad_main"

## Instruction:
Add subreddit query param to adzerk frame.
## Code After:
from urllib import quote

from pylons import c, g

from r2.lib.pages import Ads as BaseAds


class Ads(BaseAds):
    def __init__(self):
        BaseAds.__init__(self)
        adzerk_test_srs = g.live_config.get("adzerk_test_srs")
        if adzerk_test_srs and c.site.name in adzerk_test_srs:
            url_key = "adzerk_https_url" if c.secure else "adzerk_url"
            self.ad_url = g.config[url_key].format(
                subreddit=quote(c.site.name),
                origin=c.request_origin,
            )
            self.frame_id = "ad_main"
