Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added user profile edit option #262

Closed
wants to merge 89 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
a000a6c
styled helpline, added meta tag to common
tanishq-arya Mar 28, 2021
9e8f794
changes to td a tags
tanishq-arya Mar 30, 2021
9b88c01
Merge branch 'master' of https://github.com/swapnilsparsh/Rescue into…
tanishq-arya Apr 6, 2021
9da9670
Merge branch 'master' of https://github.com/swapnilsparsh/Rescue into…
tanishq-arya Apr 10, 2021
cfb8b5e
fixed and styled login page
tanishq-arya Apr 10, 2021
a6fcc5b
Merge branch 'master' of https://github.com/swapnilsparsh/Rescue into…
tanishq-arya Apr 12, 2021
62e2678
fixed login page
tanishq-arya Apr 12, 2021
e8b1d52
added delete account feature
Apr 13, 2021
7ed0288
Adding Women Safety Numbers Statewise
naman153 Apr 15, 2021
1395677
FAQ Page Added
VaibhavSharma24 Apr 15, 2021
a702220
Merge branch 'master' of https://github.com/swapnilsparsh/Rescue into…
tanishq-arya Apr 16, 2021
2172715
fixed register mobile view
tanishq-arya Apr 16, 2021
7eb1af8
profile edit view
SnehaVeerakumar Apr 16, 2021
d6522bd
adding link to profile update page
SnehaVeerakumar Apr 16, 2021
65f82b8
Update admin.py
SnehaVeerakumar Apr 16, 2021
534314b
User profile models
SnehaVeerakumar Apr 16, 2021
be4faa2
added profile edit page url
SnehaVeerakumar Apr 16, 2021
9bec7a5
Update views.py
SnehaVeerakumar Apr 16, 2021
1173199
Update settings.py
SnehaVeerakumar Apr 16, 2021
2b1e265
Update urls.py
SnehaVeerakumar Apr 16, 2021
223eb59
Removed Extra Space
naman153 Apr 17, 2021
e86dd3e
faq page
VaibhavSharma24 Apr 18, 2021
4bbe30d
page to update password
SnehaVeerakumar Apr 19, 2021
aa2aef6
Added function to update password
SnehaVeerakumar Apr 19, 2021
b36b20f
added url for change password page
SnehaVeerakumar Apr 19, 2021
3fd76a1
Added update password option in navigation bar
SnehaVeerakumar Apr 19, 2021
e753c53
Removed email field
SnehaVeerakumar Apr 19, 2021
3e87b32
Removed Bold Styling From Details
naman153 Apr 20, 2021
e51f477
fixed developers page
tanishq-arya Apr 20, 2021
91884af
added github link
aditya201551 Apr 21, 2021
432b60f
removed db.sqlite3'
aditya201551 Apr 22, 2021
e6d4386
New Changes Added
VaibhavSharma24 Apr 22, 2021
438cddd
Update change_password.html
SnehaVeerakumar Apr 22, 2021
0573f5a
Update common.html
SnehaVeerakumar Apr 22, 2021
7dca226
Update home.html
SnehaVeerakumar Apr 22, 2021
98b04b0
Update profile.html
SnehaVeerakumar Apr 22, 2021
ea0f0b3
Update views.py
SnehaVeerakumar Apr 22, 2021
21f31d9
Update change_password.html
SnehaVeerakumar Apr 22, 2021
7774dd0
New Vector Art
VaibhavSharma24 Apr 22, 2021
97c2a29
Changes Requested
naman153 Apr 23, 2021
b3c3bdc
Create Auto_message_on_pr_merge.yml
AB-san Apr 25, 2021
27057f2
welcome bot added
Ankita297 Apr 25, 2021
f099ab2
greeting action updated
Ankita297 Apr 27, 2021
16a21b6
Made the Changes
VaibhavSharma24 Apr 27, 2021
0c78c01
Merge pull request #276 from Ankita297/greetings
swapnilsparsh Apr 29, 2021
efcc103
Merge pull request #274 from AB-san/patch-1
swapnilsparsh Apr 29, 2021
9c9539e
Merge pull request #267 from Aditya201551/github-link
swapnilsparsh Apr 29, 2021
388aa55
Merge pull request #259 from naman153/master
swapnilsparsh Apr 29, 2021
d802735
Merge branch 'master' into helpline
tanishq-arya Apr 30, 2021
74e360a
Merge pull request #252 from coding-geek21/branch01
swapnilsparsh Apr 30, 2021
5e21c3d
Merge pull request #216 from tanishq-arya/helpline
swapnilsparsh May 1, 2021
2f82eb9
Merge pull request #260 from VaibhavSharma24/master
swapnilsparsh May 2, 2021
b25ad45
Update common.html
SnehaVeerakumar May 2, 2021
475d7e5
Update home.html
SnehaVeerakumar May 2, 2021
81fe8fb
Update profile.html
SnehaVeerakumar May 2, 2021
9da9ba2
Update admin.py
SnehaVeerakumar May 2, 2021
0a45edd
Update models.py
SnehaVeerakumar May 2, 2021
8346270
Update urls.py
SnehaVeerakumar May 2, 2021
3c3833b
Update views.py
SnehaVeerakumar May 2, 2021
685a4ec
Update settings.py
SnehaVeerakumar May 2, 2021
1ad678b
profile edit view
SnehaVeerakumar Apr 16, 2021
bebc2eb
adding link to profile update page
SnehaVeerakumar Apr 16, 2021
c3a0d27
Update admin.py
SnehaVeerakumar Apr 16, 2021
fd46254
User profile models
SnehaVeerakumar Apr 16, 2021
37e5abf
added profile edit page url
SnehaVeerakumar Apr 16, 2021
95af7ea
Update views.py
SnehaVeerakumar Apr 16, 2021
0aca2f0
Update settings.py
SnehaVeerakumar Apr 16, 2021
c2f70cc
Update urls.py
SnehaVeerakumar Apr 16, 2021
baaf9b5
page to update password
SnehaVeerakumar Apr 19, 2021
84141ef
Added function to update password
SnehaVeerakumar Apr 19, 2021
ef9e202
added url for change password page
SnehaVeerakumar Apr 19, 2021
cd05c31
Added update password option in navigation bar
SnehaVeerakumar Apr 19, 2021
32b8bc6
Removed email field
SnehaVeerakumar Apr 19, 2021
0f8ec19
Update change_password.html
SnehaVeerakumar Apr 22, 2021
1787b1a
Update common.html
SnehaVeerakumar Apr 22, 2021
9b7cd22
Update home.html
SnehaVeerakumar Apr 22, 2021
2bf03b0
Update profile.html
SnehaVeerakumar Apr 22, 2021
8aa5ce5
Update views.py
SnehaVeerakumar Apr 22, 2021
8994d4f
Update change_password.html
SnehaVeerakumar Apr 22, 2021
eb933a6
Update common.html
SnehaVeerakumar May 2, 2021
b0f44c5
Update home.html
SnehaVeerakumar May 2, 2021
acda46b
Update profile.html
SnehaVeerakumar May 2, 2021
926eccb
Update admin.py
SnehaVeerakumar May 2, 2021
9d4e2e4
Update models.py
SnehaVeerakumar May 2, 2021
df3de22
Update urls.py
SnehaVeerakumar May 2, 2021
cc37046
Update views.py
SnehaVeerakumar May 2, 2021
c38bc9c
Update settings.py
SnehaVeerakumar May 2, 2021
13ef438
Merge branch 'with-profile-edit' of https://github.com/SnehaVeerakuma…
SnehaVeerakumar May 2, 2021
fc09f41
editprofile
SnehaVeerakumar May 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed db.sqlite3
Binary file not shown.
5 changes: 5 additions & 0 deletions main_app/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from django.contrib import admin
from .models import register_table
from .models import contact

