SHARE
TWEET

Untitled

a guest Jul 20th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ConfirmAccesBook( BrowserView ):
  2.     template = template = ViewPageTemplateFile('templates/GetPassWordBook.pt')
  3.  
  4.     def __init__(self, context, request):
  5.         self.context      = context
  6.         self.request      = request
  7.         self.portal       = getSite ()
  8.         self.portal_state = getMultiAdapter((context, request), name=u'plone_portal_state')
  9.  
  10.     def  __call__(self):
  11.  
  12.         form = self.request.form
  13.         submitted = form.get('form.submitted', False)
  14.         submitted = form.get('form.submitted', False)
  15.         save_button = form.get('form.button.Save', None) is not None
  16.         cancel_button = form.get('form.button.Cancel', None) is not None
  17.     fromuserhome = form.get ( "user.home", False )
  18.     postback = False
  19.  
  20.     if fromuserhome == False:
  21.         postback = True
  22.  
  23.  
  24.         if submitted and not cancel_button:
  25.         book_id = self.request.get ( "book_id", None )
  26.             user = str( self.portal_state.member() )
  27.             password = self.request.get ( "password-book", None )
  28.  
  29.         group = False
  30.         rol   = 'estudiante'
  31.             data_password = self.findGroup( password )
  32.        
  33.         if data_password:
  34.         group = data_password[ 0 ]
  35.         rol   = data_password[ 1 ]
  36.  
  37.  
  38.             if group:
  39.                 #try:
  40.                 results = self.addUsertoGroup(user, group, rol )
  41.                 self.asignPasswordtoUser( user,group,password )
  42.                 self.request.response.redirect( results )
  43.                 #except:
  44.                     #pass
  45.  
  46.         if fromuserhome == False:
  47.         msg = u"ContraseƱa incorrecta"
  48.         IStatusMessage(self.context.request).addStatusMessage(msg, 'info')
  49.  
  50.         if cancel_button:
  51.             postback = False
  52.  
  53.         if postback:
  54.             return self.template()
  55.  
  56.         else:
  57.             context_state = self.context.restrictedTraverse("@@plone_context_state")
  58.             url = context_state.view_url()
  59.         if fromuserhome:
  60.         url += "/mylibraries"
  61.         if group == False:
  62.             msg = u"ContraseƱa incorrecta"
  63.             IStatusMessage(self.context.request).addStatusMessage(msg, 'info')
  64.  
  65.         self.request.response.redirect(url)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top