def as_action(self, ): """ Check that I'm an admin """ if GlobalCommunity.objects.exists(): glob = GlobalCommunity.get() if glob.can_edit: return BaseView.as_action(self, )
def as_action(self,): """ Check that I'm an admin """ if GlobalCommunity.objects.exists(): glob = GlobalCommunity.get() if glob.can_edit: return BaseView.as_action(self)
def _get_site_name_or_baseline(return_baseline = False): """ Read the site name from global community. We use tricks to ensure we can get the glob com. even with anonymous requests. """ d = cache.get_many(["twistranet_site_name", "twistranet_baseline"]) site_name = d.get("site_name", None) baseline = d.get("baseline", None) if site_name is None or baseline is None: from twistranet.twistapp.models import SystemAccount, GlobalCommunity __account__ = SystemAccount.get() try: glob = GlobalCommunity.get() site_name = glob.site_name baseline = glob.baseline finally: del __account__ cache.set('twistranet_site_name', site_name) cache.set("twistranet_baseline", baseline) if return_baseline: return baseline return site_name