10000 close #23 and added account app · moktadirul-raju/DjangoBlog@50df6a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 50df6a2

Browse files
committed
close #23 and added account app
1 parent 7c48441 commit 50df6a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+229
-54
lines changed

accounts/__init__.py

Whitespace-only changes.
160 Bytes
Binary file not shown.
282 Bytes
Binary file not shown.
746 Bytes
Binary file not shown.

accounts/admin.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.contrib import admin
2+
from .models import UserProfileInfo
3+
4+
# Register your models here.
5+
admin.site.register(UserProfileInfo)

accounts/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AccountsConfig(AppConfig):
5+
name = 'accounts'

accounts/migrations/0001_initial.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 2.1.4 on 2019-02-20 03:21
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name='UserProfileInfo',
19+
fields=[
20+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21+
('portfolio', models.URLField(blank=True)),
22+
('profile_pic', models.ImageField(blank=True, upload_to='profile_pics')),
23+
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
24+
],
25+
),
26+
]

accounts/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

accounts/models.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.db import models
2+
from django.contrib.auth.models import User
3+
4+
# Create your models here.
5+
class UserProfileInfo(models.Model):
6+
user = models.OneToOneField(User,on_delete=models.CASCADE)
7+
8+
#Additional
9+
portfolio = models.URLField(blank=True)
10+
profile_pic = models.ImageField(upload_to='profile_pics', blank=True)
11+
12+
def __str__(self):
13+
return self.user.username

accounts/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

accounts/views.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.
58 Bytes
Binary file not shown.

backend/views.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from django.shortcuts import render, redirect
22
from django.http import HttpResponse
3-
from blog.models import Post, Comment, Reply, UserProfileInfo,Tag,Category
3+
from blog.models import Post,Tag,Category
4+
from accounts.models import UserProfileInfo
5+
from comments.models import Comment,Reply
46
from .models import BlogSettings
57
from blog.forms import UserForm,UserProfileInfoForm, PostForm
68
from django.core.paginator import Paginator

blog/__pycache__/admin.cpython-37.pyc

-102 Bytes
Binary file not shown.
Binary file not shown.

blog/__pycache__/forms.cpython-37.pyc

4 Bytes
Binary file not shown.
-1.8 KB
Binary file not shown.

blog/__pycache__/views.cpython-37.pyc

58 Bytes
Binary file not shown.

blog/admin.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
from django.contrib import admin
22

3-
from blog.models import Post, Comment,Reply, UserProfileInfo,Tag,Category
3+
from blog.models import Post,Tag,Category
44
# Register your models here.
55

66
admin.site.register(Post)
7-
admin.site.register(Comment)
8-
admin.site.register(UserProfileInfo)
9-
admin.site.register(Reply)
107
admin.site.register(Tag)
118
admin.site.register(Category)

blog/context_processors.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from blog.models import Post, UserProfileInfo,Tag,Category
1+
from blog.models import Post,Tag,Category
2+
from accounts.models import UserProfileInfo
23
from backend.models import BlogSettings
34
from django.contrib.auth.models import User
45
from django.contrib.auth.decorators import login_required

blog/forms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django import forms
22
from django.core import validators
33
from django.contrib.auth.models import User
4-
from blog.models import UserProfileInfo
4+
from accounts.models import UserProfileInfo
55

66
class UserForm(forms.ModelForm):
77
password = forms.CharField(widget=forms.PasswordInput())
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Generated by Django 2.1.4 on 2019-02-20 03:21
2+
3+
import datetime
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('blog', '0018_auto_20190217_1146'),
11+
]
12+
13+
operations = [
14+
migrations.RemoveField(
15+
model_name='comment',
16+
name='author',
17+
),
18+
migrations.RemoveField(
19+
model_name='comment',
20+
name='post',
21+
),
22+
migrations.RemoveField(
23+
model_name='reply',
24+
name='author',
25+
),
26+
migrations.RemoveField(
27+
model_name='reply',
28+
name='comment',
29+
),
30+
migrations.RemoveField(
31+
model_name='userprofileinfo',
32+
name='user',
33+
),
34+
migrations.AlterField(
35+
model_name='post',
36+
name='created_date',
37+
field=models.DateTimeField(default=datetime.datetime(2019, 2, 20, 3, 21, 13, 388329)),
38+
),
39+
migrations.DeleteModel(
40+
name='Comment',
41+
),
42+
migrations.DeleteModel(
43+
name='Reply',
44+
),
45+
migrations.DeleteModel(
46+
name='UserProfileInfo',
47+
),
48+
]
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 2.1.4 on 2019-02-20 03:22
2+
3+
import datetime
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('blog', '0019_auto_20190220_0321'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='post',
16+
name='created_date',
17+
field=models.DateTimeField(default=datetime.datetime(2019, 2, 20, 3, 22, 11, 593247)),
18+
),
19+
]
Binary file not shown.
Binary file not shown.

blog/models.py

-46
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@
33
from datetime import datetime
44

55
# Create your models here.
6-
class UserProfileInfo(models.Model):
7-
user = models.OneToOneField(User,on_delete=models.CASCADE)
8-
9-
#Additional
10-
portfolio = models.URLField(blank=True)
11-
profile_pic = models.ImageField(upload_to='profile_pics', blank=True)
12-
13-
def __str__(self):
14-
return self.user.username
15-
16-
176

187
class Category(models.Model):
198
text = models.CharField(max_length=100, unique=True)
@@ -56,38 +45,3 @@ def get_absolute_url(self):
5645

