Пример #1
0
    def edit_fields(self, repo_name):
        c.repo_info = self._load_repo()
        c.repo_fields = RepositoryField.query() \
            .filter(RepositoryField.repository == c.repo_info).all()
        c.active = 'fields'
        if request.POST:

            raise HTTPFound(location=url('repo_edit_fields'))
        return render('admin/repos/repo_edit.html')
Пример #2
0
    def edit_fields(self, repo_name):
        c.repo_info = self._load_repo()
        c.repo_fields = RepositoryField.query() \
            .filter(RepositoryField.repository == c.repo_info).all()
        c.active = 'fields'
        if request.POST:

            raise HTTPFound(location=url('repo_edit_fields'))
        return render('admin/repos/repo_edit.html')
Пример #3
0
 def edit(self, repo_name):
     defaults = self.__load_data()
     c.repo_fields = RepositoryField.query() \
         .filter(RepositoryField.repository == c.repo_info).all()
     c.active = 'settings'
     return htmlfill.render(render('admin/repos/repo_edit.html'),
                            defaults=defaults,
                            encoding="UTF-8",
                            force_defaults=False)
Пример #4
0
    def update(self, repo_name):
        """
        PUT /repos/repo_name: Update an existing item"""
        # Forms posted to this method should contain a hidden field:
        #    <input type="hidden" name="_method" value="PUT" />
        # Or using helpers:
        #    h.form(url('put_repo', repo_name=ID),
        #           method='put')
        # url('put_repo', repo_name=ID)
        c.repo_info = self._load_repo(repo_name)
        self.__load_defaults(c.repo_info)
        c.active = 'settings'
        c.repo_fields = RepositoryField.query() \
            .filter(RepositoryField.repository == c.repo_info).all()

        repo_model = RepoModel()
        changed_name = repo_name
        repo = Repository.get_by_repo_name(repo_name)
        old_data = {
            'repo_name': repo_name,
            'repo_group': repo.group.get_dict() if repo.group else {},
            'repo_type': repo.repo_type,
        }
        _form = RepoForm(edit=True, old_data=old_data,
                         repo_groups=c.repo_groups,
                         landing_revs=c.landing_revs_choices)()

        try:
            form_result = _form.to_python(dict(request.POST))
            repo = repo_model.update(repo_name, **form_result)
            ScmModel().mark_for_invalidation(repo_name)
            h.flash(_('Repository %s updated successfully') % repo_name,
                    category='success')
            changed_name = repo.repo_name
            action_logger(self.authuser, 'admin_updated_repo',
                              changed_name, self.ip_addr, self.sa)
            Session().commit()
        except formencode.Invalid as errors:
            log.info(errors)
            defaults = self.__load_data(repo_name)
            defaults.update(errors.value)
            c.users_array = repo_model.get_users_js()
            return htmlfill.render(
                render('admin/repos/repo_edit.html'),
                defaults=defaults,
                errors=errors.error_dict or {},
                prefix_error=False,
                encoding="UTF-8",
                force_defaults=False)

        except Exception:
            log.error(traceback.format_exc())
            h.flash(_('Error occurred during update of repository %s') \
                    % repo_name, category='error')
        raise HTTPFound(location=url('edit_repo', repo_name=changed_name))
Пример #5
0
    def edit_fields(self, repo_name):
        """GET /repo_name/settings: Form to edit an existing item"""
        # url('edit_repo', repo_name=ID)
        c.repo_info = self._load_repo(repo_name)
        c.repo_fields = RepositoryField.query()\
            .filter(RepositoryField.repository == c.repo_info).all()
        c.active = 'fields'
        if request.POST:

            return redirect(url('repo_edit_fields'))
        return render('admin/repos/repo_edit.html')
Пример #6
0
    def edit_fields(self, repo_name):
        """GET /repo_name/settings: Form to edit an existing item"""
        # url('edit_repo', repo_name=ID)
        c.repo_info = self._load_repo(repo_name)
        c.repo_fields = RepositoryField.query()\
            .filter(RepositoryField.repository == c.repo_info).all()
        c.active = 'fields'
        if request.POST:

            return redirect(url('repo_edit_fields'))
        return render('admin/repos/repo_edit.html')
Пример #7
0
 def edit(self, repo_name):
     defaults = self.__load_data()
     c.repo_fields = RepositoryField.query() \
         .filter(RepositoryField.repository == c.repo_info).all()
     repo_model = RepoModel()
     c.users_array = repo_model.get_users_js()
     c.active = 'settings'
     return htmlfill.render(
         render('admin/repos/repo_edit.html'),
         defaults=defaults,
         encoding="UTF-8",
         force_defaults=False)
Пример #8
0
 def edit(self, repo_name):
     """GET /repo_name/settings: Form to edit an existing item"""
     # url('edit_repo', repo_name=ID)
     defaults = self.__load_data(repo_name)
     c.repo_fields = RepositoryField.query() \
         .filter(RepositoryField.repository == c.repo_info).all()
     repo_model = RepoModel()
     c.users_array = repo_model.get_users_js()
     c.active = 'settings'
     return htmlfill.render(
         render('admin/repos/repo_edit.html'),
         defaults=defaults,
         encoding="UTF-8",
         force_defaults=False)
