Exemplo n.º 1
0
def updateAcountInfo():
    type=request.args.get('type')
    if type:
        type=string.atoi(type)  #医生:1 病人:2
    else:
        type=2
    userId=None
    if session.has_key('userId'):
        userId=session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    form=UserUpdateForm(request.form)
    paraRs=form.validate()
    if rs.SUCCESS.status==paraRs.status:
        User.update(userId,form.name,form.account,form.mobile,form.address,form.email,form.identityCode,form.yibaoCard)
        if type==1:
            doctor=Doctor(userId)
            doctor.identityPhone=form.identityPhone
            hospitalId=Doctor.update(doctor)
            if hospitalId:
                hospital=Hospital(form.hospitalName)
                hospital.id=hospitalId
                Hospital.updateHospital(hospital)

        return json.dumps(rs.SUCCESS.__dict__,ensure_ascii=False)

    return json.dumps(rs.FAILURE.__dict__,ensure_ascii=False)
Exemplo n.º 2
0
def updateAcountInfo():
    type = request.form.get('type')
    if type:
        type = string.atoi(type)  #医生:1 病人:2
    else:
        type = 2
    userId = None
    if session.has_key('userId'):
        userId = session['userId']
    if userId is None:
        return redirect(LOGIN_URL)
    form = UserUpdateForm(request.form)
    paraRs = form.validate()
    if rs.SUCCESS.status == paraRs.status:
        User.update(userId, form.name, form.account, form.mobile, form.address,
                    form.email, form.identityCode, form.yibaoCard)
        if type == 1:
            doctor = Doctor(userId)
            doctor.identityPhone = form.identityPhone
            doctor.username = form.name
            hospitalId = Doctor.update(doctor)
            # if hospitalId:
            #     hospital=Hospital(form.hospitalName)
            #     hospital.id=hospitalId
            #     Hospital.updateHospital(hospital)

        return json.dumps(rs.SUCCESS.__dict__, ensure_ascii=False)

    return json.dumps(rs.FAILURE.__dict__, ensure_ascii=False)
Exemplo n.º 3
0
def profile():
    """Update profile for current user."""

    if not g.user:
        flash('You must login!')
        return redirect('/login')

    form = UserUpdateForm(obj=g.user)
    if form.validate_on_submit():
        username = form.username.data
        email = form.email.data
        image_url = form.image_url.data or DEFAULT_USER_IMG
        header_image_url = form.header_image_url.data
        bio = form.bio.data
        password = form.password.data

        if User.authenticate(username, password) == g.user:
            g.user.username = username
            g.user.email = email
            g.user.image_url = image_url
            g.user.header_image_url = header_image_url
            g.user.bio = bio

            db.session.commit()

            return redirect(f'/users/{g.user.id}')
        else:
            flash("Username and/or password is invalid.")
            return redirect('/')
    else:
        return render_template("users/edit.html", form=form, user_id=g.user.id)
Exemplo n.º 4
0
def profile():
    """Update profile for current user."""

    if not g.user:
        flash("Access unauthorized.", "danger")
        return redirect("/")

    # user = User.query.get(session[CURR_USER_KEY])

    form = UserUpdateForm(obj=g.user)

    if form.validate_on_submit():
        user = User.authenticate(g.user.username, form.password.data)
        if user:
            user.username = form.username.data
            user.email = form.email.data
            user.image_url = form.image_url.data
            user.header_image_url = form.header_image_url.data
            user.bio = form.bio.data
            user.location = form.location.data

            db.session.commit()
            return redirect(f'/users/{user.id}')
        else:
            flash('Wrong password!')
            return redirect('/')

    return render_template('/users/edit.html', form=form)
Exemplo n.º 5
0
def profile():
    """Update profile for current user."""

    # IMPLEMENT THIS
    if not g.user:
        flash("Access unauthorized.", "danger")
        return redirect("/")

    form = UserUpdateForm(obj=g.user)

    if form.validate_on_submit():
        user = User.authenticate(g.user.username, form.password.data)

        if user:
            user.username = form.username.data
            user.email = form.email.data
            user.image_url = form.image_url.data
            user.header_image_url = form.header_image_url.data
            user.bio = form.bio.data
            db.session.commit()

            flash(f"User {user.username} updated!", "success")
            return redirect(f"/users/{user.id}")

        flash("Invalid credentials.", 'danger')
        return redirect("/")

    return render_template("/users/edit.html", form=form)
