From b289f125e2566ce5ebbacf8a2962410634884803 Mon Sep 17 00:00:00 2001 From: Fatma Al Rashdi Date: Fri, 11 Nov 2022 11:23:34 +0100 Subject: [PATCH 01/19] pushing new branch --- .idea/.gitignore | 3 + .idea/coolpress.iml | 14 ++ .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 7 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + coolpress/coolpress/__init__.py | 0 coolpress/coolpress/asgi.py | 16 +++ coolpress/coolpress/settings.py | 126 ++++++++++++++++++ coolpress/coolpress/urls.py | 21 +++ coolpress/coolpress/wsgi.py | 16 +++ coolpress/manage.py | 22 +++ coolpress/press/__init__.py | 0 coolpress/press/admin.py | 3 + coolpress/press/apps.py | 6 + coolpress/press/migrations/0001_initial.py | 22 +++ coolpress/press/migrations/__init__.py | 0 coolpress/press/models.py | 9 ++ coolpress/press/tests.py | 3 + coolpress/press/views.py | 3 + 20 files changed, 291 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/coolpress.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 coolpress/coolpress/__init__.py create mode 100644 coolpress/coolpress/asgi.py create mode 100644 coolpress/coolpress/settings.py create mode 100644 coolpress/coolpress/urls.py create mode 100644 coolpress/coolpress/wsgi.py create mode 100644 coolpress/manage.py create mode 100644 coolpress/press/__init__.py create mode 100644 coolpress/press/admin.py create mode 100644 coolpress/press/apps.py create mode 100644 coolpress/press/migrations/0001_initial.py create mode 100644 coolpress/press/migrations/__init__.py create mode 100644 coolpress/press/models.py create mode 100644 coolpress/press/tests.py create mode 100644 coolpress/press/views.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/coolpress.iml b/.idea/coolpress.iml new file mode 100644 index 0000000..8e5446a --- /dev/null +++ b/.idea/coolpress.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4064368 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..53415ff --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/coolpress/coolpress/__init__.py b/coolpress/coolpress/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/coolpress/coolpress/asgi.py b/coolpress/coolpress/asgi.py new file mode 100644 index 0000000..640f4af --- /dev/null +++ b/coolpress/coolpress/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for coolpress project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'coolpress.settings') + +application = get_asgi_application() diff --git a/coolpress/coolpress/settings.py b/coolpress/coolpress/settings.py new file mode 100644 index 0000000..0550225 --- /dev/null +++ b/coolpress/coolpress/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for coolpress project. + +Generated by 'django-admin startproject' using Django 3.2.7. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-jkr6+)ng(dafm#h^k6uvqx(=3jk2b=fr6=a0bvhlku3ov=lc2&' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'press' +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'coolpress.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'coolpress.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/3.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.2/howto/static-files/ + +STATIC_URL = '/static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/coolpress/coolpress/urls.py b/coolpress/coolpress/urls.py new file mode 100644 index 0000000..ea0b47f --- /dev/null +++ b/coolpress/coolpress/urls.py @@ -0,0 +1,21 @@ +"""coolpress URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/coolpress/coolpress/wsgi.py b/coolpress/coolpress/wsgi.py new file mode 100644 index 0000000..e6e72e1 --- /dev/null +++ b/coolpress/coolpress/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for coolpress project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'coolpress.settings') + +application = get_wsgi_application() diff --git a/coolpress/manage.py b/coolpress/manage.py new file mode 100644 index 0000000..bd1eda1 --- /dev/null +++ b/coolpress/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'coolpress.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/coolpress/press/__init__.py b/coolpress/press/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/coolpress/press/admin.py b/coolpress/press/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/coolpress/press/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/coolpress/press/apps.py b/coolpress/press/apps.py new file mode 100644 index 0000000..1067a7e --- /dev/null +++ b/coolpress/press/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class PressConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'press' diff --git a/coolpress/press/migrations/0001_initial.py b/coolpress/press/migrations/0001_initial.py new file mode 100644 index 0000000..ec10b57 --- /dev/null +++ b/coolpress/press/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.7 on 2022-11-08 13:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Category', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('label', models.CharField(max_length=200)), + ('slug', models.SlugField()), + ], + ), + ] diff --git a/coolpress/press/migrations/__init__.py b/coolpress/press/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/coolpress/press/models.py b/coolpress/press/models.py new file mode 100644 index 0000000..4f2132b --- /dev/null +++ b/coolpress/press/models.py @@ -0,0 +1,9 @@ +from django.db import models + +class Category(models.Model): + label = models.CharField(max_length=200) + slug = models.SlugField() + + + def __str__(self): + return f'{self.label}({self.id})' diff --git a/coolpress/press/tests.py b/coolpress/press/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/coolpress/press/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/coolpress/press/views.py b/coolpress/press/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/coolpress/press/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. From 47e8a6e2fdf2a9cefd356dbf5ebf180e0a3bceca Mon Sep 17 00:00:00 2001 From: Fatma Nasser <104837260+f6ew@users.noreply.github.com> Date: Fri, 11 Nov 2022 11:28:13 +0100 Subject: [PATCH 02/19] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 73f253c..c5d2790 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # coolpress +# Fatma Nasser CoolPress is an application to show the power of web development using Django From 6eb4d1657c487830eb4b210de39ade5358cd95f5 Mon Sep 17 00:00:00 2001 From: F6ew Date: Sun, 13 Nov 2022 22:03:45 +0100 Subject: [PATCH 03/19] Adding dumpdata --- coolpress/dumpdata.jason | Bin 0 -> 6108 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 coolpress/dumpdata.jason diff --git a/coolpress/dumpdata.jason b/coolpress/dumpdata.jason new file mode 100644 index 0000000000000000000000000000000000000000..8f431baf50f68bca0dbef98c3d2c3274723e9d67 GIT binary patch literal 6108 zcmeHL%Wm306us+6`3K~6g233M$qu#3DvPRO)vAhk7-E$I0#d1}^6O2{nXxl4Ly9fN zAce@n$dCJ&!@1|);rZ`3IhQl}qs}$aM<73CCPPVNB7xlCZXk16;ChLpE(1KB;n^du z65J2u!m^*skIb^^JR3=>JP%>5y>CW0Ss4G!!S-a{8zYCF{K992&qD5zTPo9+90Di9 zb=wqH4_Hedc3kC5Mp<6P?TF1BmU=x?c$?rLvU#K@b@h~?vAJTOc!%Ebwms!53FIAb z!|#?iylqdXgf}ZU0k3ALzu!)^Qhj{r$pq@qSK5=SS_jul#HM}>@NFxZ`3;sz@5V36 z;9B~t_Tp&RH5x#>imI!N#%G1UMuVzY91Yj<7--lPv>zIG;KUSNa0zDgz`&#g9@}h> zfk?E6I=TGVwyMp}|9ZUy9=l=j`iQ-*|08&?u2W$NMrd1F9D@h#N^xkF#(@^TaNyiU z4Y$?GSJzlUQCCoZ*1w*GyOmXzz4Um7LEK_7RMa*Hw_1sG+4GD2vVh(Sra|<4M_eLUo z^W4DR-~*n9^7TKls4L9#9$C&SjMIaEPWF0-Lagm>xxW6*%GRrn4$4tGyE5HtH%GZs z1kY Date: Mon, 14 Nov 2022 09:54:46 +0100 Subject: [PATCH 04/19] Adding dumpdata --- coolpress/dumpdata.jason | Bin 6108 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 coolpress/dumpdata.jason diff --git a/coolpress/dumpdata.jason b/coolpress/dumpdata.jason deleted file mode 100644 index 8f431baf50f68bca0dbef98c3d2c3274723e9d67..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6108 zcmeHL%Wm306us+6`3K~6g233M$qu#3DvPRO)vAhk7-E$I0#d1}^6O2{nXxl4Ly9fN zAce@n$dCJ&!@1|);rZ`3IhQl}qs}$aM<73CCPPVNB7xlCZXk16;ChLpE(1KB;n^du z65J2u!m^*skIb^^JR3=>JP%>5y>CW0Ss4G!!S-a{8zYCF{K992&qD5zTPo9+90Di9 zb=wqH4_Hedc3kC5Mp<6P?TF1BmU=x?c$?rLvU#K@b@h~?vAJTOc!%Ebwms!53FIAb z!|#?iylqdXgf}ZU0k3ALzu!)^Qhj{r$pq@qSK5=SS_jul#HM}>@NFxZ`3;sz@5V36 z;9B~t_Tp&RH5x#>imI!N#%G1UMuVzY91Yj<7--lPv>zIG;KUSNa0zDgz`&#g9@}h> zfk?E6I=TGVwyMp}|9ZUy9=l=j`iQ-*|08&?u2W$NMrd1F9D@h#N^xkF#(@^TaNyiU z4Y$?GSJzlUQCCoZ*1w*GyOmXzz4Um7LEK_7RMa*Hw_1sG+4GD2vVh(Sra|<4M_eLUo z^W4DR-~*n9^7TKls4L9#9$C&SjMIaEPWF0-Lagm>xxW6*%GRrn4$4tGyE5HtH%GZs z1kY Date: Mon, 14 Nov 2022 09:55:55 +0100 Subject: [PATCH 05/19] Adding dumpdata --- coolpress/dumpdata.jason | Bin 0 -> 8670 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 coolpress/dumpdata.jason diff --git a/coolpress/dumpdata.jason b/coolpress/dumpdata.jason new file mode 100644 index 0000000000000000000000000000000000000000..274b37b995f766d0c3f49f6fc00da85372d9a86f GIT binary patch literal 8670 zcmeHMOK;jh5T0|T{)fot77?%s&8=$1sfVh{sZoU>IMgjK@kmrv`Ri@JZ`aF)H8yr^ zh#Js}haa;uJNwOZ|Ngm_*YZk!tM4<>!;`U0Wgwx9#FIuI_Q2#+mw|UnNZ}hPQ#Vv+j&u%?vx}Mx%J(1k4HL=7RR~h;nfX@=oyYd4&$9)SQ z?RZ1#(!h8t=NSBM$`!8bz$EWq;$IzzY(m=?@-;)-L&z~zyKK;RE#Ff2#_Vc0M#UJC z5s?w*nBZ4yg)`8044NL))k8e%Cc4X8RKtbp#)u&Hl%rjx#{25hZUCVp({+nvdBd-?d*b-)l7G?!lqYxQ7T z#+F?#P$Uy({nUr0+FIy6u33fAf3SK<&np+o-wk66_asSKoweuJhHIncwDDQ#Uu%P2 zF~2sFl+U3J*MiDv;}bA3K_SLq(~(T-|jC!OW7?jq_DE&R5+y);5jI>V|%Wa&}cm&U7lO=VN--%qjHj zZnU(TriXuQ+4_C|pcr+fD-ykSW0aK|>o!I-t~^RpDiD zT7*v$r*0l&_hdUxgM;GKm9AQxvKHsrh(_tL;xtgF8|)Uf(KYh-hSMT^k~noe)-Ig3 z4vNz{rJ;je3CeIJ=QLq9@d|hsZsLaG(tb~ nxKVnpylD&Gv<_dIeWLaBs2?D+;F)wjK1q~T<4svr>67VyVwwVj literal 0 HcmV?d00001 From 81e8904adb40efe52012bfe8a917aea890e7655c Mon Sep 17 00:00:00 2001 From: F6ew Date: Wed, 16 Nov 2022 13:39:23 +0100 Subject: [PATCH 06/19] Adding dumpdata --- coolpress/press/template/posts_detail.html | 56 ++++++++++++++++++++++ coolpress/press/template/posts_list.html | 38 +++++++++++++++ coolpress/press/template/posts_update.html | 16 +++++++ 3 files changed, 110 insertions(+) create mode 100644 coolpress/press/template/posts_detail.html create mode 100644 coolpress/press/template/posts_list.html create mode 100644 coolpress/press/template/posts_update.html diff --git a/coolpress/press/template/posts_detail.html b/coolpress/press/template/posts_detail.html new file mode 100644 index 0000000..4deb8e4 --- /dev/null +++ b/coolpress/press/template/posts_detail.html @@ -0,0 +1,56 @@ +{% extends 'base.html' %} + +{% block content %} +

{{post_obj.title}}

+ +{% if post_obj.image_link %} +
+ {{post_obj.title}} +
+{% endif %} +

{{post_obj.body|urlize}}

+ +{% if post_obj.source_link and post_obj.source_label %} + +{% endif %} + + +
+
Created at: + {{post_obj.creation_date|date:'Y-d-m'}}
+
Updated at: + {{post_obj.last_update|date:'Y-d-m'}}
+
+ + {% for comment in comments %} +
+
+

{{comment.body}}

+

+ + From: {{comment.author.user.username}} - votes: {{comment.votes}} Created at: {{comment.creation_date}} + +

+
+
+{% empty %}} +

