##// END OF EJS Templates
whoosh errors don't crash entire app now, just display an error and log exception instead
whoosh errors don't crash entire app now, just display an error and log exception instead

File last commit:

r1271:aa7e45ad beta
r1303:9773b46e beta
Show More
users_group.py
93 lines | 3.0 KiB | text/x-python | PythonLexer
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 # -*- coding: utf-8 -*-
"""
rhodecode.model.user_group
~~~~~~~~~~~~~~~~~~~~~~~~~~
users groups model for RhodeCode
source code cleanup: remove trailing white space, normalize file endings
r1203
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 :created_on: Jan 25, 2011
:author: marcink
source code cleanup: remove trailing white space, normalize file endings
r1203 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 :license: GPLv3, see COPYING for more details.
"""
fixed license issue #149
r1206 # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
source code cleanup: remove trailing white space, normalize file endings
r1203 #
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
source code cleanup: remove trailing white space, normalize file endings
r1203 #
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 # You should have received a copy of the GNU General Public License
fixed license issue #149
r1206 # along with this program. If not, see <http://www.gnu.org/licenses/>.
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
import logging
import traceback
from pylons.i18n.translation import _
from rhodecode.model import BaseModel
from rhodecode.model.caching_query import FromCache
#56 implemented users groups editing,...
r972 from rhodecode.model.db import UsersGroup, UsersGroupMember
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
log = logging.getLogger(__name__)
class UsersGroupModel(BaseModel):
def get(self, users_group_id, cache=False):
users_group = self.sa.query(UsersGroup)
if cache:
users_group = users_group.options(FromCache("sql_cache_short",
Fixed permissions for users groups, group can have create repo permission now....
r1271 "get_users_group_%s" % users_group_id))
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 return users_group.get(users_group_id)
def create(self, form_data):
try:
new_users_group = UsersGroup()
for k, v in form_data.items():
setattr(new_users_group, k, v)
self.sa.add(new_users_group)
self.sa.commit()
except:
log.error(traceback.format_exc())
self.sa.rollback()
raise
#56 implemented users groups editing,...
r972 def update(self, users_group_id, form_data):
try:
users_group = self.get(users_group_id, cache=False)
for k, v in form_data.items():
if k == 'users_group_members':
users_group.members = []
self.sa.flush()
members_list = []
if v:
for u_id in set(v):
Fixed permissions for users groups, group can have create repo permission now....
r1271 members_list.append(UsersGroupMember(
users_group_id,
u_id))
#56 implemented users groups editing,...
r972 setattr(users_group, 'members', members_list)
setattr(users_group, k, v)
self.sa.add(users_group)
self.sa.commit()
except:
log.error(traceback.format_exc())
self.sa.rollback()
raise
#56 implemented users groups deletes
r973
def delete(self, users_group_id):
try:
users_group = self.get(users_group_id, cache=False)
self.sa.delete(users_group)
self.sa.commit()
except:
log.error(traceback.format_exc())
self.sa.rollback()
raise