diff --git a/brasilio_auth/templates/brasilio_auth/profile_update_form.html b/brasilio_auth/templates/brasilio_auth/profile_update_form.html new file mode 100644 index 00000000..5ececd9c --- /dev/null +++ b/brasilio_auth/templates/brasilio_auth/profile_update_form.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block content %} + +
+ +{% endblock %} diff --git a/brasilio_auth/urls.py b/brasilio_auth/urls.py index 056ac45e..4702531e 100644 --- a/brasilio_auth/urls.py +++ b/brasilio_auth/urls.py @@ -2,8 +2,8 @@ from django.contrib.auth import views as auth_views from django.urls import path -from brasilio_auth.views import CreateUserView - +from brasilio_auth.views import CreateUserView, ProfileUpdate +from django.contrib.auth.decorators import login_required views_config = { 'login': auth_views.LoginView.as_view(template_name='brasilio_auth/login.html'), @@ -36,4 +36,5 @@ path('troca-senha/atualizada/', views_config['password_reset_complete'], name='password_reset_complete'), path('logout/', views_config['logout'], name='logout'), path('entrar/', CreateUserView.as_view(), name='sign_up'), + path('editar-perfil', login_required(ProfileUpdate.as_view()), name='profile_update_form') ) diff --git a/brasilio_auth/views.py b/brasilio_auth/views.py index 8157d9a2..b28d810a 100644 --- a/brasilio_auth/views.py +++ b/brasilio_auth/views.py @@ -2,6 +2,9 @@ from django.contrib.auth import get_user_model, login from django.views.generic.edit import CreateView from django.shortcuts import redirect +from django.views.generic.edit import UpdateView +from django.contrib.auth.models import User +from django.urls import reverse from brasilio_auth.forms import UserCreationForm @@ -24,3 +27,15 @@ def form_valid(self, *args, **kwargs): login(self.request, self.object) url = self.request.POST.get('next', None) or self.success_url return redirect(url) + + +class ProfileUpdate(UpdateView): + model = User + fields = ['first_name', 'last_name', 'username'] + template_name = 'brasilio_auth/profile_update_form.html' + + def get_object(self, queryset=None): + return self.request.user + + def get_success_url(self): + return reverse('brasilio_auth:profile_update_form') diff --git a/core/migrations/0015_auto_20181117_1827.py b/core/migrations/0015_auto_20181117_1827.py new file mode 100644 index 00000000..f4f57b3f --- /dev/null +++ b/core/migrations/0015_auto_20181117_1827.py @@ -0,0 +1,43 @@ +# Generated by Django 2.1.3 on 2018-11-17 18:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0014_auto_20180908_1902'), + ] + + operations = [ + migrations.AlterField( + model_name='field', + name='frontend_filter', + field=models.BooleanField(blank=True, default=False), + ), + migrations.AlterField( + model_name='field', + name='has_choices', + field=models.BooleanField(blank=True, default=False), + ), + migrations.AlterField( + model_name='field', + name='null', + field=models.BooleanField(blank=True, default=True), + ), + migrations.AlterField( + model_name='field', + name='obfuscate', + field=models.BooleanField(blank=True, default=False), + ), + migrations.AlterField( + model_name='field', + name='show', + field=models.BooleanField(blank=True, default=True), + ), + migrations.AlterField( + model_name='field', + name='show_on_frontend', + field=models.BooleanField(blank=True, default=False), + ), + ] diff --git a/core/templates/menu.html b/core/templates/menu.html index 7d79de40..0c65885c 100644 --- a/core/templates/menu.html +++ b/core/templates/menu.html @@ -4,6 +4,7 @@ arrow_drop_down