Kaydet (Commit) f8dce46b authored tarafından Batuhan Taşkaya's avatar Batuhan Taşkaya

Profiles

üst 5d9dc30a
......@@ -127,3 +127,4 @@ AUTH_USER_MODEL = 'social.SocialUser'
# Extra Settings
MAX_POST_LENGTH = 144 * 2
AVATAR = 'http://www.iconarchive.com/download/i106224/papirus-team/papirus-apps/python.ico'
# Generated by Django 2.2.1 on 2019-05-05 07:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('social', '0002_snippet'),
]
operations = [
migrations.AddField(
model_name='socialuser',
name='avatar',
field=models.URLField(blank=True, default='http://www.iconarchive.com/download/i106224/papirus-team/papirus-apps/python.ico'),
),
]
......@@ -3,7 +3,11 @@ from django.conf import settings
from django.contrib.auth.models import AbstractUser
class SocialUser(AbstractUser):
pass
avatar = models.URLField(blank=True, default=settings.AVATAR)
@property
def slug(self):
return self.username
class Sharable(models.Model):
class Meta:
......
{% extends 'base.html' %}
{% block title %}Profile{% endblock %}
{% block css %}
<style>
.container {
width: 100%;
height: 200px;
margin: auto;
padding: 10px;
}
.avatar {
width: 45%;
height: 200px;
float: left;
}
.content {
margin-left: 45%;
height: 200px;
}
</style>
{% endblock %}
{% block content %}
<section class="container">
<div class="avatar">
<img src="{{ object.avatar }}" alt="{{ object.username }}'s Avatar">
</div>
<div class="content">
<h3>{{ object.username }}</h3>
<ul>
<li>Mail: {{ object.email }}</li>
</ul>
</div>
</section>
{% endblock %}
......@@ -2,7 +2,7 @@ from collections import UserList
from dataclasses import dataclass
from typing import Optional, Sequence
from django.urls import include, path
from social.views import Home, Register
from social.views import Home, Register, Profile
@dataclass(frozen=True, unsafe_hash=True)
......@@ -84,8 +84,9 @@ class PatternManager:
class SocialPatterns(PatternManager, UserList):
home = "", Home
user = "people/<slug>/", Profile
register = "accounts/register/", Register
includes = {
"accounts": IncludeFilter(
"django.contrib.auth.urls", whitelist=("login", "logout")
......
......@@ -2,10 +2,10 @@ from itertools import chain
from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
from django.views.generic import CreateView, ListView
from django.views.generic import CreateView, ListView, DetailView
from django.views.generic.base import TemplateView
from social.models import Post, Snippet
from django.contrib.auth import get_user_model
class ExtendedListView(ListView):
def get_queryset(self):
......@@ -25,3 +25,8 @@ class Register(CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('login')
template_name = 'registration/register.html'
class Profile(DetailView):
model = get_user_model()
slug_field = 'username'
template_name = 'user/profile.html'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment