def enabled(self, request): if settings.ENTERPRISE_MODE: return False if hasattr(request, 'user'): from corehq.apps.notifications.models import DismissedUINotify today = datetime.now() if self.starts_on is not None and self.starts_on >= today: return False if self.ends_on is not None and self.ends_on <= today: return False if (self.visible_to_users_before is not None and was_user_created_after(request.user.username, self.visible_to_users_before)): return False if (self.visible_to_users_after is not None and not was_user_created_after( request.user.username, self.visible_to_users_after)): return False return not DismissedUINotify.is_notification_dismissed( request.user, self.slug) return False
def enabled(self, request): if settings.ENTERPRISE_MODE: return False if hasattr(request, 'user'): from corehq.apps.notifications.models import DismissedUINotify today = datetime.now() if self.starts_on is not None and self.starts_on >= today: return False if self.ends_on is not None and self.ends_on <= today: return False if (self.visible_to_users_before is not None and was_user_created_after( request.user.username, self.visible_to_users_before)): return False if (self.visible_to_users_after is not None and not was_user_created_after( request.user.username, self.visible_to_users_after)): return False return not DismissedUINotify.is_notification_dismissed( request.user, self.slug ) return False
def get_apps_base_context(request, domain, app): lang, langs = get_langs(request, app) if getattr(request, 'couch_user', None): timezone = get_timezone_for_user(request.couch_user, domain) else: timezone = None context = { 'lang': lang, 'langs': langs, 'domain': domain, 'app': app, 'app_subset': { 'commcare_minor_release': app.commcare_minor_release, 'doc_type': app.get_doc_type(), 'form_counts_by_module': [len(m.forms) for m in app.modules] if not app.is_remote_app() else [], 'version': app.version, } if app else {}, 'timezone': timezone, } if app and not app.is_remote_app(): app.assert_app_v2() show_advanced = (toggles.APP_BUILDER_ADVANCED.enabled(domain) or getattr(app, 'commtrack_enabled', False)) context.update({ 'show_care_plan': (not app.has_careplan_module and toggles.APP_BUILDER_CAREPLAN.enabled(request.user.username)), 'show_advanced': show_advanced, 'show_report_modules': toggles.MOBILE_UCR.enabled(domain), 'show_shadow_modules': toggles.APP_BUILDER_SHADOW_MODULES.enabled(domain), 'show_shadow_forms': show_advanced, }) if toggles.APP_MANAGER_V2.enabled(request.user.username): rollout = toggles.APP_MANAGER_V2.enabled_for_new_users_after if not toggles.was_user_created_after(request.user.username, rollout): context.update({'allow_v2_opt_out': True}) return context