def syncwithstrava(request): """Will update the activity with strava in with all details.""" request.item = sync_activity(request) _ = request.translate msg = _('The activity was successfully synchronized with Strava') request.session.flash(msg, "success") return update(request)
def role_update_(request, callback=None, renderers=None, validators=None, values=None): role = get_item_from_request(request) # Store the name of the role in the request to make it # available in the callback request._oldname = role.name _ = request.translate uniqueness_validator = Validator('name', _('This name is already in use, ' 'please use something unique.'), role_name_update_validator, {'pk': role.id, 'db': request.db}) if validators is None: validators = [] validators.append(uniqueness_validator) callbacks = [] if callback: if isinstance(callback, list): callbacks.extend(callback) else: callbacks.append(callback) return update(request, values=values, validators=validators, callback=callbacks)
def _update(request): """If activity is not completely synced. Than sync it when opening""" item = get_item_from_request(request) if not item.has_streams: request.item = sync_activity(request) _ = request.translate msg = _('The activity was successfully synchronized with Strava') request.session.flash(msg, "success") return update(request)
def setstandin(request, allowed_users=None): """Setting members in the default usergroup of the current user. Technically this is adding a standin for this user.""" # Check authentification # As this view has now security configured it is # generally callable by all users. For this reason we first check if # the user is authenticated. If the user is not authenticated the # raise an 401 (unauthorized) exception. if not request.user: raise HTTPUnauthorized # Check authorisation # For normal users users shall only be allowed to set the standin # for their own usergroup. So check this and otherwise raise an exception. usergroup = get_item_from_request(request) if (usergroup.id != request.user.default_gid and not has_permission("update", usergroup, request)): raise HTTPForbidden() clazz = Usergroup request.session['%s.form' % clazz] = "membersonly" request.session.save() values = {} if allowed_users: values['_allowedusers'] = [u.login for u in allowed_users] # Result may be a HTTPFOUND object. result = update(request, values=values) if isinstance(result, dict): # If the standing is set by an administrational user then the id # of the usergroup´s user is stored in the the backurl. if request.GET.get('backurl'): user_id = urlparse.urlparse( request.GET.get('backurl')).path.split('/')[-1] user = request.db.query(User).get(user_id) if not user: raise HTTPBadRequest() # Otherwise the user sets the standin of his own group. In this # case the user is already in the request. else: user = request.user result['user'] = user # Reset form value in session handle_caching(request) return result
def setstandin(request, allowed_users=None): """Setting members in the default usergroup of the current user. Technically this is adding a standin for this user.""" # Check authentification # As this view has now security configured it is # generally callable by all users. For this reason we first check if # the user is authenticated. If the user is not authenticated the # raise an 401 (unauthorized) exception. if not request.user: raise HTTPUnauthorized # Check authorisation # For normal users users shall only be allowed to set the standin # for their own usergroup. So check this and otherwise raise an exception. usergroup = get_item_from_request(request) if (usergroup.id != request.user.default_gid and not has_permission("update", usergroup, request)): raise HTTPForbidden() clazz = Usergroup request.session['%s.form' % clazz] = "membersonly" request.session['%s.backurl' % clazz] = request.current_route_path() request.session.save() values = {} if allowed_users: values['_allowedusers'] = [u.login for u in allowed_users] # Result may be a HTTPFOUND object. result = update(request, values=values) if isinstance(result, dict): # If the standing is set by an administrational user then the id # of the usergroup´s user is stored in the the backurl. if request.GET.get('backurl'): user_id = urlparse.urlparse( request.GET.get('backurl')).path.split('/')[-1] user = request.db.query(User).filter(User.id == user_id).one() # Otherwise the user sets the standin of his own group. In this # case the user is already in the request. else: user = request.user result['user'] = user # Reset form value in session handle_caching(request) return result
def update_(request, callback=None, renderers=None, validators=None, values=None): user = get_item_from_request(request) # Store the login name of the user in the request to make it # available in the callback request._oldlogin = user.login _ = request.translate uniqueness_validator = Validator( 'login', _('This name is already in use, ' 'please use something unique.'), user_name_update_validator, { 'pk': user.id, 'db': request.db }) pw_len_validator = Validator( 'password', _('Password must be at least 12 characters ' 'long.'), password_minlength_validator) pw_nonchar_validator = Validator( 'password', _('Password must contain at least 2 ' 'non-letters.'), password_nonletter_validator) if validators is None: validators = [] validators.append(uniqueness_validator) validators.append(pw_len_validator) validators.append(pw_nonchar_validator) callbacks = [] callbacks.append(user_update_callback) if callback: if isinstance(callback, list): callbacks.extend(callback) else: callbacks.append(callback) return update(request, values=values, validators=validators, callback=callbacks)
def update_(request, callback=None, renderers=None, validators=None, values=None): user = get_item_from_request(request) # Store the login name of the user in the request to make it # available in the callback request._oldlogin = user.login _ = request.translate uniqueness_validator = Validator('login', _('This name is already in use, ' 'please use something unique.'), user_name_update_validator, {'pk': user.id, 'db': request.db}) pw_len_validator = Validator('password', _('Password must be at least 12 characters ' 'long.'), password_minlength_validator) pw_nonchar_validator = Validator('password', _('Password must contain at least 2 ' 'non-letters.'), password_nonletter_validator) if validators is None: validators = [] validators.append(uniqueness_validator) validators.append(pw_len_validator) validators.append(pw_nonchar_validator) callbacks = [] callbacks.append(user_update_callback) if callback: if isinstance(callback, list): callbacks.extend(callback) else: callbacks.append(callback) return update(request, values=values, validators=validators, callback=callbacks)
def update_(request): return update(request, callback=save_file)
def update_(request): return update(request, update_callback)