Exemplo n.º 6
0
def update():
  form = UserUpdateForm()

  if request.method == 'POST':
    if form.validate() == False:
      flash('All fields are required.')
      return render_template('update_user.html', form=form)
    else:

      print "Name Is %s" %(form.username.data)
      print "Shell Is %s" %(form.sudo.data)
      print ('hello i am here1')



      f1=str(form.name.data)
      f2=str(form.username.data)
      f3=str(form.shelltype.data)
      f4=str(form.homefolder.data)
      f5=str(form.password.data)
      f6=str(form.sudo.data)
      print ('hello i am here2')

#      print f1 , f2 , f3, f4 ,f5,f6
      print ('hello i am here3')
      u=updateUser(f1,f2,f3,f4,f5,f6)
      print ('helllo i am here 4')
      return render_template('success.html', result=u)




  else:
    return render_template('update_user.html', form=form ,page_title = 'Update User Form')
Exemplo n.º 7
0
def update_user(request, user_id=None):
    user = get_object_or_404(User, userprofile__supervisor=request.user, pk=user_id) 
    if request.POST:
        user_form = UserUpdateForm(request.POST)
        if user_form.is_valid():
            # create the user and update profile information
            user.first_name = user_form.cleaned_data['first_name']
            user.last_name = user_form.cleaned_data['last_name']
            user.email = user_form.cleaned_data['email']
            if user_form.cleaned_data['password']:
                user.set_password(user_form.cleaned_data['password'])
            user.save()

            request.flash.now['notice'] = "Teller successfully updated!"
            user_form = UserUpdateForm()
        else:
            errors_list = [user_form.errors[key] for key in user_form.errors.keys()]
            error_messages = ["<br />".join(x) for x in errors_list]
            error_messages = "<br />".join(error_messages)
            request.flash.now['error'] = error_messages
    else:
        user_form = UserUpdateForm()
    context = {'form': user_form }
    context['user'] = user

    return render_to_response("webapp/update_user.html", context, context_instance=RC(request))
Exemplo n.º 8
0
def profile():
    """Update profile for current user."""

    if not g.user:
        flash("Access unauthorized.", "danger")
        return redirect("/")

    form = UserUpdateForm(obj=g.user)

    if form.validate_on_submit():
        # check if password submitted on form is user's correct password
        if not g.user.authenticate(g.user.username, form.password.data):

            flash("Invalid Password", "danger")
            return render_template('users/edit.html', user=g.user, form=form)

        g.user.username = form.username.data
        g.user.email = form.email.data
        g.user.image_url = form.image_url.data
        g.user.header_image_url = form.header_image_url.data
        g.user.bio = form.bio.data

        db.session.commit()
        return redirect(f'/users/{g.user.id}')

    else:
        return render_template('users/edit.html', user=g.user, form=form)
Exemplo n.º 9
0
def update_user():
    """Updates a user."""

    if not g.user:
        flash("Access unauthorized.", "danger")
        return redirect("/")

    form = UserUpdateForm(obj=g.user)

    if form.validate_on_submit():
        user = User.authenticate_username(g.user.username, form.pwd.data)

        if user:
            if form.new_pwd.data:
                g.user.password = User.hash_password(form.new_pwd.data)

            g.user.username = form.username.data
            g.user.email = form.email.data
            g.user.darkmode = form.darkmode.data

            db.session.add(user)
            db.session.commit()
            return redirect(f"/users/{g.user.id}")

        flash(
            "We couldn't authenticate you with that password. " +
            "Please try again.",
            "danger",
        )
        return render_template("update-user.html", form=form)

    return render_template("update-user.html", form=form)
Exemplo n.º 10
0
def profile():
    """Update profile for current user."""

    if not g.user:
        flash("Access unauthorized.", "danger")
        return redirect("/")

    form = UserUpdateForm(obj=g.user)
    if form.validate_on_submit():
        # verify user typed in correct password
        if g.user.authenticate(g.user.username, form.password.data):
            g.user.username = form.username.data
            g.user.email = form.email.data
            if form.image_url.data:
                g.user.image_url = form.image_url.data
            if form.header_image_url.data:
                g.user.header_image_url = form.header_image_url.data
            if form.bio.data:
                g.user.bio = form.bio.data
            db.session.add(g.user)
            db.session.commit()
            return redirect(f"/users/{g.user.id}")

        flash("Invalid password.", "danger")
        return redirect("/")

    return render_template("users/edit.html", form=form, user_id=g.user.id)
