From 9cbf04d260bab4cff68c4bf36e094ba26c48462c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 18 Jul 2018 18:50:18 +0100 Subject: [PATCH] Drop advertisement code Signed-off-by: Michael Tremer --- Makefile.am | 1 - src/backend/ads.py | 59 ------------------- src/backend/base.py | 2 - .../modules/ads/download-splash.html | 4 -- 4 files changed, 66 deletions(-) delete mode 100644 src/backend/ads.py delete mode 100644 src/templates/modules/ads/download-splash.html diff --git a/Makefile.am b/Makefile.am index 05e5dc1b..e16a9d2a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,7 +49,6 @@ CLEANFILES += \ backend_PYTHON = \ src/backend/__init__.py \ src/backend/accounts.py \ - src/backend/ads.py \ src/backend/base.py \ src/backend/blog.py \ src/backend/countries.py \ diff --git a/src/backend/ads.py b/src/backend/ads.py deleted file mode 100644 index f7abe588..00000000 --- a/src/backend/ads.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python - -from __future__ import division - -import datetime -import textile - -from misc import Object - -class Advertisements(Object): - def get(self, where=None): - query = "SELECT * FROM advertisements \ - WHERE NOW() BETWEEN date_start AND date_end AND published = %s" - args = [True] - - if where: - query += " AND location = %s" - args.append(where) - - query += " ORDER BY RANDOM() LIMIT 1" - - ad = self.db.get(query, *args) - if ad: - return Advert(self.backend, ad.id, ad) - - -class Advert(Object): - def __init__(self, backend, id, data=None): - Object.__init__(self, backend) - - self.id = id - self.__data = data - - @property - def data(self): - if self.__data is None: - self.__data = self.db.get("SELECT * FROM advertisements WHERE id = %s", self.id) - assert self.__data - - return self.__data - - @property - def company(self): - return self.data.company - - @property - def text(self): - return self.data.text - - @property - def url(self): - return self.data.url - - @property - def who(self): - return """%s""" % (self.url, self.text or self.company) - - def update_impressions(self): - self.db.execute("UPDATE advertisements SET impressions = impressions + 1 WHERE id = %s", self.id) diff --git a/src/backend/base.py b/src/backend/base.py index 19e6384f..94d7d49d 100644 --- a/src/backend/base.py +++ b/src/backend/base.py @@ -4,7 +4,6 @@ import ConfigParser as configparser import StringIO import accounts -import ads import database import geoip import fireinfo @@ -46,7 +45,6 @@ class Backend(object): # Initialize backend modules. self.accounts = accounts.Accounts(self) - self.advertisements = ads.Advertisements(self) self.downloads = mirrors.Downloads(self) self.geoip = geoip.GeoIP(self) self.fireinfo = fireinfo.Fireinfo(self) diff --git a/src/templates/modules/ads/download-splash.html b/src/templates/modules/ads/download-splash.html deleted file mode 100644 index 76596212..00000000 --- a/src/templates/modules/ads/download-splash.html +++ /dev/null @@ -1,4 +0,0 @@ -
- {{ _("This download is sponsored by") }} - {% raw ad.who %} -
-- 2.39.5