flask-base/templates/profile.html

154 lines
4.3 KiB
HTML

{% extends "base.html" %}
{% block title %}My Profile{% endblock %}
{% block content %}
<div class="profile-container">
<form method="POST" enctype="multipart/form-data" action="{{ url_for('profile') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="form-group">
<label for="avatar">Avatar</label>
{% if user.avatar_url %}
<div class="avatar-preview">
<img src="{{ user.avatar_url }}" alt="Avatar">
<small>Current avatar</small>
</div>
{% endif %}
<input type="file" name="avatar" accept="image/*" id="avatar" class="form-control-file">
<small>Upload a new avatar (PNG, JPG, GIF, WEBP)</small>
</div>
<div class="form-group">
<label for="first_name">First Name</label>
<input type="text" name="first_name" id="first_name" class="form-control"
value="{{ user.first_name if user.first_name else '' }}" placeholder="Enter first name">
{% if not user.has_profile() %}
<small class="text-warning">Profile incomplete - please add your name</small>
{% endif %}
</div>
<div class="form-group">
<label for="last_name">Last Name</label>
<input type="text" name="last_name" id="last_name" class="form-control"
value="{{ user.last_name if user.last_name else '' }}" placeholder="Enter last name">
{% if not user.has_profile() %}
<small class="text-warning">Profile incomplete - please add your name</small>
{% endif %}
</div>
<h3>Profile Information</h3>
<hr>
<h3>Change Password</h3>
<hr>
<div class="form-group">
<label for="current_password">Current Password</label>
<input type="password" name="current_password" id="current_password" class="form-control" placeholder="Enter your current password">
<small>Required to verify your identity before changing password</small>
</div>
<div class="form-group">
<label for="new_password">New Password</label>
<input type="password" name="new_password" id="new_password" class="form-control" placeholder="Enter new password">
<small>Must be at least 8 characters long</small>
</div>
<div class="form-group">
<label for="confirm_password">Confirm New Password</label>
<input type="password" name="confirm_password" id="confirm_password" class="form-control" placeholder="Confirm your new password">
</div>
<div class="form-group">
<label>
<input type="checkbox" id="action" name="action" value="change_password">
Change my password
</label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Update Profile</button>
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Cancel</a>
</div>
</form>
</div>
<style>
.profile-container {
max-width: 600px;
margin: 2rem auto;
padding: 1rem;
}
.profile-form {
background: #fff;
padding: 1.5rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.form-group {
margin-bottom: 1.5rem;
}
hr {
margin: 1rem 0;
border: none;
border-top: 1px solid #ddd;
}
label {
display: block;
margin-bottom: 0.5rem;
font-weight: bold;
}
.form-control {
width: 100%;
padding: 0.75rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1rem;
}
.form-control-file {
display: block;
margin-top: 0.5rem;
width: 100%;
padding: 0.5rem;
border: 2px dashed #ddd;
border-radius: 4px;
cursor: pointer;
}
.btn {
display: inline-block;
padding: 0.75rem 1.5rem;
border-radius: 4px;
text-decoration: none;
font-weight: 500;
border: none;
cursor: pointer;
margin-right: 0.5rem;
}
.btn-primary {
background: #3498db;
color: white;
}
.btn-primary:hover {
background: #2980b9;
}
.btn-secondary {
background: #95a5a6;
color: white;
}
.text-warning {
color: #e67e22;
}
</style>
{% endblock %}