Exemplo n.º 11
0
def profile():
    """Update profile for current user."""

    if not g.user:
        flash("Access unauthorized", "danger")
        return redirect("/")
    form = UserUpdateForm()

    if form.validate_on_submit():
        user = User.authenticate(g.user.username, form.password.data)

        if user:
            user.username = form.username.data
            user.email = form.email.data
            user.image_url = form.image_url.data
            user.header_image_url = form.header_image_url.data
            user.bio = form.bio.data

            db.session.add(user)
            db.session.commit()
            flash("Information updated", "success")
            return redirect(f'/users/{g.user.id}')
        else:
            flash("Incorrect password")
            return redirect('/')

    else:
        form.username.data = g.user.username
        form.email.data = g.user.email
        form.image_url.data = g.user.image_url
        form.header_image_url.data = g.user.header_image_url
        form.bio.data = g.user.bio
        return render_template('/users/edit.html', form=form)
Exemplo n.º 12
0
def profile():
    """Update profile for current user."""

    form = UserUpdateForm(obj=g.user)

    if form.validate_on_submit():
        user = User.authenticate(g.user.username, form.password.data)

        if user:
            user.username = form.username.data
            user.data = form.email.data
            user.image_url = form.image_url.data
            user.header_image_url = form.header_image_url.data
            user.bio = form.bio.data
            db.session.commit()

            flash('You updated your profile', 'success')

            return redirect(f'/users/{g.user.id}')
        else:
            flash('Incorrect credentials', 'danger')

            return redirect(url_for('profile'))
    else:

        return render_template('/users/edit.html', form=form)

    return redirect('/')
Exemplo n.º 13
0
def profile():
    """Update profile for current user."""

    if not g.user:
        flash("Access unauthorized.", "danger")
        return redirect("/")

    form = UserUpdateForm(obj=g.user)

    if form.validate_on_submit():
        if User.authenticate(g.user.username, form.password.data):
            g.user.username = form.username.data
            g.user.email = form.email.data
            g.user.image_url = form.image_url.data
            g.user.header_image_url = form.header_image_url.data
            g.user.location = form.location.data
            g.user.bio = form.bio.data

            db.session.commit()
            flash("Successfully updated your profile!", "success")

            return redirect(f"/users/{g.user.id}")

        else:
            flash("Incorrect password.", "danger")

    return render_template("users/edit.html", form=form, user=g.user)
Exemplo n.º 14
0
    def get_post(self, request, post):
        if request.user.is_authenticated():
            u = User.objects.get(username=request.user)
            form = UserUpdateForm(post, u.id)

            if form.is_valid():
                user = form.update()
                return user
            return form.error
Exemplo n.º 15
0
	def post(self, request):
		form = UserUpdateForm()
		if form.is_valid():
			form.save()
			request.session["temp_user"] = {
				'username': request.POST["username"],
				'new': False,
			}
			return redirect('/accounts/register/done/')
		else:
			return render(request, self.template_name, {'user_update_form': form})
Exemplo n.º 16
0
 def post(self, request, *args, **kwargs):
     updateForm = UserUpdateForm(request.POST, request.FILES, instance=request.user)
     if updateForm.is_valid():
         email = updateForm.cleaned_data['email']
         users = CustomUser.objects.filter(email=email)
         if len(users) >= 1 and users[0] != request.user:
             errors = updateForm._errors.setdefault("email", ErrorList())
             errors.append(u"This email has been register with another account.")
         else:
             updateForm.save();
             updateForm = UserUpdateForm(instance=request.user)
     return render(request, 'accounts/profile.html', {'userUpdateForm': updateForm})
Exemplo n.º 17
0
 def put(self):
     """update or patch"""
     form = UserUpdateForm(data=request.get_json())
     if form.validate():
         user_service = service.UserService()
         try:
             u = user_service.update(form)
             return success({'user_info': u}, code=200)
         except Exception as ex:
             return fail({'message': ex.message}, code=400)
     else:
         return fail({'errors': form.errors}, code=400)