5746
def __str__(self):
5847
return self.title
59-
60-
61-
62-
class Comment(models.Model):
63-
post = models.ForeignKey(Post,on_delete=models.CASCADE, default=1, related_name='comments')
64-
content = models.CharField(max_length=1000, blank=True)
65-
author = models.ForeignKey(UserProfileInfo,on_delete=models.CASCADE,default=1)
66-
created_date = models.DateTimeField(default=datetime.now())
67-
published_date = models.DateTimeField(null=True, blank=True)
68-
is_approved = models.BooleanField(default=False)
69-
70-
71-
def approve(self):
72-
self.is_approved = True
73-
self.save()
74-
75-
def move_to_trash(self):
76-
self.delete()
77-
78-
def get_absolute_url(self):
79-
return reverse('blog:post_details', args=(post_id, ))
80-
81-
def __str__(self):
82-
return self.content
83-
84-
85-
86-
class Reply(models.Model):
87-
comment = models.ForeignKey(Comment,on_delete=models.CASCADE, default=10, related_name='replies')
88-
content = models.CharField(max_length=1000, blank=True)
89-
author = models.ForeignKey(UserProfileInfo,on_delete=models.CASCADE,default=1)
90-
published_date = models.DateTimeField(default=datetime.now(), blank=True)
91-
92-
def __str__(self):
93-
return self.title

blog/views.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from django.shortcuts import render, redirect
22
from django.http import HttpResponse
3-
from blog.models import Post, Comment, Reply, UserProfileInfo,Tag,Category
3+
from blog.models import Post,Tag,Category
4+
from accounts.models import UserProfileInfo
5+
from comments.models import Comment,Reply
46
from blog.forms import UserForm,UserProfileInfoForm, PostForm
57
from . import forms
68
from django.core.paginator import Paginator
28 Bytes
Binary file not shown.

blog_engine/settings.py

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
'django.contrib.staticfiles',
4343
'blog',
4444
'backend',
45+
'accounts',
46+
'comments',
4547

4648
]
4749

comments/__init__.py

Whitespace-only changes.
160 Bytes
Binary file not shown.
304 Bytes
Binary file not shown.
1.9 KB
Binary file not shown.

comments/admin.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.contrib import admin
2+
from .models import Comment,Reply
3+
# Register your models here.
4+
admin.site.register(Comment)
5+
admin.site.register(Reply)

comments/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class CommentsConfig(AppConfig):
5+
name = 'comments'

comments/migrations/0001_initial.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Generated by Django 2.1.4 on 2019-02-20 03:22
2+
3+
import datetime
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
('accounts', '0001_initial'),
14+
('blog', '0020_auto_20190220_0322'),
15+
]
16+
17+
operations = [
18+
migrations.CreateModel(
19+
name='Comment',
20+
fields=[
21+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
22+
('content', models.CharField(blank=True, max_length=1000)),
23+
('created_date', models.DateTimeField(default=datetime.datetime(2019, 2, 20, 3, 22, 11, 596225))),
24+
('published_date', models.DateTimeField(blank=True, null=True)),
25+
('is_approved', models.BooleanField(default=False)),
26+
('author', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='accounts.UserProfileInfo')),
27+
('post', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='blog.Post')),
28+
],
29+
),
30+
migrations.CreateModel(
31+
name='Reply',
32+
fields=[
33+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
34+
('content', models.CharField(blank=True, max_length=1000)),
35+
('published_date', models.DateTimeField(blank=True, default=datetime.datetime(2019, 2, 20, 3, 22, 11, 596629))),
36+
('author', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='accounts.UserProfileInfo')),
37+
('comment', models.ForeignKey(default=10, on_delete=django.db.models.deletion.CASCADE, related_name='replies', to='comments.Comment')),
38+
],
39+
),
40+
]

comments/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

comments/models.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from django.db import models
2+
from django.contrib.auth.models import User
3+
from datetime import datetime
4+
from blog.models import Post
5+
from accounts.models import UserProfileInfo
6+
7+
# Create your models here.
8+
class Comment(models.Model):
9+
post = models.ForeignKey(Post,on_delete=models.CASCADE, default=1, related_name='comments')
10+
content = models.CharField(max_length=1000, blank=True)
11+
author = models.ForeignKey(UserProfileInfo,on_delete=models.CASCADE,default=1)
12+
created_date = models.DateTimeField(default=datetime.now())
13+
published_date = models.DateTimeField(null=True, blank=True)
14+
is_approved = models.BooleanField(default=False)
15+
16+
17+
def approve(self):
18+
self.is_approved = True
19+
self.save()
20+
21+
def move_to_trash(self):
22+
self.delete()
23+
24+
def get_absolute_url(self):
25+
return reverse('blog:post_details', args=(post_id, ))
26+
27+
def __str__(self):
28+
return self.content
29+
30+
31+
32+
class Reply(models.Model):
33+
comment = models.ForeignKey(Comment,on_delete=models.CASCADE, default=10, related_name='replies')
34+
content = models.CharField(max_length=1000, blank=True)
35+
author = models.ForeignKey(UserProfileInfo,on_delete=models.CASCADE,default=1)
36+
published_date = models.DateTimeField(default=datetime.now(), blank=True)
37+
38+
def __str__(self):
39+
return self.title

comments/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

comments/views.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

db.sqlite3

0 Bytes
Binary file not shown.
63 KB

0 commit comments

Comments
 (0)
0