forked from fediversity/fediversity
		
	Add page showing account info
Co-authored-by: lois <lois@procolix.eu> Co-authored-by: Kiara Grouwstra <kiara.grouwstra@gmail.com>
This commit is contained in:
		
							parent
							
								
									d5632a795b
								
							
						
					
					
						commit
						ed4912800f
					
				
					 7 changed files with 37 additions and 3 deletions
				
			
		|  | @ -2,6 +2,7 @@ | |||
|   lib, | ||||
|   buildPythonPackage, | ||||
|   setuptools, | ||||
|   sqlite, | ||||
|   django_4, | ||||
|   django-compressor, | ||||
|   django-libsass, | ||||
|  | @ -46,6 +47,7 @@ buildPythonPackage { | |||
|     django-compressor | ||||
|     django-libsass | ||||
|     dj-database-url | ||||
|     sqlite | ||||
|   ]; | ||||
| 
 | ||||
|   postInstall = '' | ||||
|  |  | |||
|  | @ -119,6 +119,9 @@ AUTH_PASSWORD_VALIDATORS = [ | |||
|     }, | ||||
| ] | ||||
| 
 | ||||
| LOGIN_URL = 'login' | ||||
| LOGIN_REDIRECT_URL = '/'  # Redirect to homepage after login | ||||
| LOGOUT_REDIRECT_URL = '/'  # Redirect to homepage after logout | ||||
| 
 | ||||
| # Internationalization | ||||
| # https://docs.djangoproject.com/en/4.2/topics/i18n/ | ||||
|  |  | |||
							
								
								
									
										8
									
								
								panel/src/panel/templates/accountdetail.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								panel/src/panel/templates/accountdetail.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | |||
| {% extends "base.html" %} | ||||
| 
 | ||||
| {% block content %} | ||||
| <h1>{{ user.username }}</h1> | ||||
| <dl> | ||||
| <dt>e-mail</dt><dd>{{ user.email}}</dd> | ||||
| </dl> | ||||
| {% endblock %} | ||||
|  | @ -17,9 +17,9 @@ | |||
|   <body> | ||||
|     <header> | ||||
|     {% if user.is_authenticated %} | ||||
|       <p>Welcome, {{ user.username }}!</p> | ||||
|       <p>Welcome, {{ user.username }}! <a href="{% url 'logout' %}">Logout</a></p> | ||||
|     {% else %} | ||||
|       <p>You are not logged in.</p> | ||||
|       <p><a href="{% url 'login' %}">Login</a></p> | ||||
|     {% endif %} | ||||
|     </header> | ||||
|     {% block navigation %} | ||||
|  |  | |||
							
								
								
									
										10
									
								
								panel/src/panel/templates/registration/login.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								panel/src/panel/templates/registration/login.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | |||
| {% extends 'base.html' %} | ||||
| 
 | ||||
| {% block content %} | ||||
|   <h2>Login</h2> | ||||
|   <form method="post"> | ||||
|     {% csrf_token %} | ||||
|     {{ form.as_p }} | ||||
|     <button type="submit">Login</button> | ||||
|   </form> | ||||
| {% endblock %} | ||||
|  | @ -15,10 +15,12 @@ Including another URLconf | |||
|     2. Add a URL to urlpatterns:  path('blog/', include('blog.urls')) | ||||
| """ | ||||
| from django.contrib import admin | ||||
| from django.urls import path | ||||
| from django.urls import include, path | ||||
| from panel import views | ||||
| 
 | ||||
| urlpatterns = [ | ||||
|     path('admin/', admin.site.urls), | ||||
|     path('', views.Index.as_view(), name='index'), | ||||
|     path("", include("django.contrib.auth.urls")), | ||||
|     path("account/", views.AccountDetail.as_view(), name='accountdetail') | ||||
| ] | ||||
|  |  | |||
|  | @ -1,4 +1,13 @@ | |||
| from django.contrib.auth.mixins import LoginRequiredMixin | ||||
| from django.contrib.auth.models import User | ||||
| from django.views.generic import TemplateView | ||||
| from django.views.generic import DetailView | ||||
| 
 | ||||
| class Index(TemplateView): | ||||
|     template_name = 'index.html' | ||||
| 
 | ||||
| class AccountDetail(LoginRequiredMixin, DetailView): | ||||
|     model = User | ||||
|     template_name = 'accountdetail.html' | ||||
|     def get_object(self): | ||||
|         return self.request.user | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue