def update_(self):
     """
     Send update confirmation email
     """
     # If the person is not logged in,
     if not h.isPerson():
         return {'isOk': 0}
     # Load
     person = meta.Session.query(model.Person).get(session['personID'])
     # Return
     return changeAccount(dict(request.POST), 'update', '/people/confirm_email.mako', person)
 def delete(self):
     # If the person is not logged in, return
     if not h.isPerson():
         return dict(isOk=0, message='You must be logged in to perform this action.')
     # Load
     jobID = request.POST.get('jobID')
     # Delete
     meta.Session.execute(model.jobs_table.delete().where(model.Job.id==jobID))
     # Commit
     meta.Session.commit()
     # Return
     return dict(isOk=1)
 def logout(self, url=h.encodeURL('/')):
     """
     Logout
     """
     # If the person is logged in,
     if h.isPerson():
         del session['offset_in_minutes']
         del session['personID']
         del session['nickname']
         del session['is_super']
         session.save()
     # Redirect
     return redirect_to(h.decodeURL(url))
 def delete(self):
     # If the person is not logged in, return
     if not h.isPerson():
         return dict(isOk=0, message='You must be logged in to perform this action.')
     # Load
     imageID = request.POST.get('imageID')
     imagePath = folder_store.WebStore(config['storage_path']).getImagePath(image.id)
     # Delete
     meta.Session.execute(model.images_table.delete().where(model.Image.id==imageID))
     shutil.rmtree(imagePath)
     # Commit
     meta.Session.commit()
     # Return
     return dict(isOk=1)
 def delete(self):
     # If the person is not logged in, return
     if not h.isPerson():
         return dict(isOk=0, message='You must be logged in to perform this action.')
     # !!! Assert ownership
     # Load
     regionID = request.POST.get('regionID')
     # Delete from database
     meta.Session.execute(model.regions_table.delete().where(model.Region.id==regionID))
     # Delete from file system 
     shutil.rmtree(folder_store.WebStore(config['storage_path']).getRegionPath(regionID))
     # Commit
     meta.Session.commit()
     # Return
     return dict(isOk=1)
 def add(self):
     'Add a job to define datasets'
     # If the user is not logged in, return
     if not h.isPerson():
         return 'Please log in to perform this action.'
     # Initialize
     parameterByName = {
         'test fraction per region': float(request.POST['testFractionPerRegion']),
     }
     # Extract
     regionMethod = request.POST['regionMethod']
     # If the user wants to specify regions via coverage fraction,
     if regionMethod == 'viaCoverageFraction':
         parameterByName.update({
             'window length in meters': float(request.POST['windowLengthInMeters']),
             'region length in windows': int(request.POST['regionLengthInWindows']),
             'coverage fraction': float(request.POST['coverageFraction']),
             'coverage offset': int(request.POST['coverageOffset']),
         })
     # If the user wants to specify regions via rectangles,
     elif regionMethod == 'viaRectangles':
         parameterByName.update({
             'multispectral region frames': request.POST['multispectralRegionFrames'],
         })
     # If the user wants to specify regions via shapefile,
     elif regionMethod == 'viaShapefile':
         # Save upload into a temporary file
         # !!!! not finished
         # region
         parameterByName.update({'region path': ''})
     # Add job
     job = model.Job(model.job_defineRegions, session['personID'])
     job.setInput(dict(
         regionName=request.POST['regionName'],
         imageID=request.POST['imageID'],
         parameterByName=parameterByName,
     ))
     meta.Session.add(job)
     meta.Session.commit()
     # Redirect
     redirect_to(h.decodeURL(url) or url_for('image_index'))
     pass
 def add(self, url=None):
     # If the person is not logged in, return
     if not h.isPerson():
         return
     # Load
     imageName = request.POST.get('imageName')
     imageMultispectral = request.POST.get('imageMultispectral')
     imagePanchromatic = request.POST.get('imagePanchromatic')
     # Verify attributes
     if imageName:
         # Get subfolder name
         image = model.Image(imageName, session['personID'])
         meta.Session.add(image)
         meta.Session.commit()
         # Save images
         imagePath = folder_store.WebStore(config['storage_path']).getImagePath(image.id)
         image.multispectral_path = saveUpload(imagePath, 'multispectral', imageMultispectral)
         image.panchromatic_path = saveUpload(imagePath, 'panchromatic', imagePanchromatic)
         meta.Session.commit()
     # Redirect
     redirect_to(h.decodeURL(url) or url_for('image_index'))
 def update(self):
     """
     Show account update page.
     """
     # If the person is not logged in,
     if not h.isPerson():
         return ''
     # Get
     person = meta.Session.query(model.Person).get(session['personID'])
     # Render
     c.title = 'Update'
     c.button_label = 'Update'
     c.save_url_name = 'person_update_'
     c.success_message = 'Please check your email to finalize changes to your account.'
     form = render('/people/change.mako')
     # Return
     return htmlfill.render(form, {
         'username': person.username,
         'nickname': person.nickname,
         'email': person.email,
         'email_sms': person.email_sms,
     })
 def add(self, url=None):
     """
     Add a job to define windows
     """
     # If the user is not logged in, return
     if not h.isPerson():
         return 'Please log in to perform this action.'
     # Load parameters from request.POST
     parameterByName = {
         'example count per region': int(request.POST['exampleCountPerRegion']),
         'multispectral pixel shift value': int(request.POST['multispectralPixelShiftValue']),
         'shift count': int(request.POST['shiftCount']),
     }
     # Create a job in the database with type job_sampleWindows
     job = model.Job(model.job_sampleWindows, session['personID'])
     job.setInput(dict(
         windowName=request.POST['windowName'],
         regionID=request.POST['regionID'],
         parameterByName=parameterByName,
     ))
     meta.Session.add(job)
     meta.Session.commit()
     # Redirect
     redirect_to(h.decodeURL(url) or url_for('window_index'))
 def __before__(self):
     # If authentication is required and the person is not logged in,
     if self.withAuthentication and not h.isPerson():
         # Remember where to send the user after a successful login
         return redirect_to('person_login', url=h.encodeURL(request.path_info))