# Register your models here.
admin.site.register(contact)
admin.site.register(register_table)



32 changes: 32 additions & 0 deletions main_app/migrations/0004_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 3.0.6 on 2021-04-16 08:02

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('main_app', '0003_merge_20210408_2337'),
]

operations = [
migrations.CreateModel(
name='profile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('contact_number', models.IntegerField()),
('profile_pic', models.ImageField(blank=True, null=True, upload_to='profiles/%Y/%m/%d')),
('age', models.CharField(blank=True, max_length=250, null=True)),
('city', models.CharField(blank=True, max_length=250, null=True)),
('about', models.TextField(blank=True, null=True)),
('gender', models.CharField(default='Male', max_length=250)),
('occupation', models.CharField(blank=True, max_length=250, null=True)),
('added_on', models.DateTimeField(auto_now_add=True, null=True)),
('update_on', models.DateTimeField(auto_now=True, null=True)),
('username', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
16 changes: 16 additions & 0 deletions main_app/migrations/0005_delete_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.0.6 on 2021-04-16 08:20

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('main_app', '0004_profile'),
]

operations = [
migrations.DeleteModel(
name='profile',
),
]
32 changes: 32 additions & 0 deletions main_app/migrations/0006_register_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 3.1.7 on 2021-04-16 09:21

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('main_app', '0005_delete_profile'),
]

operations = [
migrations.CreateModel(
name='register_table',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('contact_number', models.IntegerField()),
('profile_pic', models.ImageField(blank=True, null=True, upload_to='profiles/')),
('age', models.CharField(blank=True, max_length=250, null=True)),
('city', models.CharField(blank=True, max_length=250, null=True)),
('about', models.TextField(blank=True, null=True)),
('gender', models.CharField(default='Male', max_length=250)),
('occupation', models.CharField(blank=True, max_length=250, null=True)),
('added_on', models.DateTimeField(auto_now_add=True, null=True)),
('update_on', models.DateTimeField(auto_now=True, null=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
26 changes: 26 additions & 0 deletions main_app/migrations/0007_auto_20210416_1710.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.1.7 on 2021-04-16 11:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main_app', '0006_register_table'),
]

operations = [
migrations.RemoveField(
model_name='register_table',
name='about',
),
migrations.RemoveField(
model_name='register_table',
name='occupation',
),
migrations.AlterField(
model_name='register_table',
name='profile_pic',
field=models.ImageField(blank=True, null=True, upload_to='profiles/%Y/%m/%d'),
),
]
18 changes: 18 additions & 0 deletions main_app/migrations/0008_auto_20210416_1718.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.7 on 2021-04-16 11:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main_app', '0007_auto_20210416_1710'),
]

operations = [
migrations.AlterField(
model_name='register_table',
name='profile_pic',
field=models.ImageField(blank=True, null=True, upload_to='profiles/'),
),
]
17 changes: 17 additions & 0 deletions main_app/migrations/0009_remove_register_table_profile_pic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.0.6 on 2021-04-16 14:50

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('main_app', '0008_auto_20210416_1718'),
]

operations = [
migrations.RemoveField(
model_name='register_table',
name='profile_pic',
),
]
12 changes: 12 additions & 0 deletions main_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ class Login(models.Model):
Username_or_Email= models.CharField(max_length=100)
password = models.CharField(max_length=32)


class register_table(models.Model):
user = models.OneToOneField(User,on_delete=models.CASCADE)
contact_number = models.IntegerField()
age = models.CharField(max_length=250,null=True,blank=True)
city = models.CharField(max_length=250,null=True,blank=True)
gender = models.CharField(max_length=250,default="Male")
added_on =models.DateTimeField(auto_now_add=True,null=True)
update_on = models.DateTimeField(auto_now=True,null=True)

def __str__(self):
return self.user.username
1 change: 1 addition & 0 deletions main_app/templates/main_app/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ <h4 class="User">&nbsp;&nbsp; {{user.username}}</h4>
aria-labelledby="navbarDropdown2"
style="background-color: rgb(6, 17, 31)"
>
<a class="dropdown-item" style="color: white" href="/profile">Update profile</a>
<a class="dropdown-item" style="color: white" href="/logout"
>Logout</a
>
Expand Down
10 changes: 7 additions & 3 deletions main_app/templates/main_app/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,19 @@
style="background-color: rgb(6, 17, 31); padding: None">
<ul class="navbar-nav ml-auto" style="margin-right: 20px !important">
{% if user.is_authenticated %}
<li class="nav-item dropdown" style="margin-top: 20px">
<a class="nav-link" href="#" id="navbarDropdown2" role="button" data-toggle="dropdown"

<li class="nav-item dropdown" style="margin-top: 22px">
<a class="nav-link" href="#" data-target="#navbarDopdown1" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false" style="color: white; font-size: 18px">
<h4 class="User">&nbsp;&nbsp; {{user.username}}</h4>
<h4 class="new">&nbsp;&nbsp; {{user.username}}</h4>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown2" style="background-color: rgb(6, 17, 31)">
<a class="dropdown-item" style="color: white" href="/profile">Update profile</a>
<a class="dropdown-item" style="color: white" href="/logout">Logout</a>
</div>
</li>


{% else %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown3" role="button" data-toggle="dropdown"
Expand Down
79 changes: 79 additions & 0 deletions main_app/templates/main_app/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
{% extends "main_app/common.html" %}
{% load static %}
<head>
</head>
<html lang="en">
{% block content %}
<div class="container-fluid">
<div class="row">
<div class="col-md-12 bg-img py-5 text-center text-light">
<h1>Dashboard &gt; Edit your profile</h1>
</div>
<div class="col-md-6 mx-auto p-3 bg-light my-2">
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{% if status %}
<div class="alert alert-primary">{{status}}</div>
{% endif %}
<div class="form-group">
<h1 style="margin-left: 25%;"> Edit your profile</h1>
<div class="row">
<div class="col-md-6">
<label>First Name</label>
<input type="text" class="form-control" name="fname" placeholder="Enter First Name" value="{{user.first_name}}">
</div>
<div class="col-md-6">
<label>Last Name</label>
<input type="text" class="form-control" name="lname" placeholder="Enter Last Name" value="{{user.last_name}}">
</div>
<div class="col-md-6">
<label>Age (in years)</label>
<input type="number" class="form-control" name="age" placeholder="Enter Age" min="15" max="99"
value="{{data.age}}">
</div>
<div class="col-md-6">
<label>Contact Number</label>
<input type="text" value="{{data.contact_number}}" class="form-control" name="contact" placeholder="Enter Contact Number" pattern="[0-9]{10}" title="Number must contain 10 digits only!!">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-6">
<label>Gender</label>

<select name="gender" class="form-control">
<option value="Male">Male</option>

{% if data.gender == "Female" %}
<option value="Female" selected>Female</option>
{% else %}
<option value="Female">Female</option>
{% endif %}

{% if data.gender == "Others" %}
<option value="Others" selected>Others</option>
{% else %}
<option value="Others">Others</option>
{% endif %}
</select>
</div>
<div class="col-md-6">
<label>City</label>
<input type="text" class="form-control" name="city" placeholder="Enter City" value="{{data.city}}">
</div>
</div>
</div>
<div class="form-group">
<input type="submit" name="changeprofile" value="Save Changes" class="btn btn-primary" style="margin-left: 34%;width:25%;border-radius:20px;">
</div>


</form>
</div>
</div>
</div>
{% endblock %}

</html>
3 changes: 2 additions & 1 deletion main_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
path('reset/<uidb64>/<token>/',auth_views.PasswordResetConfirmView.as_view(template_name="main_app/password_reset_form.html"), name="password_reset_confirm"),
path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(template_name="main_app/password_reset_done.html"), name="password_reset_complete"),
path('check_username',views.check_username,name="check_username"),
path('check_email',views.check_email,name="check_email")
path('check_email',views.check_email,name="check_email"),
path('profile/', views.profile,name="profile"),
]

36 changes: 34 additions & 2 deletions main_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.auth import login, logout, authenticate
from django.contrib import messages
from .forms import ContactForm
from .models import contact,Login
from .models import contact,Login,register_table
from django.contrib.auth.models import User , auth
from .mail import send_email
from .whatsapp import send_whatsapp
Expand Down Expand Up @@ -245,4 +245,36 @@ def check_email(request):
email = request.GET.get("email")
if User.objects.filter(email=email).exists():
return JsonResponse({"exists":"yes"})
return JsonResponse({"exists":"no"})
return JsonResponse({"exists":"no"})

def profile(request):
context = {}
check = register_table.objects.filter(user__id=request.user.id)
if len(check)>0:
data = register_table.objects.get(user__id=request.user.id)
context["data"]=data
if request.method=="POST":
fn = request.POST["fname"]
ln = request.POST["lname"]
con = request.POST["contact"]
age = request.POST["age"]
ct = request.POST["city"]
gen = request.POST["gender"]

usr = User.objects.get(id=request.user.id)
usr.first_name = fn
usr.last_name = ln
usr.save()

data.contact_number = con
data.age = age
data.city = ct
data.gender = gen
data.save()

context["status"] = "Changes Saved Successfully"

return render(request,'main_app/profile.html',context)



2 changes: 2 additions & 0 deletions mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
STATICFILES_DIRS = (
os.path.join(BASE_DIR+"/main_app/", 'static'),
)
MEDIA_URL='/media/'
MEDIA_ROOT =os.path.join(BASE_DIR,'media')

#SMTP Configuration
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
Expand Down
4 changes: 3 additions & 1 deletion mysite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@
path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(template_name="main_app/password_reset_done.html"), name="password_reset_complete"),
path('accounts/', include('allauth.urls')),

]


]+ static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)