Created an edit profile view for the user.

Created an editBoodleUser html file.
Co-authored-by: 's avatarpinkboheme <pinkboheme@users.noreply.github.com>
parent 550c8fa3
{% extends 'boodlesite\templates\base.html' %}
{% load static %}
{% block title %}My Profile{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<div class="container">
<h1>{{ title }}</h1>
<div class="row">
<div class="col-lg-7 col-md-6">ITEM IMAGE CONTAINER
<div class="item-image-container"></div>
</div>
<div class=" col-lg-5 col-md-6">ITEM FORM CONTAINER
<div class="item-form-container">
<form action="" method="POST">
{% csrf_token %}
{{ form.as_p }}
</div>
<button type="submit" name="Add Item"> Save Changes </button>
</form>
</div>
</div>
</div>
<!-- Form with fields:
[Item name]
[Item Description]
[Floor Price] -->
<!-- Image, if no image add image -->
{% endblock %}
\ No newline at end of file
......@@ -32,7 +32,10 @@
data-whatever="@mdo">Create Store</button>
{% endif %}
<button type="button" class="btn btn-primary">Edit Profile</button>
<button type="button" class="btn btn-primary">
<a href= "{% url 'editProfile' user %}" >
Edit Profile
</a></button>
</div>
</div>
......
......@@ -111,3 +111,15 @@ class CreateStoreForm(forms.ModelForm):
'storename': _('Store Name'),
'storedesc': _('Store Description')
}
class editBoodleUserForm(forms.ModelForm):
class Meta:
model = BoodleUser
fields = ['displayname', 'username', 'userid']
widgets = {'userid': forms.HiddenInput()}
labels = {
'username': _('User Name'),
'displayname': _('Display Name')
}
\ No newline at end of file
......@@ -109,6 +109,9 @@ class BoodleUser(models.Model):
managed = False
db_table = 'boodleuser'
def __str__(self):
return '%s' % (self.userid)
class DjangoAdminLog(models.Model):
action_time = models.DateTimeField()
......
......@@ -20,4 +20,5 @@ urlpatterns = [
path('profile', tempProfile, name='profile'),
path('profile/<int:pk>', profile, name='profileid'),
path('editstore/<int:pk>', editStore, name='editstoreid'),
path('editProfile/<int:pk>', editProfile, name='editProfile'),
]
\ No newline at end of file
......@@ -273,6 +273,7 @@ def profile(request, pk):
context = {
'displayname': current_user.displayname,
'username': current_user.username,
'user': current_user.userid,
'store': current_storeid,
'bidsByUser' : bidsByUser,
'auctionsOfUser': auctionsOfUser,
......@@ -301,3 +302,22 @@ def editStore(request, pk):
}
return render(request, "boodlesite/templates/storeForm.html", context)
def editProfile(request, pk):
user= BoodleUser.objects.get(userid=pk) # boodleuser object
current_user = user.userid #boodle user id
form = editBoodleUserForm(instance=user)
if request.method == 'POST':
form = editBoodleUserForm(request.POST, instance=user)
if form.is_valid():
form.save()
return redirect('profileid', pk=current_user)
context = {
'form': form,
'title': 'Edit Profile Information',
}
return render(request, "boodlesite/templates/editBoodleUser.html", context)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment