Exemple #1
0
def settings():
    delete_user_account_form = DeleteUserAccountForm()
    user_info_form = UserInformationForm(obj=current_user)
    if user_info_form.validate_on_submit():
        user_info_form.populate_obj(current_user)
        current_user.save()
    return render_template('settings.html', user_info_form=user_info_form, delete_user_account_form=delete_user_account_form)
Exemple #2
0
def settings():
    delete_user_account_form = DeleteUserAccountForm()
    user_info_form = UserInformationForm(obj=current_user)
    if user_info_form.validate_on_submit():
        user_info_form.populate_obj(current_user)
        current_user.save()
    return render_template('settings.html',
                           user_info_form=user_info_form,
                           delete_user_account_form=delete_user_account_form)
Exemple #3
0
    def post(self):
        '''Upload a new avatar'''
        args = avatar_parser.parse_args()

        avatar = args['file']
        bbox = [int(float(c)) for c in args['bbox'].split(',')] if 'bbox' in args else None
        current_user.avatar.save(avatar, bbox=bbox)
        current_user.save()

        return current_user
Exemple #4
0
    def post(self):
        """Upload a new avatar"""
        args = avatar_parser.parse_args()

        avatar = args["file"]
        bbox = [int(float(c)) for c in args["bbox"].split(",")] if "bbox" in args else None
        current_user.avatar.save(avatar, bbox=bbox)
        current_user.save()

        return current_user
Exemple #5
0
def set_item_in_branch(item_id, branch_num, value):
    line = None
    for i in current_user.story_items:
        if i.id == item_id:
            line = i
            break
    if not line:
        abort(400, 'item must be part of the story'.format(item_id))
    line.in_branch[branch_num] = value
    current_user.save()
Exemple #6
0
 def delete(self, slug):
     if not current_user.is_authenticated():
         abort(401)
     obj = self.get_or_404(slug=slug)
     key = obj.__class__.__name__.lower()
     starred = getattr(current_user, 'starred_{0}s'.format(key))
     starred.remove(obj)
     current_user.save()
     obj.on_unstar.send(obj)
     return marshal(current_user, user_fields), 204
Exemple #7
0
    def post(self):
        '''Upload a new avatar'''
        args = avatar_parser.parse_args()

        avatar = args['file']
        bbox = ([int(float(c))
                 for c in args['bbox'].split(',')] if 'bbox' in args else None)
        current_user.avatar.save(avatar, bbox=bbox)
        current_user.save()

        return current_user
Exemple #8
0
    def dispatch_request(self, resp):
        if resp is None:
            flash(u'You denied the request to sign in.')
            return redirect(url_for('frontend.index'))
            
        if self.blueprint.api.oauth_type == 'oauth2':
            resp['access_token'] = (resp['access_token'], '') #need to make it a tuple for oauth2 requests

        current_user['services'][self.blueprint.name] = resp
        current_user.save()

        flash('You were signed in to %s' % self.blueprint.name.capitalize())
        return redirect(url_for('frontend.index'))
Exemple #9
0
    def post(self, slug):
        if not current_user.is_authenticated():
            abort(401)
        obj = self.get_or_404(slug=slug)
        key = obj.__class__.__name__.lower()
        starred = getattr(current_user, 'starred_{0}s'.format(key))

        if obj not in starred:
            starred.append(obj)
            current_user.save()
            obj.on_star.send(obj)
            return marshal(current_user, user_fields), 201
        else:
            return marshal(current_user, user_fields)
Exemple #10
0
def add_to_my_story(item_id):
    current_user.story_items.append(
        StoryLine(id=item_id, in_branch=4 * [False]))
    current_user.save()
Exemple #11
0
def clear():
    current_user.services = None
    current_user.save()
    return jsonify(user=current_user.to_dict())
Exemple #12
0
def set_story_branch_name(branch_num):

    name = request.data
    current_user.story_branches[int(branch_num) - 1] = name
    current_user.save()
    return humanify(current_user.get_mjs())
Exemple #13
0
 def post(self):
     """Upload a new avatar"""
     parse_uploaded_image(current_user.avatar)
     current_user.save()
     return {"image": current_user.avatar}
Exemple #14
0
 def delete(self):
     '''Clear/destroy an apikey'''
     current_user.apikey = None
     current_user.save()
     return '', 204
Exemple #15
0
 def post(self):
     '''Upload a new avatar'''
     parse_uploaded_image(current_user.avatar)
     current_user.save()
     return {'image': current_user.avatar}
Exemple #16
0
 def delete(self):
     '''Clear/destroy an apikey'''
     current_user.apikey = None
     current_user.save()
     return '', 204
Exemple #17
0
 def post(self):
     '''(Re)Generate my API Key'''
     current_user.generate_api_key()
     current_user.save()
     return current_user, 201
Exemple #18
0
 def post(self):
     '''(Re)Generate my API Key'''
     current_user.generate_api_key()
     current_user.save()
     return current_user, 201
Exemple #19
0
def remove_item_from_story(item_id):
    current_user.story_items = [
        i for i in current_user.story_items if i.id != item_id
    ]
    current_user.save()
Exemple #20
0
 def post(self):
     '''Upload a new avatar'''
     parse_uploaded_image(current_user.avatar)
     current_user.save()
     return {'image': current_user.avatar}
Exemple #21
0
 def delete(self):
     """Clear/destroy an apikey"""
     current_user.apikey = None
     current_user.save()
     return "", 204