rename error template to avoid conflicts with the error view
"""Set of HTML base actions:organization: Logilab:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr"""__docformat__="restructuredtext en"fromcubicweb.vregistryimportobjectify_selectorfromcubicweb.selectorsimport(yes,one_line_rset,two_lines_rset,one_etype_rset,relation_possible,non_final_entity,authenticated_user,match_user_groups,match_search_state,has_editable_relation,has_permission,has_add_permission,)fromcubicweb.web.actionimportActionfromcubicweb.web.viewsimportlinksearch_select_url,vid_from_rset_=unicode@objectify_selectordefmatch_searched_etype(cls,req,rset,**kwargs):returnreq.match_search_state(rset)@objectify_selectordefview_is_not_default_view(cls,req,rset,**kwargs):# interesting if it propose another view than the current onevid=req.form.get('vid')ifvidandvid!=vid_from_rset(req,rset,cls.schema):return1return0@objectify_selectordefaddable_etype_empty_rset(cls,req,rset,**kwargs):ifrsetisnotNoneandnotrset.rowcount:rqlst=rset.syntax_tree()iflen(rqlst.children)>1:return0select=rqlst.children[0]iflen(select.defined_vars)==1andlen(select.solutions)==1:rset._searched_etype=select.solutions[0].itervalues().next()eschema=cls.schema.eschema(rset._searched_etype)ifnot(eschema.is_final()oreschema.is_subobject(strict=True)) \andeschema.has_perm(req,'add'):return1return0# generic primary actions #####################################################classSelectAction(Action):"""base class for link search actions. By default apply on any size entity result search it the current state is 'linksearch' if accept match. """id='select'__select__=match_search_state('linksearch')&match_searched_etype()title=_('select')category='mainactions'order=0defurl(self):returnlinksearch_select_url(self.req,self.rset)classCancelSelectAction(Action):id='cancel'__select__=match_search_state('linksearch')title=_('cancel select')category='mainactions'order=10defurl(self):target,eid,r_type,searched_type=self.req.search_state[1]returnself.build_url(str(eid),vid='edition',__mode='normal')classViewAction(Action):id='view'__select__=(match_search_state('normal')&match_user_groups('users','managers')&view_is_not_default_view()&non_final_entity())title=_('view')category='mainactions'order=0defurl(self):params=self.req.form.copy()params.pop('vid',None)params.pop('__message',None)returnself.build_url(self.req.relative_path(includeparams=False),**params)classModifyAction(Action):id='edit'__select__=(match_search_state('normal')&one_line_rset()&(has_permission('update')|has_editable_relation('add')))title=_('modify')category='mainactions'order=10defurl(self):entity=self.rset.get_entity(self.rowor0,self.color0)returnentity.absolute_url(vid='edition')classMultipleEditAction(Action):id='muledit'# XXX get strange conflicts if id='edit'__select__=(match_search_state('normal')&two_lines_rset()&one_etype_rset()&has_permission('update'))title=_('modify')category='mainactions'order=10defurl(self):returnself.build_url('view',rql=self.rset.rql,vid='muledit')# generic secondary actions ###################################################classManagePermissionsAction(Action):id='managepermission'__select__=one_line_rset()&non_final_entity()&match_user_groups('managers')title=_('manage permissions')category='moreactions'order=100@classmethoddefregistered(cls,vreg):super(ManagePermissionsAction,cls).registered(vreg)if'require_permission'invreg.schema:cls.__select__=(one_line_rset()&non_final_entity()&(match_user_groups('managers')|relation_possible('require_permission','subject','EPermission',action='add')))returnsuper(ManagePermissionsAction,cls).registered(vreg)defurl(self):returnself.rset.get_entity(0,0).absolute_url(vid='security')classDeleteAction(Action):id='delete'__select__=has_permission('delete')title=_('delete')category='moreactions'order=20defurl(self):iflen(self.rset)==1:entity=self.rset.get_entity(0,0)returnself.build_url(entity.rest_path(),vid='deleteconf')returnself.build_url(rql=self.rset.printable_rql(),vid='deleteconf')classCopyAction(Action):id='copy'__select__=one_line_rset()&has_permission('add')title=_('copy')category='moreactions'order=30defurl(self):entity=self.rset.get_entity(self.rowor0,self.color0)returnentity.absolute_url(vid='copy')classAddNewAction(MultipleEditAction):"""when we're seeing more than one entity with the same type, propose to add a new one """id='addentity'__select__=(match_search_state('normal')&(addable_etype_empty_rset()|(two_lines_rset()&one_etype_rset&has_add_permission())))category='moreactions'order=40@propertydefrsettype(self):ifself.rset:returnself.rset.description[0][0]returnself.rset._searched_etype@propertydeftitle(self):returnself.req.__('add a %s'%self.rsettype)# generated msgiddefurl(self):returnself.build_url('add/%s'%self.rsettype)# logged user actions #########################################################classUserPreferencesAction(Action):id='myprefs'__select__=authenticated_user()title=_('user preferences')category='useractions'order=10defurl(self):returnself.build_url(self.id)classUserInfoAction(Action):id='myinfos'__select__=authenticated_user()title=_('personnal informations')category='useractions'order=20defurl(self):returnself.build_url('euser/%s'%self.req.user.login,vid='edition')classLogoutAction(Action):id='logout'__select__=authenticated_user()title=_('logout')category='useractions'order=30defurl(self):returnself.build_url(self.id)# site actions ################################################################classManagersAction(Action):__abstract__=True__select__=match_user_groups('managers')category='siteactions'defurl(self):returnself.build_url(self.id)classSiteConfigurationAction(ManagersAction):id='siteconfig'title=_('site configuration')order=10classManageAction(ManagersAction):id='manage'title=_('manage')order=20classViewSchemaAction(Action):id='schema'__select__=yes()title=_("site schema")category='siteactions'order=30defurl(self):returnself.build_url(self.id)