├── ablog
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-37.pyc
│ ├── settings.cpython-37.pyc
│ ├── urls.cpython-37.pyc
│ └── wsgi.cpython-37.pyc
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
├── db.sqlite3
├── manage.py
├── media
└── images
│ ├── dogs2.png
│ └── profile
│ └── Profile200x200.png
├── members
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-37.pyc
│ ├── admin.cpython-37.pyc
│ ├── forms.cpython-37.pyc
│ ├── models.cpython-37.pyc
│ ├── urls.cpython-37.pyc
│ └── views.cpython-37.pyc
├── admin.py
├── apps.py
├── forms.py
├── migrations
│ ├── __init__.py
│ └── __pycache__
│ │ └── __init__.cpython-37.pyc
├── models.py
├── templates
│ └── registration
│ │ ├── change-password.html
│ │ ├── create_user_profile_page.html
│ │ ├── edit_profile.html
│ │ ├── edit_profile_page.html
│ │ ├── login.html
│ │ ├── password_success.html
│ │ ├── register.html
│ │ └── user_profile.html
├── tests.py
├── urls.py
└── views.py
├── static
└── theblog
│ └── images
│ └── default_profile_pic.png
└── theblog
├── __init__.py
├── __pycache__
├── __init__.cpython-37.pyc
├── admin.cpython-37.pyc
├── forms.cpython-37.pyc
├── models.cpython-37.pyc
├── urls.cpython-37.pyc
└── views.cpython-37.pyc
├── admin.py
├── apps.py
├── forms.py
├── migrations
├── 0001_initial.py
├── 0002_post_title_tag.py
├── 0003_auto_20200417_0912.py
├── 0004_auto_20200427_0828.py
├── 0005_post_likes.py
├── 0006_auto_20200604_0823.py
├── 0007_post_snippet.py
├── 0008_auto_20200623_0832.py
├── 0009_profile.py
├── 0010_auto_20200630_0818.py
├── 0011_comment.py
├── 0012_profile_post.py
├── 0013_remove_profile_post.py
├── __init__.py
└── __pycache__
│ ├── 0001_initial.cpython-37.pyc
│ ├── 0002_post_title_tag.cpython-37.pyc
│ ├── 0003_auto_20200417_0912.cpython-37.pyc
│ ├── 0004_auto_20200427_0828.cpython-37.pyc
│ ├── 0005_post_likes.cpython-37.pyc
│ ├── 0006_auto_20200604_0811.cpython-37.pyc
│ ├── 0006_auto_20200604_0823.cpython-37.pyc
│ ├── 0007_post_snippet.cpython-37.pyc
│ ├── 0008_auto_20200623_0832.cpython-37.pyc
│ ├── 0009_profile.cpython-37.pyc
│ ├── 0010_auto_20200630_0818.cpython-37.pyc
│ ├── 0011_comment.cpython-37.pyc
│ ├── 0012_profile_post.cpython-37.pyc
│ ├── 0013_remove_profile_post.cpython-37.pyc
│ └── __init__.cpython-37.pyc
├── models.py
├── templates
├── add_category.html
├── add_comment.html
├── add_post.html
├── article_details.html
├── base.html
├── categories.html
├── category_list.html
├── delete_post.html
├── home.html
└── update_post.html
├── tests.py
├── urls.py
└── views.py
/ablog/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/ablog/__init__.py
--------------------------------------------------------------------------------
/ablog/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/ablog/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/ablog/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/ablog/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/ablog/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/ablog/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/ablog/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/ablog/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/ablog/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for ablog project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ablog.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/ablog/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for ablog project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.0.5.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.0/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.0/ref/settings/
11 | """
12 |
13 | import os
14 |
15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = '(o%y^j1ba$-p9@9ld5t(dmj4ersvf&@+^!a08xi$xse%exp@ar'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'django.contrib.admin',
35 | 'django.contrib.auth',
36 | 'django.contrib.contenttypes',
37 | 'django.contrib.sessions',
38 | 'django.contrib.messages',
39 | 'django.contrib.staticfiles',
40 | 'theblog',
41 | 'members',
42 | 'ckeditor',
43 | ]
44 |
45 | MIDDLEWARE = [
46 | 'django.middleware.security.SecurityMiddleware',
47 | 'django.contrib.sessions.middleware.SessionMiddleware',
48 | 'django.middleware.common.CommonMiddleware',
49 | 'django.middleware.csrf.CsrfViewMiddleware',
50 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
51 | 'django.contrib.messages.middleware.MessageMiddleware',
52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
53 | ]
54 |
55 | ROOT_URLCONF = 'ablog.urls'
56 |
57 | TEMPLATES = [
58 | {
59 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
60 | 'DIRS': [],
61 | 'APP_DIRS': True,
62 | 'OPTIONS': {
63 | 'context_processors': [
64 | 'django.template.context_processors.debug',
65 | 'django.template.context_processors.request',
66 | 'django.contrib.auth.context_processors.auth',
67 | 'django.contrib.messages.context_processors.messages',
68 | ],
69 | },
70 | },
71 | ]
72 |
73 | WSGI_APPLICATION = 'ablog.wsgi.application'
74 |
75 |
76 | # Database
77 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
78 |
79 | DATABASES = {
80 | 'default': {
81 | 'ENGINE': 'django.db.backends.sqlite3',
82 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
83 | }
84 | }
85 |
86 |
87 | # Password validation
88 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
89 |
90 | AUTH_PASSWORD_VALIDATORS = [
91 | {
92 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
93 | },
94 | {
95 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
96 | },
97 | {
98 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
99 | },
100 | {
101 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
102 | },
103 | ]
104 |
105 |
106 | # Internationalization
107 | # https://docs.djangoproject.com/en/3.0/topics/i18n/
108 |
109 | LANGUAGE_CODE = 'en-us'
110 |
111 | TIME_ZONE = 'UTC'
112 |
113 | USE_I18N = True
114 |
115 | USE_L10N = True
116 |
117 | USE_TZ = True
118 |
119 |
120 | # Static files (CSS, JavaScript, Images)
121 | # https://docs.djangoproject.com/en/3.0/howto/static-files/
122 |
123 | STATIC_URL = '/static/'
124 | MEDIA_URL = '/media/'
125 |
126 | STATICFILES_DIRS = [
127 | os.path.join(BASE_DIR, 'static')
128 | ]
129 |
130 |
131 |
132 | MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
133 |
134 | STATICFILES_DIRS = (
135 | os.path.join(BASE_DIR, 'static'),
136 | )
137 |
138 | LOGIN_REDIRECT_URL = 'home'
139 | LOGOUT_REDIRECT_URL = 'home'
--------------------------------------------------------------------------------
/ablog/urls.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.urls import path, include
3 |
4 | from django.conf import settings
5 | from django.conf.urls.static import static
6 |
7 |
8 | urlpatterns = [
9 | path('admin/', admin.site.urls),
10 | path('', include('theblog.urls')),
11 | path('members/', include('django.contrib.auth.urls')),
12 | path('members/', include('members.urls')),
13 |
14 | ]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
15 |
--------------------------------------------------------------------------------
/ablog/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for ablog project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ablog.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/db.sqlite3
--------------------------------------------------------------------------------
/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ablog.settings')
9 | try:
10 | from django.core.management import execute_from_command_line
11 | except ImportError as exc:
12 | raise ImportError(
13 | "Couldn't import Django. Are you sure it's installed and "
14 | "available on your PYTHONPATH environment variable? Did you "
15 | "forget to activate a virtual environment?"
16 | ) from exc
17 | execute_from_command_line(sys.argv)
18 |
19 |
20 | if __name__ == '__main__':
21 | main()
22 |
--------------------------------------------------------------------------------
/media/images/dogs2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/media/images/dogs2.png
--------------------------------------------------------------------------------
/media/images/profile/Profile200x200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/media/images/profile/Profile200x200.png
--------------------------------------------------------------------------------
/members/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/__init__.py
--------------------------------------------------------------------------------
/members/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/members/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/members/__pycache__/forms.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/__pycache__/forms.cpython-37.pyc
--------------------------------------------------------------------------------
/members/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/members/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/members/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/members/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/members/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class MembersConfig(AppConfig):
5 | name = 'members'
6 |
--------------------------------------------------------------------------------
/members/forms.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.forms import UserCreationForm, UserChangeForm, PasswordChangeForm
2 | from django.contrib.auth.models import User
3 | from django import forms
4 | from theblog.models import Profile
5 |
6 | class ProfilePageForm(forms.ModelForm):
7 | class Meta:
8 | model = Profile
9 | fields = ('bio', 'profile_pic', 'website_url', 'facebook_url', 'twitter_url', 'instagram_url', 'pinterest_url')
10 |
11 |
12 | widgets = {
13 | 'bio': forms.Textarea(attrs={'class': 'form-control'}),
14 | #'profil_pic': forms.TextInput(attrs={'class': 'form-control'}),
15 | 'website_url': forms.TextInput(attrs={'class': 'form-control', }),
16 | 'facebook_url': forms.TextInput(attrs={'class': 'form-control'}),
17 | 'twitter_url': forms.TextInput(attrs={'class': 'form-control'}),
18 | 'instagram_url': forms.TextInput(attrs={'class': 'form-control'}),
19 | 'pinterest_url': forms.TextInput(attrs={'class': 'form-control'}),
20 | }
21 |
22 |
23 | class SignUpForm(UserCreationForm):
24 | email = forms.EmailField(widget=forms.EmailInput(attrs={'class': 'form-control'}))
25 | first_name = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control'}))
26 | last_name = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control'}))
27 |
28 | class Meta:
29 | model = User
30 | fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2' )
31 |
32 |
33 | def __init__(self, *args, **kwargs):
34 | super(SignUpForm, self).__init__(*args, **kwargs)
35 |
36 | self.fields['username'].widget.attrs['class'] = 'form-control'
37 | self.fields['password1'].widget.attrs['class'] = 'form-control'
38 | self.fields['password2'].widget.attrs['class'] = 'form-control'
39 |
40 |
41 | class EditProfileForm(UserChangeForm):
42 | email = forms.EmailField(widget=forms.EmailInput(attrs={'class': 'form-control'}))
43 | first_name = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control'}))
44 | last_name = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control'}))
45 | username = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control'}))
46 | last_login = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control'}))
47 | is_superuser = forms.CharField(max_length=100, widget=forms.CheckboxInput(attrs={'class': 'form-check'}))
48 | is_staff = forms.CharField(max_length=100, widget=forms.CheckboxInput(attrs={'class': 'form-check'}))
49 | is_active = forms.CharField(max_length=100, widget=forms.CheckboxInput(attrs={'class': 'form-check'}))
50 | date_joined = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class': 'form-control'}))
51 |
52 | class Meta:
53 | model = User
54 | fields = ('username', 'first_name', 'last_name', 'email', 'password', 'last_login', 'is_superuser', 'is_staff', 'is_active', 'date_joined')
55 |
56 |
57 | class PasswordChangingForm(PasswordChangeForm):
58 | old_password = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control', 'type':'password'}))
59 | new_password1 = forms.CharField(max_length=100, widget=forms.PasswordInput(attrs={'class': 'form-control', 'type':'password'}))
60 | new_password2 = forms.CharField(max_length=100, widget=forms.PasswordInput(attrs={'class': 'form-control', 'type':'password'}))
61 |
62 | class Meta:
63 | model = User
64 | fields = ('old_password', 'new_password1', 'new_password2')
65 |
--------------------------------------------------------------------------------
/members/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/migrations/__init__.py
--------------------------------------------------------------------------------
/members/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/members/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/members/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/members/templates/registration/change-password.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Change Password{% endblock %}
3 | {% block content %}
4 |
5 |
6 |
7 |
Change Password...
8 |
9 |
10 |
26 |
27 |
28 |
29 |
30 |
31 | {% endblock %}
--------------------------------------------------------------------------------
/members/templates/registration/create_user_profile_page.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Create A New Profile Page{% endblock %}
3 | {% block content %}
4 |
5 |
6 | {% if user.is_authenticated %}
7 | Create Profile Page...
8 |
9 |
10 |
11 |
17 |
18 |
19 |
20 | {% else %}
21 |
22 | You're not allowed here! (and you know it...)
23 |
24 | {% endif %}
25 |
26 |
27 |
28 | {% endblock %}
--------------------------------------------------------------------------------
/members/templates/registration/edit_profile.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Edit Profile{% endblock %}
3 | {% block content %}
4 |
5 |
6 |
7 | Edit Settings...
8 |
9 |
10 | {{ user.profile.bio }}
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
23 |
24 |
25 |
26 | {% endblock %}
--------------------------------------------------------------------------------
/members/templates/registration/edit_profile_page.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Edit Profile Page{% endblock %}
3 | {% block content %}
4 |
5 |
6 | {% if user.is_authenticated %}
7 | {% if user.id == profile.user.id %}
8 | Edit Profile Page...
9 |
10 |
11 |
12 |
17 |
18 |
19 |
20 | {% else %}
21 |
22 | You are not the correct User To Edit This Page...
23 | {% endif %}
24 |
25 | {% else %}
26 |
27 | You're not allowed here! (and you know it...)
28 |
29 |
30 | {% endif %}
31 |
32 |
33 | {% endblock %}
--------------------------------------------------------------------------------
/members/templates/registration/login.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Login{% endblock %}
3 | {% block content %}
4 |
5 |
6 |
7 | Login...
8 |
9 |
10 |
27 |
28 |
29 |
30 | Not Registered? Sign Up Here...
31 |
32 |
33 |
34 |
35 | {% endblock %}
--------------------------------------------------------------------------------
/members/templates/registration/password_success.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Password Updated{% endblock %}
3 | {% block content %}
4 |
5 |
6 |
7 | Your Password Was Changed Successfully...
8 |
9 |
10 |
11 |
12 |
13 |
14 | {% endblock %}
--------------------------------------------------------------------------------
/members/templates/registration/register.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Register{% endblock %}
3 | {% block content %}
4 |
5 |
6 |
7 | Register...
8 |
9 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 | {% endblock %}
--------------------------------------------------------------------------------
/members/templates/registration/user_profile.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% load static %}
3 |
4 | {% block content %}
5 |
6 |
7 |
8 | User Profile...
9 |
10 |
11 |
12 |
13 |
14 |
15 | {% if page_user.profile_pic %}
16 |

17 |
18 | {% else %}
19 |

20 | {% endif %}
21 |
22 |
23 |
24 |
25 | {{ page_user.user.first_name }}
26 | {{ page_user.user.last_name }}
27 |
28 |
29 |
30 |
31 |
32 |
33 | {% if page_user.website_url %}
34 | Website
35 | {% endif %}
36 |
37 |
38 | {% if page_user.facebook_url %}
39 | | Facebook
40 | {% endif %}
41 |
42 |
43 | {% if page_user.twitter_url %}
44 | | Twitter
45 | {% endif %}
46 |
47 |
48 | {% if page_user.instagram_url %}
49 | | Instagram
50 | {% endif %}
51 |
52 |
53 | {% if page_user.pinterest_url %}
54 | | Pinterest
55 | {% endif %}
56 |
57 |
58 |
59 |
60 |
61 |
62 | {{ page_user.bio }}
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | {% endblock %}
--------------------------------------------------------------------------------
/members/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/members/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from .views import UserRegisterView, UserEditView, PasswordsChangeView, ShowProfilePageView, EditProfilePageView, CreateProfilePageView
3 | #from django.contrib.auth import views as auth_views
4 | from . import views
5 |
6 | urlpatterns = [
7 | path('register/', UserRegisterView.as_view(), name='register'),
8 | path('edit_profile/', UserEditView.as_view(), name='edit_profile'),
9 | #path('password/', auth_views.PasswordChangeView.as_view(template_name='registration/change-password.html')),
10 | path('password/', PasswordsChangeView.as_view(template_name='registration/change-password.html')),
11 | path('password_success', views.password_success, name="password_success"),
12 | path('/profile/', ShowProfilePageView.as_view(), name='show_profile_page'),
13 | path('/edit_profile_page/', EditProfilePageView.as_view(), name='edit_profile_page'),
14 | path('create_profile_page/', CreateProfilePageView.as_view(), name='create_profile_page'),
15 | ]
16 |
--------------------------------------------------------------------------------
/members/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render, get_object_or_404
2 | from django.views import generic
3 | from django.views.generic import DetailView, CreateView
4 | from django.contrib.auth.forms import UserCreationForm, UserChangeForm, PasswordChangeForm
5 | from django.contrib.auth.views import PasswordChangeView
6 | from django.urls import reverse_lazy
7 | from .forms import SignUpForm, EditProfileForm, PasswordChangingForm, ProfilePageForm
8 | from theblog.models import Profile
9 |
10 | class CreateProfilePageView(CreateView):
11 | model = Profile
12 | form_class = ProfilePageForm
13 | template_name = "registration/create_user_profile_page.html"
14 | #fields = '__all__'
15 |
16 | def form_valid(self, form):
17 | form.instance.user = self.request.user
18 | return super().form_valid(form)
19 |
20 | class EditProfilePageView(generic.UpdateView):
21 | model = Profile
22 | template_name = 'registration/edit_profile_page.html'
23 | fields = ['bio', 'profile_pic', 'website_url', 'facebook_url', 'twitter_url', 'instagram_url', 'pinterest_url']
24 | success_url = reverse_lazy('home')
25 |
26 | class ShowProfilePageView(DetailView):
27 | model = Profile
28 | template_name = 'registration/user_profile.html'
29 |
30 | def get_context_data(self, *args, **kwargs):
31 | #users = Profile.objects.all()
32 | context = super(ShowProfilePageView, self).get_context_data(*args, **kwargs)
33 |
34 | page_user = get_object_or_404(Profile, id=self.kwargs['pk'])
35 |
36 | context["page_user"] = page_user
37 | return context
38 |
39 | class PasswordsChangeView(PasswordChangeView):
40 | form_class = PasswordChangingForm
41 | #foom_class = PasswordChangeForm
42 | success_url = reverse_lazy('password_success')
43 | #success_url = reverse_lazy('home')
44 |
45 | def password_success(request):
46 | return render(request, 'registration/password_success.html', {})
47 |
48 | class UserRegisterView(generic.CreateView):
49 | form_class = SignUpForm
50 | template_name = 'registration/register.html'
51 | success_url = reverse_lazy('login')
52 |
53 | class UserEditView(generic.UpdateView):
54 | form_class = EditProfileForm
55 | template_name = 'registration/edit_profile.html'
56 | success_url = reverse_lazy('home')
57 |
58 | def get_object(self):
59 | return self.request.user
--------------------------------------------------------------------------------
/static/theblog/images/default_profile_pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/static/theblog/images/default_profile_pic.png
--------------------------------------------------------------------------------
/theblog/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/__init__.py
--------------------------------------------------------------------------------
/theblog/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/__pycache__/forms.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/__pycache__/forms.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import Post, Category, Profile, Comment
3 |
4 | admin.site.register(Post)
5 | admin.site.register(Category)
6 | admin.site.register(Profile)
7 | admin.site.register(Comment)
8 |
--------------------------------------------------------------------------------
/theblog/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TheblogConfig(AppConfig):
5 | name = 'theblog'
6 |
--------------------------------------------------------------------------------
/theblog/forms.py:
--------------------------------------------------------------------------------
1 | from django import forms
2 | from .models import Post, Category, Comment
3 |
4 | #choices = [('coding', 'coding'), ('sports', 'sports'), ('entertainment', 'entertainment'),]
5 | choices = Category.objects.all().values_list('name','name')
6 |
7 | choice_list = []
8 |
9 | for item in choices:
10 | choice_list.append(item)
11 |
12 |
13 | class PostForm(forms.ModelForm):
14 | class Meta:
15 | model = Post
16 | fields = ('title', 'title_tag', 'author', 'category', 'body', 'snippet', 'header_image')
17 |
18 | widgets = {
19 | 'title': forms.TextInput(attrs={'class': 'form-control'}),
20 | 'title_tag': forms.TextInput(attrs={'class': 'form-control'}),
21 | 'author': forms.TextInput(attrs={'class': 'form-control', 'value':'', 'id':'elder', 'type':'hidden'}),
22 | #'author': forms.Select(attrs={'class': 'form-control'}),
23 | 'category': forms.Select(choices=choice_list, attrs={'class': 'form-control'}),
24 | 'body': forms.Textarea(attrs={'class': 'form-control'}),
25 | 'snippet': forms.Textarea(attrs={'class': 'form-control'}),
26 | }
27 |
28 |
29 | class EditForm(forms.ModelForm):
30 | class Meta:
31 | model = Post
32 | fields = ('title', 'title_tag', 'body', 'snippet')
33 |
34 | widgets = {
35 | 'title': forms.TextInput(attrs={'class': 'form-control'}),
36 | 'title_tag': forms.TextInput(attrs={'class': 'form-control'}),
37 | #'author': forms.Select(attrs={'class': 'form-control'}),
38 | 'body': forms.Textarea(attrs={'class': 'form-control'}),
39 | 'snippet': forms.Textarea(attrs={'class': 'form-control'}),
40 | }
41 |
42 |
43 | class CommentForm(forms.ModelForm):
44 | class Meta:
45 | model = Comment
46 | fields = ('name', 'body')
47 |
48 | widgets = {
49 | 'name': forms.TextInput(attrs={'class': 'form-control'}),
50 | 'body': forms.Textarea(attrs={'class': 'form-control'}),
51 |
52 | }
--------------------------------------------------------------------------------
/theblog/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-04-02 16:43
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='Post',
19 | fields=[
20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21 | ('title', models.CharField(max_length=255)),
22 | ('body', models.TextField()),
23 | ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
24 | ],
25 | ),
26 | ]
27 |
--------------------------------------------------------------------------------
/theblog/migrations/0002_post_title_tag.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-04-06 15:50
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('theblog', '0001_initial'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='post',
15 | name='title_tag',
16 | field=models.CharField(default="My Freakin' Awesome Blog!", max_length=255),
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/theblog/migrations/0003_auto_20200417_0912.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-04-17 16:12
2 |
3 | from django.db import migrations, models
4 | import django.utils.timezone
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('theblog', '0002_post_title_tag'),
11 | ]
12 |
13 | operations = [
14 | migrations.AddField(
15 | model_name='post',
16 | name='post_date',
17 | field=models.DateField(auto_now_add=True, default=django.utils.timezone.now),
18 | preserve_default=False,
19 | ),
20 | migrations.AlterField(
21 | model_name='post',
22 | name='title_tag',
23 | field=models.CharField(max_length=255),
24 | ),
25 | ]
26 |
--------------------------------------------------------------------------------
/theblog/migrations/0004_auto_20200427_0828.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-04-27 15:28
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('theblog', '0003_auto_20200417_0912'),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name='Category',
15 | fields=[
16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17 | ('name', models.CharField(max_length=255)),
18 | ],
19 | ),
20 | migrations.AddField(
21 | model_name='post',
22 | name='category',
23 | field=models.CharField(default='coding', max_length=255),
24 | ),
25 | ]
26 |
--------------------------------------------------------------------------------
/theblog/migrations/0005_post_likes.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-05-13 17:12
2 |
3 | from django.conf import settings
4 | from django.db import migrations, models
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
11 | ('theblog', '0004_auto_20200427_0828'),
12 | ]
13 |
14 | operations = [
15 | migrations.AddField(
16 | model_name='post',
17 | name='likes',
18 | field=models.ManyToManyField(related_name='blog_posts', to=settings.AUTH_USER_MODEL),
19 | ),
20 | ]
21 |
--------------------------------------------------------------------------------
/theblog/migrations/0006_auto_20200604_0823.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-06-04 15:23
2 |
3 | import ckeditor.fields
4 | from django.db import migrations
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('theblog', '0005_post_likes'),
11 | ]
12 |
13 | operations = [
14 | migrations.AlterField(
15 | model_name='post',
16 | name='body',
17 | field=ckeditor.fields.RichTextField(blank=True, null=True),
18 | ),
19 | ]
20 |
--------------------------------------------------------------------------------
/theblog/migrations/0007_post_snippet.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-06-09 14:45
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('theblog', '0006_auto_20200604_0823'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='post',
15 | name='snippet',
16 | field=models.CharField(default='Click Link Above To Read Blog Post...', max_length=255),
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/theblog/migrations/0008_auto_20200623_0832.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-06-23 15:32
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('theblog', '0007_post_snippet'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='post',
15 | name='header_image',
16 | field=models.ImageField(blank=True, null=True, upload_to='images/'),
17 | ),
18 | migrations.AlterField(
19 | model_name='post',
20 | name='snippet',
21 | field=models.CharField(max_length=255),
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/theblog/migrations/0009_profile.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-06-25 15:42
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 | dependencies = [
11 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12 | ('theblog', '0008_auto_20200623_0832'),
13 | ]
14 |
15 | operations = [
16 | migrations.CreateModel(
17 | name='Profile',
18 | fields=[
19 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20 | ('bio', models.TextField()),
21 | ('user', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
22 | ],
23 | ),
24 | ]
25 |
--------------------------------------------------------------------------------
/theblog/migrations/0010_auto_20200630_0818.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-06-30 15:18
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('theblog', '0009_profile'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='profile',
15 | name='facebook_url',
16 | field=models.CharField(blank=True, max_length=255, null=True),
17 | ),
18 | migrations.AddField(
19 | model_name='profile',
20 | name='instagram_url',
21 | field=models.CharField(blank=True, max_length=255, null=True),
22 | ),
23 | migrations.AddField(
24 | model_name='profile',
25 | name='pinterest_url',
26 | field=models.CharField(blank=True, max_length=255, null=True),
27 | ),
28 | migrations.AddField(
29 | model_name='profile',
30 | name='profile_pic',
31 | field=models.ImageField(blank=True, null=True, upload_to='images/profile/'),
32 | ),
33 | migrations.AddField(
34 | model_name='profile',
35 | name='twitter_url',
36 | field=models.CharField(blank=True, max_length=255, null=True),
37 | ),
38 | migrations.AddField(
39 | model_name='profile',
40 | name='website_url',
41 | field=models.CharField(blank=True, max_length=255, null=True),
42 | ),
43 | ]
44 |
--------------------------------------------------------------------------------
/theblog/migrations/0011_comment.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-07-16 15:34
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('theblog', '0010_auto_20200630_0818'),
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Comment',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('name', models.CharField(max_length=255)),
19 | ('body', models.TextField()),
20 | ('date_added', models.DateTimeField(auto_now_add=True)),
21 | ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='theblog.Post')),
22 | ],
23 | ),
24 | ]
25 |
--------------------------------------------------------------------------------
/theblog/migrations/0012_profile_post.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-08-04 14:59
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('theblog', '0011_comment'),
11 | ]
12 |
13 | operations = [
14 | migrations.AddField(
15 | model_name='profile',
16 | name='post',
17 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='theblog.Post'),
18 | ),
19 | ]
20 |
--------------------------------------------------------------------------------
/theblog/migrations/0013_remove_profile_post.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.5 on 2020-08-04 15:03
2 |
3 | from django.db import migrations
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('theblog', '0012_profile_post'),
10 | ]
11 |
12 | operations = [
13 | migrations.RemoveField(
14 | model_name='profile',
15 | name='post',
16 | ),
17 | ]
18 |
--------------------------------------------------------------------------------
/theblog/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__init__.py
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0002_post_title_tag.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0002_post_title_tag.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0003_auto_20200417_0912.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0003_auto_20200417_0912.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0004_auto_20200427_0828.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0004_auto_20200427_0828.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0005_post_likes.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0005_post_likes.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0006_auto_20200604_0811.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0006_auto_20200604_0811.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0006_auto_20200604_0823.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0006_auto_20200604_0823.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0007_post_snippet.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0007_post_snippet.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0008_auto_20200623_0832.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0008_auto_20200623_0832.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0009_profile.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0009_profile.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0010_auto_20200630_0818.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0010_auto_20200630_0818.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0011_comment.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0011_comment.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0012_profile_post.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0012_profile_post.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/0013_remove_profile_post.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/0013_remove_profile_post.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flatplanet/djangoblog/fcf2ec53f64fb84eb829febf709a7af4f279531c/theblog/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/theblog/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import User
3 | from django.urls import reverse
4 | from datetime import datetime, date
5 | from ckeditor.fields import RichTextField
6 |
7 | class Category(models.Model):
8 | name = models.CharField(max_length=255)
9 |
10 | def __str__(self):
11 | return self.name
12 |
13 | def get_absolute_url(self):
14 | #return reverse('article-detail', args=(str(self.id)) )
15 | return reverse('home')
16 |
17 |
18 | class Post(models.Model):
19 | title = models.CharField(max_length=255)
20 | header_image = models.ImageField(null=True, blank=True, upload_to="images/")
21 | title_tag = models.CharField(max_length=255)
22 | author = models.ForeignKey(User, on_delete=models.CASCADE)
23 | body = RichTextField(blank=True, null=True)
24 | #body = models.TextField()
25 | post_date = models.DateField(auto_now_add=True)
26 | category = models.CharField(max_length=255, default='coding')
27 | snippet = models.CharField(max_length=255)
28 | likes = models.ManyToManyField(User, related_name='blog_posts')
29 |
30 | def total_likes(self):
31 | return self.likes.count()
32 |
33 | def __str__(self):
34 | return self.title + ' | ' + str(self.author)
35 |
36 | def get_absolute_url(self):
37 | #return reverse('article-detail', args=(str(self.id)) )
38 | return reverse('home')
39 |
40 | class Profile(models.Model):
41 | user = models.OneToOneField(User, null=True, on_delete=models.CASCADE)
42 | bio = models.TextField()
43 | profile_pic = models.ImageField(null=True, blank=True, upload_to="images/profile/")
44 | website_url = models.CharField(max_length=255, null=True, blank=True)
45 | facebook_url = models.CharField(max_length=255, null=True, blank=True)
46 | twitter_url = models.CharField(max_length=255, null=True, blank=True)
47 | instagram_url = models.CharField(max_length=255, null=True, blank=True)
48 | pinterest_url = models.CharField(max_length=255, null=True, blank=True)
49 |
50 |
51 | def __str__(self):
52 | return str(self.user)
53 |
54 | def get_absolute_url(self):
55 | return reverse('home')
56 |
57 |
58 |
59 | class Comment(models.Model):
60 | post = models.ForeignKey(Post, related_name="comments", on_delete=models.CASCADE)
61 | name = models.CharField(max_length=255)
62 | body = models.TextField()
63 | date_added = models.DateTimeField(auto_now_add=True)
64 |
65 | def __str__(self):
66 | return '%s - %s' % (self.post.title, self.name)
67 |
--------------------------------------------------------------------------------
/theblog/templates/add_category.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Create A New Blog Category!{% endblock %}
3 | {% block content %}
4 |
5 |
6 | {% if user.is_authenticated %}
7 | Add Category...
8 |
9 |
10 |
11 |
16 |
17 | {% else %}
18 |
19 | You're not allowed here! (and you know it...)
20 |
21 | {% endif %}
22 |
23 |
24 |
25 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/templates/add_comment.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Comment On Blog Post{% endblock %}
3 | {% block content %}
4 |
5 |
6 |
7 | Add Comment...
8 |
9 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/templates/add_post.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Create A New Blog Post!{% endblock %}
3 | {% block content %}
4 |
5 |
6 | {% if user.is_authenticated %}
7 | Add Post...
8 |
9 |
10 |
11 |
17 |
18 |
24 |
25 | {% else %}
26 |
27 | You're not allowed here! (and you know it...)
28 |
29 | {% endif %}
30 |
31 |
32 |
33 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/templates/article_details.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% load static %}
3 |
4 | {% block title %}{{ post.title_tag }}{% endblock %}
5 |
6 |
7 |
8 | {% block content %}
9 |
10 | {{ post.title }}
11 | By:
12 | {{ post.author.first_name }}
13 | {{ post.author.last_name }} -
14 | {{ post.post_date }}
15 |
16 | {% if user.is_authenticated %}
17 | {% if user.id == post.author.id %}
18 | - (Edit)
19 |
20 | (Delete)
21 | {% endif %}
22 | {% endif %}
23 |
24 |
25 |
26 |
27 | {% if post.header_image %}
28 |
29 | {% endif %}
30 |
31 |
32 | {{ post.body|safe }}
33 |
34 |
35 |
36 |
37 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | {% if post.author.profile.profile_pic %}
62 |

63 |
64 | {% else %}
65 |

66 | {% endif %}
67 |
68 |
69 |
70 |
71 | {{ post.author.first_name }}
72 | {{ post.author.last_name }}
73 |
74 |
75 |
76 |
77 | Profile Page
78 |
79 | {% if post.author.profile.website_url %}
80 | | Website
81 | {% endif %}
82 |
83 |
84 | {% if post.author.profile.facebook_url %}
85 | | Facebook
86 | {% endif %}
87 |
88 |
89 | {% if post.author.profile.twitter_url %}
90 | | Twitter
91 | {% endif %}
92 |
93 |
94 | {% if post.author.profile.instagram_url %}
95 | | Instagram
96 | {% endif %}
97 |
98 |
99 | {% if post.author.profile.pinterest_url %}
100 | | Pinterest
101 | {% endif %}
102 |
103 |
104 |
105 |
106 |
107 |
108 | {{ post.author.profile.bio }}
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 | Comments...
120 |
121 | {% if not post.comments.all %}
122 | No Comments Yet...Add One
123 | {% else %}
124 |
125 | Add Comment
126 |
127 |
128 | {% for comment in post.comments.all %}
129 |
130 | {{ comment.name }} -
131 | {{ comment.date_added }}
132 |
133 |
134 | {{ comment.body }}
135 |
136 |
137 |
138 | {% endfor %}
139 | Add Comment
140 | {% endif %}
141 |
142 |
143 |
144 |
145 |
146 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/templates/base.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {% block title %}
14 | My Freakin' Awesome Blog!
15 | {% endblock %}
16 |
17 |
18 |
19 |
123 |
124 |
125 |
126 |
127 |
128 | {% block content %}
129 |
130 | {% endblock %}
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/theblog/templates/categories.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block content %}
4 |
5 | {% if category_posts %}
6 |
7 | {{ cats }}
8 |
9 |
10 | {% for post in category_posts %}
11 | - {{ post.title }}
12 |
13 |
14 | - {{ post.author.first_name }} {{ post.author.last_name }} -
15 | {{ post.post_date }}
16 |
17 | {% if user.is_authenticated %}
18 | - (Edit)
19 |
20 | (Delete)
21 | {% endif %}
22 |
23 |
24 | {{ post.body|slice:":200"|safe }}
25 | {% endfor %}
26 |
27 |
28 | {% else %}
29 | Sorry this page does not exist...
30 | {% endif %}
31 |
32 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/templates/category_list.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Blog Categories{% endblock %}
3 |
4 |
5 |
6 | {% block content %}
7 |
8 | Blog Categories
9 |
10 | {% for item in cat_menu_list %}
11 |
12 |
13 | {% endfor %}
14 |
15 |
16 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/templates/delete_post.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Delete Blog Post{% endblock %}
3 | {% block content %}
4 |
5 |
6 | {% if user.is_authenticated %}
7 | {% if user.id == post.author.id %}
8 | Delete Post...
9 |
10 | Delete: {{ post.title }}
11 |
12 |
13 |
14 |
19 | {% else %}
20 | You're not allowed here! (and you know it...)
21 | {% endif %}
22 |
23 | {% else %}
24 |
25 | You're not allowed here! (and you know it...)
26 |
27 | {% endif %}
28 |
29 |
30 |
31 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/templates/home.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block content %}
4 |
5 |
6 |
7 | Posts
8 |
9 |
10 | {% for post in object_list %}
11 | - {{ post.title }}
12 |
13 | - {{ post.category }}
14 | - {{ post.author.first_name }} {{ post.author.last_name }} -
15 | {{ post.post_date }}
16 |
17 | {% if user.is_authenticated %}
18 | {% if user.id == post.author.id %}
19 | - (Edit)
20 |
21 | (Delete)
22 | {% endif %}
23 | {% endif %}
24 |
25 |
26 | {{ post.snippet }}
27 | {% endfor %}
28 |
29 |
30 |
31 |
32 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/templates/update_post.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 | {% block title %}Edit Blog Post{% endblock %}
3 | {% block content %}
4 |
5 |
6 | {% if user.is_authenticated %}
7 | {% if user.id == post.author.id %}
8 |
9 | Update Post...
10 |
11 |
12 |
13 |
19 | {% else %}
20 | You're not allowed here! (and you know it...)
21 | {% endif %}
22 | {% else %}
23 |
24 | You're not allowed here! (and you know it...)
25 |
26 | {% endif %}
27 |
28 |
29 |
30 |
31 | {% endblock %}
--------------------------------------------------------------------------------
/theblog/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/theblog/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | #from . import views
3 | from .views import HomeView, ArticleDetailView, AddPostView, UpdatePostView, DeletePostView, AddCategoryView, CategoryView, CategoryListView, LikeView, AddCommentView
4 |
5 | urlpatterns = [
6 | #path('', views.home, name="home"),
7 | path('', HomeView.as_view(), name="home"),
8 | path('article/', ArticleDetailView.as_view(), name='article-detail'),
9 | path('add_post/', AddPostView.as_view(), name='add_post'),
10 | path('add_category/', AddCategoryView.as_view(), name='add_category'),
11 | path('article/edit/', UpdatePostView.as_view(), name='update_post'),
12 | path('article//remove', DeletePostView.as_view(), name='delete_post'),
13 | path('category//', CategoryView, name='category'),
14 | path('category-list/', CategoryListView, name='category-list'),
15 | path('like/', LikeView, name='like_post'),
16 | path('article//comment/', AddCommentView.as_view(), name='add_comment'),
17 | ]
18 |
--------------------------------------------------------------------------------
/theblog/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render, get_object_or_404
2 | from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView
3 | from .models import Post, Category, Comment
4 | from .forms import PostForm, EditForm, CommentForm
5 | from django.urls import reverse_lazy, reverse
6 | from django.http import HttpResponseRedirect
7 | #def home(request):
8 | # return render(request, 'home.html', {})
9 |
10 | def LikeView(request, pk):
11 | post = get_object_or_404(Post, id=request.POST.get('post_id'))
12 | liked = False
13 | if post.likes.filter(id=request.user.id).exists():
14 | post.likes.remove(request.user)
15 | liked = False
16 | else:
17 | post.likes.add(request.user)
18 | liked = True
19 |
20 | return HttpResponseRedirect(reverse('article-detail', args=[str(pk)]))
21 |
22 | class HomeView(ListView):
23 | model = Post
24 | template_name = 'home.html'
25 | cats = Category.objects.all()
26 | ordering = ['-post_date']
27 | #ordering = ['-id']
28 |
29 | def get_context_data(self, *args, **kwargs):
30 | cat_menu = Category.objects.all()
31 | context = super(HomeView, self).get_context_data(*args, **kwargs)
32 | context["cat_menu"] = cat_menu
33 | return context
34 |
35 | def CategoryListView(request):
36 | cat_menu_list = Category.objects.all()
37 | return render(request, 'category_list.html', {'cat_menu_list':cat_menu_list})
38 |
39 |
40 |
41 | def CategoryView(request, cats):
42 | category_posts = Post.objects.filter(category=cats.replace('-', ' '))
43 | return render(request, 'categories.html', {'cats':cats.replace('-', ' ').title(), 'category_posts':category_posts})
44 |
45 |
46 | class ArticleDetailView(DetailView):
47 | model = Post
48 | template_name = 'article_details.html'
49 |
50 | def get_context_data(self, *args, **kwargs):
51 | cat_menu = Category.objects.all()
52 | context = super(ArticleDetailView, self).get_context_data(*args, **kwargs)
53 |
54 | stuff = get_object_or_404(Post, id=self.kwargs['pk'])
55 | total_likes = stuff.total_likes()
56 |
57 | liked = False
58 | if stuff.likes.filter(id=self.request.user.id).exists():
59 | liked = True
60 |
61 | context["cat_menu"] = cat_menu
62 | context["total_likes"] = total_likes
63 | context["liked"] = liked
64 | return context
65 |
66 | class AddPostView(CreateView):
67 | model = Post
68 | form_class = PostForm
69 | template_name = 'add_post.html'
70 | #fields = '__all__'
71 | #fields = ('title', 'body')
72 |
73 | class AddCommentView(CreateView):
74 | model = Comment
75 | form_class = CommentForm
76 | template_name = 'add_comment.html'
77 | #fields = '__all__'
78 | def form_valid(self, form):
79 | form.instance.post_id = self.kwargs['pk']
80 | return super().form_valid(form)
81 |
82 | success_url = reverse_lazy('home')
83 |
84 | class AddCategoryView(CreateView):
85 | model = Category
86 | #form_class = PostForm
87 | template_name = 'add_category.html'
88 | fields = '__all__'
89 | #fields = ('title', 'body')
90 |
91 | class UpdatePostView(UpdateView):
92 | model = Post
93 | form_class = EditForm
94 | template_name = 'update_post.html'
95 | #fields = ['title', 'title_tag', 'body']
96 |
97 | class DeletePostView(DeleteView):
98 | model = Post
99 | template_name = 'delete_post.html'
100 | success_url = reverse_lazy('home')
--------------------------------------------------------------------------------