def planet(self):
return self.handler.planet
+ @property
+ def talk(self):
+ return self.handler.talk
+
@property
def wishlist(self):
return self.handler.wishlist
})
countries.append(country)
- # Sort the list of small countries by alphabet
- other_countries.sort()
-
return self.render_string("fireinfo/modules/table-geo.html",
countries=countries, other_countries=other_countries)
class NetBootMenuConfigModule(UIModule):
- def render(self, release):
- return self.render_string("netboot/menu-config.cfg", release=release)
+ def render(self, release, arch=None, platform=None):
+ return self.render_string("netboot/menu-config.cfg", release=release,
+ arch=arch, platform=platform)
class NetBootMenuHeaderModule(UIModule):
- def render(self, title, releases):
+ def render(self, title, releases, arch=None, platform=None):
id = unicodedata.normalize("NFKD", unicode(title)).encode("ascii", "ignore")
id = re.sub(r"[^\w]+", " ", id)
id = "-".join(id.lower().strip().split())
return self.render_string("netboot/menu-header.cfg", id=id,
- title=title, releases=releases)
+ title=title, releases=releases, arch=arch, platform=platform)
class NetBootMenuSeparatorModule(UIModule):
# Render text
item.text = textile.textile(item.text.decode("utf8"))
- return self.render_string("modules/news-item.html", item=item,
+ # Find a release if one exists
+ release = self.releases.get_by_news_id(item.uuid)
+
+ return self.render_string("modules/news-item.html", item=item, release=release,
uncut=uncut, announcement=announcement, show_heading=show_heading)
class PlanetSearchBoxModule(UIModule):
def render(self, query=None):
- years = self.planet.get_years()
-
- return self.render_string("modules/planet/search-box.html",
- query=query, years=years)
+ return self.render_string("modules/planet/search-box.html", query=query)
class SidebarItemModule(UIModule):
release=release, image=best_image)
+class PlanetAuthorBoxModule(UIModule):
+ def render(self, author):
+ return self.render_string("planet/modules/author-box.html", author=author)
+
+
class PlanetEntryModule(UIModule):
def render(self, entry, show_avatar=True):
return self.render_string("modules/planet-entry.html",
class TalkCallLogModule(UIModule):
- def render(self, calls):
- return self.render_string("talk/modules/call-log.html", calls=calls)
+ def render(self, account=None, viewer=None):
+ if (account is None or not self.current_user == account) \
+ and not self.current_user.is_admin():
+ raise RuntimeException("Insufficient permissions")
+
+ if viewer is None:
+ viewer = self.current_user
+
+ calls = self.talk.get_call_log(account)
+
+ return self.render_string("talk/modules/call-log.html",
+ calls=calls, viewer=viewer)
+
+
+class TalkLinesModule(UIModule):
+ def render(self, account=None, show_account=False):
+ if (account is None or not self.current_user == account) \
+ and not self.current_user.is_admin():
+ raise RuntimeException("Insufficient permissions")
+
+ lines = self.talk.get_lines(account)
+
+ return self.render_string("talk/modules/lines.html",
+ show_account=show_account, lines=lines)
class TalkOngoingCallsModule(UIModule):
- def render(self, calls):
- return self.render_string("talk/modules/ongoing-calls.html", calls=calls)
+ def render(self, account=None):
+ if (account is None or not self.current_user == account) \
+ and not self.current_user.is_admin():
+ raise RuntimeException("Insufficient permissions")
+
+ calls = self.talk.get_ongoing_calls(account)
+
+ if calls:
+ return self.render_string("talk/modules/ongoing-calls.html",
+ calls=calls)
+
+ return ""
class TrackerPeerListModule(UIModule):
class DonationBoxModule(UIModule):
- def render(self, reason_for_transfer=None, show_wishlist_items=False):
+ def render(self, reason_for_transfer=None):
if reason_for_transfer:
reason_for_transfer = "IPFire.org - %s" % reason_for_transfer
- # Interesting items from the wishlist.
- wishlist_items = []
- if show_wishlist_items:
- wishlist_items = self.wishlist.get_hot_wishes()
-
return self.render_string("modules/donation-box.html",
- reason_for_transfer=reason_for_transfer, wishlist_items=wishlist_items)
+ reason_for_transfer=reason_for_transfer)
+
+
+class DonationButtonModule(UIModule):
+ # https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
+ COUNTRIES = (
+ "AU",
+ "AT",
+ "BE",
+ "BR",
+ "CA",
+ "CH",
+ "CN",
+ "DE",
+ "ES",
+ "GB",
+ "FR",
+ "IT",
+ "NL",
+ "PL",
+ "PT",
+ "RU",
+ "US",
+ )
+
+ LOCALES = (
+ "da_DK",
+ "he_IL",
+ "id_ID",
+ "ja_JP",
+ "no_NO",
+ "pt_BR",
+ "ru_RU",
+ "sv_SE",
+ "th_TH",
+ "zh_CN",
+ "zh_HK",
+ "zh_TW",
+ )
+
+ def render(self, reason_for_transfer=None, currency="EUR"):
+ if not reason_for_transfer:
+ reason_for_transfer = "IPFire.org"
+
+ primary = (currency == "EUR")
+
+ return self.render_string("modules/donation-button.html", primary=primary,
+ reason_for_transfer=reason_for_transfer, currency=currency, lc=self.lc)
+
+ @property
+ def lc(self):
+ """
+ Returns the locale of the user
+ """
+ try:
+ locale, delimiter, encoding = self.locale.code.partition(".")
+
+ # Break for languages in specific countries
+ if locale in self.LOCALES:
+ return locale
+
+ lang, delimiter, country_code = locale.partition("_")
+
+ if country_code and country_code in self.COUNTRIES:
+ return country_code
+
+ lang = lang.upper()
+ if lang in self.COUNTRIES:
+ return lang
+ except:
+ pass
+
+ # If anything goes wrong, fall back to GB
+ return "GB"
+
+
+class DonationInputBoxModule(DonationButtonModule):
+ def render(self):
+ currencies = ("EUR", "USD", "GBP", "CHF", "AUD", "NZD", "CAD")
+
+ return self.render_string("modules/donation-input-box.html",
+ currencies=currencies, lc=self.lc)