def repos_path(self): """ Get's the repositories root path from database """ q = RhodeCodeUi.get_by_key('/').one() return q.ui_value
def fork_create(self, repo_name): self.__load_defaults() c.repo_info = Repository.get_by_repo_name(repo_name) _form = RepoForkForm(old_data={'repo_type': c.repo_info.repo_type}, repo_groups=c.repo_groups_choices, landing_revs=c.landing_revs_choices)() form_result = {} try: form_result = _form.to_python(dict(request.POST)) # an approximation that is better than nothing if not RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE).ui_active: form_result['update_after_clone'] = False # create fork is done sometimes async on celery, db transaction # management is handled there. RepoModel().create_fork(form_result, self.rhodecode_user.user_id) fork_url = h.link_to(form_result['repo_name_full'], h.url('summary_home', repo_name=form_result['repo_name_full'])) h.flash(h.literal(_('Forked repository %s as %s') \ % (repo_name, fork_url)), category='success') except formencode.Invalid, errors: c.new_repo = errors.value['repo_name'] return htmlfill.render( render('forks/fork.html'), defaults=errors.value, errors=errors.error_dict or {}, prefix_error=False, encoding="UTF-8")
def repos_path(self): """ Get's the repositories root path from database """ q = RhodeCodeUi.get_by_key('/') return q.ui_value
def fork_create(self, repo_name): self.__load_defaults() c.repo_info = Repository.get_by_repo_name(repo_name) _form = RepoForkForm(old_data={'repo_type': c.repo_info.repo_type}, repo_groups=c.repo_groups_choices, landing_revs=c.landing_revs_choices)() form_result = {} try: form_result = _form.to_python(dict(request.POST)) # an approximation that is better than nothing if not RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE).ui_active: form_result['update_after_clone'] = False # create fork is done sometimes async on celery, db transaction # management is handled there. RepoModel().create_fork(form_result, self.rhodecode_user.user_id) fork_url = h.link_to( form_result['repo_name_full'], h.url('summary_home', repo_name=form_result['repo_name_full'])) h.flash(h.literal(_('Forked repository %s as %s') \ % (repo_name, fork_url)), category='success') except formencode.Invalid, errors: c.new_repo = errors.value['repo_name'] return htmlfill.render(render('forks/fork.html'), defaults=errors.value, errors=errors.error_dict or {}, prefix_error=False, encoding="UTF-8")
def __load_defaults(self): acl_groups = RepoGroupList(RepoGroup.query().all(), perm_set=['group.write', 'group.admin']) c.repo_groups = RepoGroup.groups_choices(groups=acl_groups) c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) choices, c.landing_revs = ScmModel().get_repo_landing_revs() c.landing_revs_choices = choices c.can_update = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE).ui_active
def __load_defaults(self): acl_groups = RepoGroupList(RepoGroup.query().all(), perm_set=['group.write', 'group.admin']) c.repo_groups = RepoGroup.groups_choices(groups=acl_groups) c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) choices, c.landing_revs = ScmModel().get_repo_landing_revs() c.landing_revs_choices = choices c.can_update = RhodeCodeUi.get_by_key( RhodeCodeUi.HOOK_UPDATE).ui_active
def _check_ssl(self, environ, start_response): """ Checks the SSL check flag and returns False if SSL is not present and required True otherwise """ org_proto = environ["wsgi._org_proto"] # check if we have SSL required ! if not it's a bad request ! require_ssl = str2bool(RhodeCodeUi.get_by_key("push_ssl").ui_value) if require_ssl and org_proto == "http": log.debug("proto is %s and SSL is required BAD REQUEST !" % org_proto) return False return True
def _check_ssl(self, environ, start_response): """ Checks the SSL check flag and returns False if SSL is not present and required True otherwise """ org_proto = environ['wsgi._org_proto'] #check if we have SSL required ! if not it's a bad request ! require_ssl = str2bool(RhodeCodeUi.get_by_key('push_ssl').ui_value) if require_ssl and org_proto == 'http': log.debug('proto is %s and SSL is required BAD REQUEST !' % org_proto) return False return True
if setting_id == 'vcs': application_form = ApplicationUiSettingsForm()() try: form_result = application_form.to_python(dict(request.POST)) except formencode.Invalid, errors: return htmlfill.render( render('admin/settings/settings.html'), defaults=errors.value, errors=errors.error_dict or {}, prefix_error=False, encoding="UTF-8" ) try: sett = RhodeCodeUi.get_by_key('push_ssl') sett.ui_value = form_result['web_push_ssl'] Session().add(sett) if c.visual.allow_repo_location_change: sett = RhodeCodeUi.get_by_key('/') sett.ui_value = form_result['paths_root_path'] Session().add(sett) #HOOKS sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE) sett.ui_active = form_result['hooks_changegroup_update'] Session().add(sett) sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_REPO_SIZE) sett.ui_active = form_result['hooks_changegroup_repo_size'] Session().add(sett)
def step_6(self): notify('re-checking permissions') self.klass.create_permissions() notify('installing new UI options') sett4 = RhodeCodeSetting('show_public_icon', True) Session().add(sett4) sett5 = RhodeCodeSetting('show_private_icon', True) Session().add(sett5) sett6 = RhodeCodeSetting('stylify_metatags', False) Session().add(sett6) notify('fixing old PULL hook') _pull = RhodeCodeUi.get_by_key('preoutgoing.pull_logger') if _pull: _pull.ui_key = RhodeCodeUi.HOOK_PULL Session().add(_pull) notify('fixing old PUSH hook') _push = RhodeCodeUi.get_by_key('pretxnchangegroup.push_logger') if _push: _push.ui_key = RhodeCodeUi.HOOK_PUSH Session().add(_push) notify('installing new pre-push hook') hooks4 = RhodeCodeUi() hooks4.ui_section = 'hooks' hooks4.ui_key = RhodeCodeUi.HOOK_PRE_PUSH hooks4.ui_value = 'python:rhodecode.lib.hooks.pre_push' Session().add(hooks4) notify('installing new pre-pull hook') hooks6 = RhodeCodeUi() hooks6.ui_section = 'hooks' hooks6.ui_key = RhodeCodeUi.HOOK_PRE_PULL hooks6.ui_value = 'python:rhodecode.lib.hooks.pre_pull' Session().add(hooks6) notify('installing hgsubversion option') # enable hgsubversion disabled by default hgsubversion = RhodeCodeUi() hgsubversion.ui_section = 'extensions' hgsubversion.ui_key = 'hgsubversion' hgsubversion.ui_value = '' hgsubversion.ui_active = False Session().add(hgsubversion) notify('installing hg git option') # enable hggit disabled by default hggit = RhodeCodeUi() hggit.ui_section = 'extensions' hggit.ui_key = 'hggit' hggit.ui_value = '' hggit.ui_active = False Session().add(hggit) notify('re-check default permissions') default_user = User.get_by_username(User.DEFAULT_USER) perm = Permission.get_by_key('hg.fork.repository') reg_perm = UserToPerm() reg_perm.user = default_user reg_perm.permission = perm Session().add(reg_perm)
'visualisation settings'), category='error') if setting_id == 'vcs': application_form = ApplicationUiSettingsForm()() try: form_result = application_form.to_python(dict(request.POST)) except formencode.Invalid, errors: return htmlfill.render(render('admin/settings/settings.html'), defaults=errors.value, errors=errors.error_dict or {}, prefix_error=False, encoding="UTF-8") try: sett = RhodeCodeUi.get_by_key('push_ssl') sett.ui_value = form_result['web_push_ssl'] Session().add(sett) sett = RhodeCodeUi.get_by_key('/') sett.ui_value = form_result['paths_root_path'] Session().add(sett) #HOOKS sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE) sett.ui_active = form_result['hooks_changegroup_update'] Session().add(sett) sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_REPO_SIZE) sett.ui_active = form_result['hooks_changegroup_repo_size'] Session().add(sett)