Exemplo n.º 18
0
def render_admin_update_profile():
    contact = current_user.contact
    admin = Users.query.filter_by(contact=contact).first()
    if admin:
        form = UserUpdateForm(obj=admin)
        if request.method == 'POST' and form.validate_on_submit():
            profile = Users.query.filter_by(contact=contact).first()
            profile.username = form.username.data
            profile.password = form.password.data
            db.session.commit()
            print("Admin profile has been updated", flush=True)
            return redirect(url_for('view.render_admin_profile'))
        return render_template("update.html",
                               form=form,
                               username=current_user.username + " admin")
Exemplo n.º 19
0
def change_password():
    """This function change both users and amins password.

    It is accessable by both users and admin that is why we first access the 
    is_admin() to check if it is an admin or not.
    """

    if not is_authenticated():
        return redirect(url_for('login'))

    admin = is_admin()
    form = AdminUpdateForm() if admin else UserUpdateForm()
    pass_form = changePasswordForm()
    redirect_page_url = "admin/edit_profile_admin.html" if admin \
            else "edit_profile.html"
    redirect_url = "admin_manage_profile" if admin else "profile"

    user = current_user()
    if pass_form.validate():
        if not verify_password(pass_form.old_password.data):
            flash("Invalid Password", category="old_pass_incorect")
            return render_template(redirect_page_url, form=form,
                    pass_form=pass_form
                )
        else:
            user.password = pbkdf2_sha256.hash(pass_form.new_password.data)
            db.session.commit()
            flash("Password Changed", category="addSuccess")
            return redirect(url_for(redirect_url))
    else:
        return render_template(redirect_page_url, form=form,
                pass_form=pass_form
            )
Exemplo n.º 20
0
def render_caretaker_update_profile():
    contact = current_user.contact
    caretaker = Users.query.filter_by(contact=contact).first()
    if caretaker:
        form = UserUpdateForm(obj=caretaker)
        if request.method == 'POST' and form.validate_on_submit():
            profile = Users.query.filter_by(contact=contact).first()
            profile.username = form.username.data
            profile.password = form.password.data
            profile.isparttime = form.is_part_time.data
            profile.postalcode = form.postal_code.data
            db.session.commit()
            print("Caretaker profile has been updated", flush=True)
            return redirect(url_for('view.render_caretaker_profile'))
        return render_template("update.html",
                               form=form,
                               username=current_user.username + " caretaker")
Exemplo n.º 21
0
def update(request):
    if request.method == "POST":
        form = UserUpdateForm(request.POST, request.FILES)
        if form.is_valid():
            firstname = form.cleaned_data['firstName']
            lastname = form.cleaned_data['lastName']
            email = form.cleaned_data['email']
            user_profile = UserProfile.objects.get(user=request.user)

            request.user.first_name = firstname
            request.user.last_name = lastname
            request.user.username = email
            request.user.email = email
            if request.FILES:
                photo = request.FILES['photo']
                user_profile.profilePhoto.save(
                    str(request.user.id) + ".jpg", photo)
                user_profile.save()
                #user_profile.profilePhoto.name='/images/'+str(request.user.id)+'.jpeg'
                image = Image.open(user_profile.profilePhoto.path)
                image = image.resize((96, 96), Image.ANTIALIAS)
                image.save(user_profile.profilePhoto.path, "jpeg")
                user_profile.save()
            request.user.save()
            return HttpResponseRedirect("/email/update")

    else:
        user_profile = UserProfile.objects.get(user=request.user)

        initial_data = {
            'email': request.user.email,
            'firstName': request.user.first_name,
            'lastName': request.user.last_name
        }
        form = UserUpdateForm(initial=initial_data)

    unread_message_count = Message.objects.count_unread(request.user)
    data = {
        'form': form,
        'title': "Profile",
        'img': request.user.userprofile.profilePhoto.url,
        'unread': unread_message_count,
        'user': request.user
    }
    return render_to_response("email_app/update.html", data)