Пример #9
0
    def edit(self, repo_name):
        """GET /repo_name/settings: Form to edit an existing item"""
        # url('edit_repo', repo_name=ID)
        defaults = self.__load_data(repo_name)
        if 'clone_uri' in defaults:
            del defaults['clone_uri']

        c.repo_fields = RepositoryField.query()\
            .filter(RepositoryField.repository == c.repo_info).all()
        c.active = 'settings'
        return htmlfill.render(render('admin/repos/repo_edit.html'),
                               defaults=defaults,
                               encoding="UTF-8",
                               force_defaults=False)
Пример #10
0
    def update(self, repo_name):
        """
        PUT /repos/repo_name: Update an existing item"""
        # Forms posted to this method should contain a hidden field:
        #    <input type="hidden" name="_method" value="PUT" />
        # Or using helpers:
        #    h.form(url('repo', repo_name=ID),
        #           method='put')
        # url('repo', repo_name=ID)
        c.repo_info = self._load_repo(repo_name)
        c.active = 'settings'
        c.repo_fields = RepositoryField.query()\
            .filter(RepositoryField.repository == c.repo_info).all()
        self.__load_defaults(c.repo_info)

        repo_model = RepoModel()
        changed_name = repo_name
        #override the choices with extracted revisions !
        choices, c.landing_revs = ScmModel().get_repo_landing_revs(repo_name)
        c.landing_revs_choices = choices
        repo = Repository.get_by_repo_name(repo_name)
        old_data = {
            'repo_name': repo_name,
            'repo_group': repo.group.get_dict() if repo.group else {},
            'repo_type': repo.repo_type,
        }
        _form = RepoForm(edit=True,
                         old_data=old_data,
                         repo_groups=c.repo_groups_choices,
                         landing_revs=c.landing_revs_choices)()

        try:
            form_result = _form.to_python(dict(request.POST))
            repo = repo_model.update(repo_name, **form_result)
            ScmModel().mark_for_invalidation(repo_name)
            h.flash(_('Repository %s updated successfully') % repo_name,
                    category='success')
            changed_name = repo.repo_name
            action_logger(self.authuser, 'admin_updated_repo', changed_name,
                          self.ip_addr, self.sa)
            Session().commit()
        except formencode.Invalid, errors:
            defaults = self.__load_data(repo_name)
            defaults.update(errors.value)
            return htmlfill.render(render('admin/repos/repo_edit.html'),
                                   defaults=defaults,
                                   errors=errors.error_dict or {},
                                   prefix_error=False,
                                   encoding="UTF-8",
                                   force_defaults=False)
Пример #11
0
    def edit(self, repo_name):
        """GET /repo_name/settings: Form to edit an existing item"""
        # url('edit_repo', repo_name=ID)
        defaults = self.__load_data(repo_name)
        if 'clone_uri' in defaults:
            del defaults['clone_uri']

        c.repo_fields = RepositoryField.query()\
            .filter(RepositoryField.repository == c.repo_info).all()
        c.active = 'settings'
        return htmlfill.render(
            render('admin/repos/repo_edit.html'),
            defaults=defaults,
            encoding="UTF-8",
            force_defaults=False)
Пример #12
0
    def update(self, repo_name):
        c.repo_info = self._load_repo()
        self.__load_defaults(c.repo_info)
        c.active = 'settings'
        c.repo_fields = RepositoryField.query() \
            .filter(RepositoryField.repository == c.repo_info).all()

        repo_model = RepoModel()
        changed_name = repo_name
        repo = Repository.get_by_repo_name(repo_name)
        old_data = {
            'repo_name': repo_name,
            'repo_group': repo.group.get_dict() if repo.group else {},
            'repo_type': repo.repo_type,
        }
        _form = RepoForm(edit=True,
                         old_data=old_data,
                         repo_groups=c.repo_groups,
                         landing_revs=c.landing_revs_choices)()

        try:
            form_result = _form.to_python(dict(request.POST))
            repo = repo_model.update(repo_name, **form_result)
            ScmModel().mark_for_invalidation(repo_name)
            h.flash(_('Repository %s updated successfully') % repo_name,
                    category='success')
            changed_name = repo.repo_name
            action_logger(request.authuser, 'admin_updated_repo', changed_name,
                          request.ip_addr)
            Session().commit()
        except formencode.Invalid as errors:
            log.info(errors)
            defaults = self.__load_data()
            defaults.update(errors.value)
            return htmlfill.render(render('admin/repos/repo_edit.html'),
                                   defaults=defaults,
                                   errors=errors.error_dict or {},
                                   prefix_error=False,
                                   encoding="UTF-8",
                                   force_defaults=False)

        except Exception:
            log.error(traceback.format_exc())
            h.flash(_('Error occurred during update of repository %s') %
                    repo_name,
                    category='error')
        raise HTTPFound(location=url('edit_repo', repo_name=changed_name))