Esempio n. 1
0
    def __before__(self):
        c.rhodecode_version = __version__
        c.rhodecode_instanceid = config.get('instance_id')
        c.rhodecode_name = config.get('rhodecode_title')
        c.use_gravatar = str2bool(config.get('use_gravatar'))
        c.ga_code = config.get('rhodecode_ga_code')
        # Visual options
        c.visual = AttributeDict({})
        rc_config = RhodeCodeSetting.get_app_settings()

        c.visual.show_public_icon = str2bool(rc_config.get('rhodecode_show_public_icon'))
        c.visual.show_private_icon = str2bool(rc_config.get('rhodecode_show_private_icon'))
        c.visual.stylify_metatags = str2bool(rc_config.get('rhodecode_stylify_metatags'))
        c.visual.lightweight_dashboard = str2bool(rc_config.get('rhodecode_lightweight_dashboard'))
        c.visual.lightweight_dashboard_items = safe_int(config.get('dashboard_items', 100))

        c.repo_name = get_repo_slug(request)
        c.backends = BACKENDS.keys()
        c.unread_notifications = NotificationModel()\
                        .get_unread_cnt_for_user(c.rhodecode_user.user_id)
        self.cut_off_limit = int(config.get('cut_off_limit'))

        self.sa = meta.Session
        self.scm_model = ScmModel(self.sa)
        self.ip_addr = ''
Esempio n. 2
0
    def __before__(self):
        """
        __before__ is called before controller methods and after __call__
        """
        # on each call propagate settings calls into global settings.
        set_rhodecode_config(config)
        attach_context_attributes(c)

        # TODO: Remove this when fixed in attach_context_attributes()
        c.repo_name = get_repo_slug(request)  # can be empty

        self.cut_off_limit_diff = safe_int(config.get('cut_off_limit_diff'))
        self.cut_off_limit_file = safe_int(config.get('cut_off_limit_file'))
        self.sa = meta.Session
        self.scm_model = ScmModel(self.sa)

        default_lang = c.language
        user_lang = c.language
        try:
            user_obj = self._rhodecode_user.get_instance()
            if user_obj:
                user_lang = user_obj.user_data.get('language')
        except Exception:
            log.exception('Failed to fetch user language for user %s',
                          self._rhodecode_user)

        if user_lang and user_lang != default_lang:
            log.debug('set language to %s for user %s', user_lang,
                      self._rhodecode_user)
            translation.set_lang(user_lang)
Esempio n. 3
0
    def __before__(self):
        """
        __before__ is called before controller methods and after __call__
        """
        c.rhodecode_version = __version__
        c.rhodecode_instanceid = config.get('instance_id')
        c.rhodecode_name = config.get('rhodecode_title')
        c.use_gravatar = str2bool(config.get('use_gravatar'))
        c.ga_code = config.get('rhodecode_ga_code')
        # Visual options
        c.visual = AttributeDict({})
        rc_config = RhodeCodeSetting.get_app_settings()
        ## DB stored
        c.visual.show_public_icon = str2bool(rc_config.get('rhodecode_show_public_icon'))
        c.visual.show_private_icon = str2bool(rc_config.get('rhodecode_show_private_icon'))
        c.visual.stylify_metatags = str2bool(rc_config.get('rhodecode_stylify_metatags'))
        c.visual.dashboard_items = safe_int(rc_config.get('rhodecode_dashboard_items', 100))
        c.visual.repository_fields = str2bool(rc_config.get('rhodecode_repository_fields'))
        c.visual.show_version = str2bool(rc_config.get('rhodecode_show_version'))

        ## INI stored
        self.cut_off_limit = int(config.get('cut_off_limit'))
        c.visual.allow_repo_location_change = str2bool(config.get('allow_repo_location_change', True))

        c.repo_name = get_repo_slug(request)  # can be empty
        c.backends = BACKENDS.keys()
        c.unread_notifications = NotificationModel()\
                        .get_unread_cnt_for_user(c.rhodecode_user.user_id)
        self.sa = meta.Session
        self.scm_model = ScmModel(self.sa)