No comments added yet

+{% endfor %} + + + +

+ {% csrf_token %} +
+ {{ comment_form }} +
+ +
+ +
+
+ +{% endblock %} diff --git a/coolpress/press/template/posts_list.html b/coolpress/press/template/posts_list.html new file mode 100644 index 0000000..f091423 --- /dev/null +++ b/coolpress/press/template/posts_list.html @@ -0,0 +1,38 @@ +{% extends 'base.html' %} + +{% block content %} + +{% for post in posts_list %} +
+
+ {% if post.image_link %} +
+ {{post.title}} +
+ {% endif %} + +
+
+{% empty %} + +

+ There are no posts yet for this category, let's create some :D +

+ +{% end-for %} + +{% end-block %} diff --git a/coolpress/press/template/posts_update.html b/coolpress/press/template/posts_update.html new file mode 100644 index 0000000..71f9729 --- /dev/null +++ b/coolpress/press/template/posts_update.html @@ -0,0 +1,16 @@ +{% extends 'base.html' %} + +{% block content %} +

Create a new news post

+
+ {% csrf_token %} + +
+ {{ my_awesome_form }} +
+ +
+ +
+
+{% endblock %} From 0c0ae6a0ece798f587cbf9cf51ec0700565e938a Mon Sep 17 00:00:00 2001 From: F6ew Date: Wed, 16 Nov 2022 13:57:30 +0100 Subject: [PATCH 07/19] Adding TEMPLATES --- .idea/coolpress.iml | 4 + .idea/modules.xml | 3 + .idea/vcs.xml | 2 + coolpress/__init__.py | 0 coolpress/coolpress/settings.py | 23 ++- coolpress/coolpress/urls.py | 44 +++--- coolpress/press/admin.py | 34 ++++ coolpress/press/forms.py | 24 +++ coolpress/press/models.py | 63 +++++++- coolpress/press/pip.py | 1 + coolpress/press/template/about.html | 16 ++ coolpress/press/template/base.html | 32 ++++ coolpress/press/template/comment-add.html | 20 +++ coolpress/press/template/navbar.html | 48 ++++++ coolpress/press/template/pagination.html | 25 +++ coolpress/press/views.py | 184 +++++++++++++++++++++- coolpress/requirements.txt | 1 + 17 files changed, 490 insertions(+), 34 deletions(-) create mode 100644 coolpress/__init__.py create mode 100644 coolpress/press/forms.py create mode 100644 coolpress/press/pip.py create mode 100644 coolpress/press/template/about.html create mode 100644 coolpress/press/template/base.html create mode 100644 coolpress/press/template/comment-add.html create mode 100644 coolpress/press/template/navbar.html create mode 100644 coolpress/press/template/pagination.html create mode 100644 coolpress/requirements.txt diff --git a/.idea/coolpress.iml b/.idea/coolpress.iml index 8e5446a..088ac7a 100644 --- a/.idea/coolpress.iml +++ b/.idea/coolpress.iml @@ -6,6 +6,10 @@ + + + +