diff --git a/friends_map/settings.py b/friends_map/settings.py
index b0a94c1..ebef48f 100644
--- a/friends_map/settings.py
+++ b/friends_map/settings.py
@@ -158,5 +158,6 @@ APP = {
CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOGOUT_REDIRECT_URL = '/'
+LOGIN_REDIRECT_URL = '/'
django_heroku.settings(locals(), allowed_hosts=False, databases=DJANGO_ENV == 'prod')
diff --git a/map/templates/map/change_profile.html b/map/templates/map/change_profile.html
new file mode 100644
index 0000000..572bbe9
--- /dev/null
+++ b/map/templates/map/change_profile.html
@@ -0,0 +1,13 @@
+{% extends 'map/base.html' %}
+{% load crispy_forms_filters %}
+
+{% block h1 %}Change your profile{% endblock %}
+
+{% block content %}
+
+{% endblock %}
diff --git a/map/templates/map/delete_location.html b/map/templates/map/delete_location.html
index ef9b15d..1249804 100644
--- a/map/templates/map/delete_location.html
+++ b/map/templates/map/delete_location.html
@@ -4,10 +4,16 @@
{% block h1 %}Delete your location{% endblock %}
{% block content %}
- Are you sure you want to delete your location ? There is no turning back.
+
+
Are you sure?
+
+ Are you sure you want to delete your location ? This can't be undone,
+ though you will be able to add it again in the future.
+
+
{% endblock %}
diff --git a/map/templates/map/delete_profile.html b/map/templates/map/delete_profile.html
new file mode 100644
index 0000000..e004e63
--- /dev/null
+++ b/map/templates/map/delete_profile.html
@@ -0,0 +1,19 @@
+{% extends 'map/base.html' %}
+{% load crispy_forms_filters %}
+
+{% block h1 %}Delete your location{% endblock %}
+
+{% block content %}
+
+
Are you sure?
+
+ Are you sure you want to delete your profile ? You will permanently lose access to this service.
+ This can't be undone.
+
+
+
+{% endblock %}
diff --git a/map/templates/map/navbar.html b/map/templates/map/navbar.html
index 33c97b0..c9fe5d2 100644
--- a/map/templates/map/navbar.html
+++ b/map/templates/map/navbar.html
@@ -20,12 +20,13 @@
Admin
{% endif %}
+ Edit profile
Change password
Logout
{% else %}
- Login
+ Login
{% endif %}
diff --git a/map/urls.py b/map/urls.py
index 1ac221d..b28ea51 100644
--- a/map/urls.py
+++ b/map/urls.py
@@ -7,4 +7,6 @@ urlpatterns = [
path('change-location', views.EditLocationView.as_view(), name='change-location'),
path('add-location', views.AddLocationView.as_view(), name='add-location'),
path('delete-location', views.DeleteLocationView.as_view(), name='delete-location'),
+ path('accounts/profile', views.UpdateProfileView.as_view(), name='change-profile'),
+ path('accounts/profile/delete', views.DeleteProfileView.as_view(), name='delete-profile'),
]
diff --git a/map/views.py b/map/views.py
index 1d5c4b0..9fffb54 100644
--- a/map/views.py
+++ b/map/views.py
@@ -86,3 +86,38 @@ class DeleteLocationView(LoginRequiredMixin, generic.DeleteView):
def get_success_url(self):
messages.success(self.request, 'Your location has been successfully deleted')
return super().get_success_url()
+
+
+class UpdateProfileView(LoginRequiredMixin, generic.UpdateView):
+ model = models.Friend
+ context_object_name = 'friend'
+ template_name = 'map/change_profile.html'
+ success_url = reverse_lazy('map')
+
+ fields = [
+ 'username',
+ 'first_name',
+ 'last_name',
+ 'email',
+ ]
+
+ def get_object(self, queryset=None):
+ return self.request.user
+
+ def get_success_url(self):
+ messages.success(self.request, 'Your profile has been successfully updated')
+ return super().get_success_url()
+
+
+class DeleteProfileView(LoginRequiredMixin, generic.DeleteView):
+ model = models.Friend
+ context_object_name = 'friend'
+ template_name = 'map/delete_profile.html'
+ success_url = reverse_lazy('map')
+
+ def get_object(self, queryset=None):
+ return self.request.user
+
+ def get_success_url(self):
+ messages.success(self.request, 'Your profile has been successfully and permanently deleted')
+ return super().get_success_url()