Exemplo n.º 22
0
def update_user(request, user_id=None):
    user = get_object_or_404(User,
                             userprofile__supervisor=request.user,
                             pk=user_id)
    if request.POST:
        user_form = UserUpdateForm(request.POST)
        if user_form.is_valid():
            # create the user and update profile information
            user.first_name = user_form.cleaned_data['first_name']
            user.last_name = user_form.cleaned_data['last_name']
            user.email = user_form.cleaned_data['email']
            if user_form.cleaned_data['password']:
                user.set_password(user_form.cleaned_data['password'])
            user.save()

            request.flash.now['notice'] = "Teller successfully updated!"
            user_form = UserUpdateForm()
        else:
            errors_list = [
                user_form.errors[key] for key in user_form.errors.keys()
            ]
            error_messages = ["<br />".join(x) for x in errors_list]
            error_messages = "<br />".join(error_messages)
            request.flash.now['error'] = error_messages
    else:
        user_form = UserUpdateForm()
    context = {'form': user_form}
    context['user'] = user

    return render_to_response("webapp/update_user.html",
                              context,
                              context_instance=RC(request))
Exemplo n.º 23
0
def render_owner_profile_update():
    contact = current_user.contact
    petowner = Users.query.filter_by(contact=contact).first()
    if petowner:
        form = UserUpdateForm(obj=petowner)
        if request.method == 'POST' and form.validate_on_submit():
            profile = Users.query.filter_by(contact=contact).first()
            profile.username = form.username.data
            profile.password = bcrypt.generate_password_hash(
                form.password.data).decode('utf-8')
            profile.card = form.credit_card.data
            profile.postalcode = form.postal_code.data
            db.session.commit()
            print("Owner profile has been updated", flush=True)
            return redirect(url_for('view.render_owner_profile'))
        return render_template("update.html",
                               form=form,
                               username=current_user.username + " owner")
Exemplo n.º 24
0
def render_owner_profile_update():
    contact = current_user.contact
    userQuery = "SELECT * FROM users WHERE contact = '{}';".format(contact)
    petowner = db.session.execute(userQuery).fetchall()
    if petowner:
        form = UserUpdateForm(obj=petowner)
        if request.method == 'POST' and form.validate_on_submit():
            update = """UPDATE users
                    SET username = '******', password = '******', card = '{}', postalcode = '{}'
                    WHERE contact = '{}';""".format(
                form.username.data,
                bcrypt.generate_password_hash(
                    form.password.data).decode('utf-8'), form.credit_card.data,
                form.postal_code.data, contact)
            db.session.execute(update)
            db.session.commit()
            return redirect(url_for('view.render_owner_profile'))
        return render_template("update.html",
                               form=form,
                               username=current_user.username)
def profile():
    """This function edit normal user profile."""
    # redirct if user is already authenticated
    if not is_authenticated() or is_admin():
        return redirect(url_for('login'))

    form = UserUpdateForm()
    pass_form = changePasswordForm()
    user = current_user()

    if request.method == "GET":
        form.name.data = user.name
        form.address.data = user.address
        form.email.data = user.email
        return render_template("edit_profile.html", form = form, \
            pass_form = pass_form)
    else:
        if form.validate():
            if not email_is_unique(UserModel, form.email.data, 'update'):
                flash("email already taken", category="emailNotUnique")
                return render_template("edit_profile.html",
                                       form=form,
                                       pass_form=pass_form)
            if verify_password(form.password_verify.data):
                user.name = form.name.data
                user.address = form.address.data
                user.email = form.email.data.lower()
                db.session.commit()
                flash("User Updated", category="addSuccess")
                return redirect(url_for('profile'))
            else:
                flash("Invalid Password", category="passwordIncorrect")
                return render_template("edit_profile.html",
                                       form=form,
                                       pass_form=pass_form)
        else:
            return render_template("edit_profile.html", form = form, \
            pass_form = pass_form)
Exemplo n.º 26
0
def update_user(id):
    """Update user"""
    try:
        form = UserUpdateForm(csrf_enabled=False, data=request.json)
        if form.validate():
            user = User.query.filter(User.id == id).first()

            user.first_name = form.data["first_name"]
            user.last_name = form.data["last_name"]
            user.email = form.data["email"]
            if "image_url" in form.data:
                user.image_url = form.data["image_url"]

            if "bio" in form.data:
                user.bio = form.data["bio"]

            db.session.commit()
            return jsonify({"data": user.to_dict()})
        else:
            return jsonify({"errors": "Missing fields"}), 400

    except IntegrityError as e:
        return jsonify({"errors": "Email taken"}), 400
