Exemple #1
0
 def _handle_avatar(self, user):
     """
     Append avatar if uploaded.
     """
     _file = request.files['avatar']
     if _file and is_allowed_file_format(_file.filename):
         filename = handle_avatar(_file, user)
         user.avatar = filename
Exemple #2
0
 def _handle_avatar(self, user):
     """
     Append avatar if uploaded.
     """
     _file = request.files['avatar']
     if _file and is_allowed_file_format(_file.filename):
         filename = handle_avatar(_file, user)
         user.avatar = filename
    def form_valid(self, form):
        """
        Update profile on form's data.
        """
        profile = self.get_object()

        _file = request.files['avatar']
        if _file and is_allowed_file_format(_file.filename):
            filename = handle_avatar(_file, profile)
            profile.avatar = filename

        profile.display_name = form.display_name.data
        profile.friends = db.session.query(Profile).filter(
            Profile.id.in_(form.friends.data)
        ).all()
        profile.motivation_quote = form.motivation_quote.data

        db.session.add(profile)