Esempio n. 4
0
    def __before__(self):
        """
        __before__ is called before controller methods and after __call__
        """
        c.rhodecode_version = __version__
        c.rhodecode_instanceid = config.get('instance_id')
        c.rhodecode_name = config.get('rhodecode_title')
        c.rhodecode_bugtracker = config.get('bugtracker', 'http://bitbucket.org/marcinkuzminski/rhodecode/issues')
        c.use_gravatar = str2bool(config.get('use_gravatar'))
        c.ga_code = config.get('rhodecode_ga_code')
        # Visual options
        c.visual = AttributeDict({})
        rc_config = RhodeCodeSetting.get_app_settings()
        ## DB stored
        c.visual.show_public_icon = str2bool(rc_config.get('rhodecode_show_public_icon'))
        c.visual.show_private_icon = str2bool(rc_config.get('rhodecode_show_private_icon'))
        c.visual.stylify_metatags = str2bool(rc_config.get('rhodecode_stylify_metatags'))
        c.visual.dashboard_items = safe_int(rc_config.get('rhodecode_dashboard_items', 100))
        c.visual.repository_fields = str2bool(rc_config.get('rhodecode_repository_fields'))
        c.visual.show_version = str2bool(rc_config.get('rhodecode_show_version'))

        ## INI stored
        self.cut_off_limit = int(config.get('cut_off_limit'))
        c.visual.allow_repo_location_change = str2bool(config.get('allow_repo_location_change', True))
        c.visual.allow_custom_hooks_settings = str2bool(config.get('allow_custom_hooks_settings', True))

        c.repo_name = get_repo_slug(request)  # can be empty
        c.backends = BACKENDS.keys()
        c.unread_notifications = NotificationModel()\
                        .get_unread_cnt_for_user(c.rhodecode_user.user_id)
        self.sa = meta.Session
        self.scm_model = ScmModel(self.sa)
Esempio n. 5
0
 def check_permissions(self):
     repo_name = get_repo_slug(request)
     try:
         user_perms = set([self.user_perms['repositories'][repo_name]])
     except KeyError:
         return False
     if self.required_perms.issubset(user_perms):
         return True
     return False
Esempio n. 6
0
 def check_permissions(self):
     repo_name = get_repo_slug(request)
     try:
         user_perms = set([self.user_perms['repositories'][repo_name]])
     except KeyError:
         return False
     if self.required_perms.issubset(user_perms):
         return True
     return False
Esempio n. 7
0
    def __before__(self):
        c.rhodecode_version = __version__
        c.rhodecode_name = config.get('rhodecode_title')
        c.ga_code = config.get('rhodecode_ga_code')
        c.repo_name = get_repo_slug(request)
        c.backends = BACKENDS.keys()
        self.cut_off_limit = int(config.get('cut_off_limit'))

        self.sa = meta.Session()
        self.scm_model = ScmModel(self.sa)
Esempio n. 8
0
    def check_permissions(self):
        if not self.repo_name:
            self.repo_name = get_repo_slug(request)

        try:
            self._user_perms = set(
                [self.user_perms['repositories'][self.repo_name]])
        except KeyError:
            return False
        if self.required_perms.intersection(self._user_perms):
            return True
        return False
Esempio n. 9
0
    def check_permissions(self):
        if not self.repo_name:
            self.repo_name = get_repo_slug(request)

        try:
            self.user_perms = set([self.user_perms["reposi" "tories"][self.repo_name]])
        except KeyError:
            return False
        self.granted_for = self.repo_name
        if self.required_perms.intersection(self.user_perms):
            return True
        return False
Esempio n. 10
0
    def __before__(self):
        c.rhodecode_version = __version__
        c.rhodecode_instanceid = config.get('instance_id')
        c.rhodecode_name = config.get('rhodecode_title')
        c.use_gravatar = str2bool(config.get('use_gravatar'))
        c.ga_code = config.get('rhodecode_ga_code')
        c.repo_name = get_repo_slug(request)
        c.backends = BACKENDS.keys()
        c.unread_notifications = NotificationModel()\
                        .get_unread_cnt_for_user(c.rhodecode_user.user_id)
        self.cut_off_limit = int(config.get('cut_off_limit'))

        self.sa = meta.Session
        self.scm_model = ScmModel(self.sa)
Esempio n. 11
0
    def __before__(self):
        c.rhodecode_version = __version__
        c.rhodecode_instanceid = config.get("instance_id")
        c.rhodecode_name = config.get("rhodecode_title")
        c.use_gravatar = str2bool(config.get("use_gravatar"))
        c.ga_code = config.get("rhodecode_ga_code")
        # Visual options
        c.visual = AttributeDict({})
        c.visual.show_public_icon = str2bool(config.get("rhodecode_show_public_icon"))
        c.visual.show_private_icon = str2bool(config.get("rhodecode_show_private_icon"))
        c.visual.stylify_metatags = str2bool(config.get("rhodecode_stylify_metatags"))

        c.repo_name = get_repo_slug(request)
        c.backends = BACKENDS.keys()
        c.unread_notifications = NotificationModel().get_unread_cnt_for_user(c.rhodecode_user.user_id)
        self.cut_off_limit = int(config.get("cut_off_limit"))

        self.sa = meta.Session
        self.scm_model = ScmModel(self.sa)
        self.ip_addr = ""