##// END OF EJS Templates
moved cache invalidating to utils, as seperate function. Implemented invalidating in
moved cache invalidating to utils, as seperate function. Implemented invalidating in

File last commit:

r140:b5e59e2b default
r140:b5e59e2b default
Show More
admin.py
101 lines | 3.7 KiB | text/x-python | PythonLexer
changed for pylons 0.1 / 1.0...
r43 import logging
Changed creation of repository to vcs implementation,...
r133 import os
changed for pylons 0.1 / 1.0...
r43
from pylons import request, response, session, tmpl_context as c, url, app_globals as g
from pylons.controllers.util import abort, redirect
from pylons_app.lib.base import BaseController, render
Added managment pages....
r44 from pylons_app.lib import auth
implemented admin page login
r45 from pylons_app.model.forms import LoginForm
import formencode
import formencode.htmlfill as htmlfill
Marcin Kuzminski
Updated admin to show last 5 actions + updated db model
r62 from pylons_app.model import meta
from pylons_app.model.db import Users, UserLogs
Marcin Kuzminski
Implemented paging to admin user acion log
r78 from webhelpers.paginate import Page
moved cache invalidating to utils, as seperate function. Implemented invalidating in
r140 from pylons_app.lib.utils import check_repo, invalidate_cache
changed for pylons 0.1 / 1.0...
r43 log = logging.getLogger(__name__)
class AdminController(BaseController):
def __before__(self):
implemented autentication
r52 c.admin_user = session.get('admin_user', False)
implemented admin page login
r45 c.admin_username = session.get('admin_username')
changed for pylons 0.1 / 1.0...
r43
def index(self):
# Return a rendered template
implemented admin page login
r45 if request.POST:
#import Login Form validator class
login_form = LoginForm()
try:
c.form_result = login_form.to_python(dict(request.params))
Marcin Kuzminski
Static files for production fixed...
r46 if auth.admin_auth(c.form_result['username'], c.form_result['password']):
implemented admin page login
r45 session['admin_user'] = True
session['admin_username'] = c.form_result['username']
session.save()
return redirect(url('admin_home'))
else:
raise formencode.Invalid('Login Error', None, None,
error_dict={'username':'invalid login',
'password':'invalid password'})
except formencode.Invalid, error:
c.form_result = error.value
c.form_errors = error.error_dict or {}
Html changes and cleanups, made folders for html templates, implemented tags and branches pages
r127 html = render('admin/admin.html')
implemented admin page login
r45
return htmlfill.render(
html,
defaults=c.form_result,
encoding="UTF-8"
)
Marcin Kuzminski
Updated admin to show last 5 actions + updated db model
r62 if c.admin_user:
sa = meta.Session
Marcin Kuzminski
Implemented paging to admin user acion log
r78
users_log = sa.query(UserLogs)\
.order_by(UserLogs.action_date.desc())
p = int(request.params.get('page', 1))
c.users_log = Page(users_log, page=p, items_per_page=10)
Html changes and cleanups, made folders for html templates, implemented tags and branches pages
r127 c.log_data = render('admin/admin_log.html')
Marcin Kuzminski
Implemented AJAH paging
r79 if request.params.get('partial'):
return c.log_data
Html changes and cleanups, made folders for html templates, implemented tags and branches pages
r127 return render('admin/admin.html')
changed for pylons 0.1 / 1.0...
r43
def hgrc(self, dirname):
filename = os.path.join(dirname, '.hg', 'hgrc')
return filename
def add_repo(self, new_repo):
#extra check it can be add since it's the command
Added managment pages....
r44 if new_repo == '_admin':
c.msg = 'DENIED'
changed for pylons 0.1 / 1.0...
r43 c.new_repo = ''
Changed creation of repository to vcs implementation,...
r133 return render('admin/add.html')
changed for pylons 0.1 / 1.0...
r43
new_repo = new_repo.replace(" ", "_")
new_repo = new_repo.replace("-", "_")
try:
self._create_repo(new_repo)
c.new_repo = new_repo
c.msg = 'added repo'
Changed creation of repository to vcs implementation,...
r133 #clear our cached list for refresh with new repo
moved cache invalidating to utils, as seperate function. Implemented invalidating in
r140 invalidate_cache('repo_list_2')
changed for pylons 0.1 / 1.0...
r43 except Exception as e:
c.new_repo = 'Exception when adding: %s' % new_repo
c.msg = str(e)
Changed creation of repository to vcs implementation,...
r133 return render('admin/add.html')
changed for pylons 0.1 / 1.0...
r43
def _create_repo(self, repo_name):
if repo_name in [None, '', 'add']:
raise Exception('undefined repo_name of repo')
Changed creation of repository to vcs implementation,...
r133 repo_path = os.path.join(g.base_path, repo_name)
Moved check_repo function to utils, error controller check for first name in url, for this repo and only prints 404 make repo template if repo does not exists, moded check repo from admin
r125 if check_repo(repo_name, g.base_path):
Changed creation of repository to vcs implementation,...
r133 log.info('creating repo %s in %s', repo_name, repo_path)
from vcs.backends.hg import MercurialRepository
MercurialRepository(repo_path, create=True)