Exemplo n.º 27
0
def profile():
    """Update profile for current user."""

    if not g.user:
        flash("Access unauthorized.", "danger")
        return redirect("/")

    form = UserUpdateForm(obj=g.user)
    if form.validate_on_submit():
        user = User.authenticate(g.user.username, form.pwd.data)

        if user:
            form.populate_obj(user)
            g.user = user
            db.session.add(user)
            db.session.commit()
            return redirect(f"/users/{g.user.id}")

        flash("That password didn't work. Please try again.", "danger")
        return render_template("/users/update.html", form=form)

    else:
        return render_template("/users/update.html", form=form)
Exemplo n.º 28
0
def update_profile(user_id):
    """Update profile for current user."""
    curr_user = User.query.get_or_404(user_id)
    form = UserUpdateForm(obj=curr_user)

    if form.validate_on_submit():
        user = User.authenticate(form.username.data, form.password.data)
        if user:
            curr_user.username = form.username.data
            curr_user.email = form.email.data
            curr_user.image_url = form.image_url.data
            curr_user.header_image_url = form.header_image_url.data
            curr_user.bio = form.bio.data
            db.session.add(curr_user)
            db.session.commit()
        else:
            flash('Incorrect username or password', 'danger')
            return render_template('users/edit.html',
                                   form=form,
                                   user=curr_user)
        return render_template('users/detail.html', user=user)
    else:
        return render_template('users/edit.html', form=form, user=curr_user)
Exemplo n.º 29
0
def viewprofile():
    """
    Handle requests to the /register route
    Add an notetaker to the database through the registration form
    """
    user = current_user
    form = UserUpdateForm(obj=user)
    form.populate_obj(user)
    if form.validate_on_submit():

        form.populate_obj(user)

        db.session.commit()

        flash('You have successfully edited your profile!')
    return render_template('user/user.html',
                           title="View Profile",
                           user=user,
                           form=form,
                           action='Edit')
Exemplo n.º 30
0
def profile(user_id):
    """
    a profile page for normal registered users
    if it is users own profile; user can change account info
    else; user can see the common clubs and basic information of the other user
    """
    if not current_user.is_authenticated:
        return redirect(url_for('login'))
    if current_user.is_admin:
        abort(401)
    try:
        form = UserUpdateForm()
        user = get_user_by_id(id=current_user.id)
        if request.method == 'GET':
            if user_id == current_user.id:
                user = get_user_by_id(id=current_user.id)
                form.name.data = user.name
                form.surname.data = user.surname
                form.student_id.data = user.student_id
                form.email.data = user.email
                #form.department.data = user.department
                if user.gender:
                    form.gender.data = user.gender
                return render_template('profile.html',
                                       form=form,
                                       name=None,
                                       surname=None,
                                       student_id=None,
                                       department=None)
            elif user_id != current_user.id:
                user = get_user_by_id(id=user_id)
                name = user.name
                surname = user.surname
                student_id = user.student_id
                department = user.department
                get_common_clubs_statement = """select clubs.id, clubs.name from clubs 
                                                join members 
                                                on clubs.id = members.club_id 
                                                join users 
                                                on users.id = members.user_id 
                                                where users.id = %s
                                                INTERSECT 
                                                select clubs.id, clubs.name from clubs 
                                                join members 
                                                on clubs.id = members.club_id 
                                                join users 
                                                on users.id = members.user_id 
                                                where users.id = %s """
                with connection.cursor() as cursor:
                    cursor.execute(get_common_clubs_statement,
                                   (current_user.id, user_id))
                    common_clubs = cursor.fetchall()

                return render_template('profile.html',
                                       name=name,
                                       surname=surname,
                                       student_id=student_id,
                                       department=department,
                                       common_clubs=common_clubs)
        elif request.method == 'POST':
            if 'delete' in request.form:
                return "asd"
                logout_user()
                delete_user(user_id=user_id)
                flash('User Deleted')
                return redirect(url_for('register'))
            if form.validate_on_submit():
                name = form.data["name"]
                surname = form.data["surname"]
                student_id = form.data["student_id"]
                email = form.data["email"]
                if form.data["gender"]:
                    gender = form.data["gender"]
                else:
                    gender = None
                x = False
                if (user.student_id != student_id):
                    x = True
                update_user(current_user.id, name, surname, student_id, email,
                            gender)
                if x:
                    flash(
                        'Your student id is changed, login again with your new id'
                    )
                return redirect(url_for('profile', user_id=current_user.id))
            else:
                print(form.errors)
                return render_template('profile.html', form=form)
    except Exception as e:
        print("Error in profile page", e)