Skip to content

Commit

Permalink
Add profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
omerbselvi committed Aug 28, 2018
1 parent 963d4e8 commit f362fd0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
7 changes: 7 additions & 0 deletions deductivereasoning/accounts/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib.auth import login, authenticate
from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User


def signup(request):
Expand All @@ -17,5 +18,11 @@ def signup(request):
form = UserCreationForm()
return render(request, 'registration/signup.html', {'form': form})

def profile(request, username):
user = User.objects.get(username=username)
return render(request, 'accounts/profile.html', {
'user': user,
})

def dashboard(request):
return render(request, 'accounts/dashboard.html', {'title': 'Profile Page'})
1 change: 1 addition & 0 deletions deductivereasoning/deductivereasoning/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
path('accounts/signup/', account_views.signup, name='signup'),
path('accounts/profile/', account_views.dashboard, name='dashboard'),
path('about/', proof_views.about, name='about'),
path('accounts/profile/<slug:username>/', account_views.profile, name='profile')
]
24 changes: 24 additions & 0 deletions deductivereasoning/templates/accounts/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "base.html" %}

{% block title %}{{ title }}{% endblock %}

{% block content %}
<div class="box dashboard">
<h1 class="welcome">{{ user.username }}</h1>
{% if user.first_name and user.last_name %}
Name: {{ user.first_name }}
<br>
Surname: {{ user.last_name }}
<br>
{% endif %}
Username: {{ user.username }}
<br>
{% if user.email %}
User Email: {{ user.email }}
<br>
{% endif %}
Last Login: {{ user.last_login }}
<br>
Date Joined: {{ user.date_joined }}
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion deductivereasoning/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{ conclusion }}
</a>
</p>
<a href="{% url 'proposition_detail' conclusion.id %}">
<a href="{% url 'profile' conclusion.user.username %}">
<span class="createdBy">
<p>{{ conclusion.user }}</p>
<p>{{ conclusion.created_date }}</p>
Expand Down

0 comments on commit f362fd0

Please sign in to comment.