Files
@ a04fe5986109
Branch filter:
Location: kallithea/rhodecode/controllers/admin/repos_groups.py - annotation
a04fe5986109
3.2 KiB
text/x-python
#47 implemented basic gui for browsing repo groups
2ab211e0aecd 523382549c45 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 523382549c45 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 5f2fbab7c429 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd 523382549c45 523382549c45 a04fe5986109 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 523382549c45 a04fe5986109 a04fe5986109 a04fe5986109 a04fe5986109 523382549c45 523382549c45 2ab211e0aecd 2ab211e0aecd 2ab211e0aecd | import logging
from operator import itemgetter
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from rhodecode.lib.base import BaseController, render
from rhodecode.model.db import Group
log = logging.getLogger(__name__)
class ReposGroupsController(BaseController):
"""REST Controller styled on the Atom Publishing Protocol"""
# To properly map this controller, ensure your config/routing.py
# file has a resource setup:
# map.resource('repos_group', 'repos_groups')
def index(self, format='html'):
"""GET /repos_groups: All items in the collection"""
# url('repos_groups')
def create(self):
"""POST /repos_groups: Create a new item"""
# url('repos_groups')
def new(self, format='html'):
"""GET /repos_groups/new: Form to create a new item"""
# url('new_repos_group')
def update(self, id):
"""PUT /repos_groups/id: 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('repos_group', id=ID),
# method='put')
# url('repos_group', id=ID)
def delete(self, id):
"""DELETE /repos_groups/id: Delete an existing item"""
# Forms posted to this method should contain a hidden field:
# <input type="hidden" name="_method" value="DELETE" />
# Or using helpers:
# h.form(url('repos_group', id=ID),
# method='delete')
# url('repos_group', id=ID)
def show(self, id, format='html'):
"""GET /repos_groups/id: Show a specific item"""
# url('repos_group', id=ID)
c.group = Group.get(id)
if c.group:
c.group_repos = c.group.repositories.all()
else:
return redirect(url('repos_group'))
sortables = ['name', 'description', 'last_change', 'tip', 'owner']
current_sort = request.GET.get('sort', 'name')
current_sort_slug = current_sort.replace('-', '')
if current_sort_slug not in sortables:
c.sort_by = 'name'
current_sort_slug = c.sort_by
else:
c.sort_by = current_sort
c.sort_slug = current_sort_slug
sort_key = current_sort_slug + '_sort'
#overwrite our cached list with current filter
gr_filter = [r.repo_name for r in c.group_repos]
c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter)
if c.sort_by.startswith('-'):
c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key),
reverse=True)
else:
c.repos_list = sorted(c.cached_repo_list, key=itemgetter(sort_key),
reverse=False)
c.repo_cnt = len(c.repos_list)
c.groups = self.sa.query(Group).order_by(Group.group_name)\
.filter(Group.group_parent_id == id).all()
return render('admin/repos_groups/repos_groups.html')
def edit(self, id, format='html'):
"""GET /repos_groups/id/edit: Form to edit an existing item"""
# url('edit_repos_group', id=ID)
|