-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd8af8e
commit aa47675
Showing
183 changed files
with
49,340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.pythonPath": "C:\\Anaconda3\\envs\\django2\\python.exe" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
""" | ||
Django settings for PasteleriaBelen project. | ||
Generated by 'django-admin startproject' using Django 2.0.2. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/2.0/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/2.0/ref/settings/ | ||
""" | ||
|
||
import os | ||
|
||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = 'c59(q(-8dw=ci(lu(!prvy=r^cu++c&^qfhi(q9=e6-m49f4u1' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = [] | ||
|
||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'registration', | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'blog', | ||
'catalog.apps.CatalogConfig', | ||
'core', | ||
'contact', | ||
'pages.apps.PagesConfig', | ||
'services.apps.ServicesConfig', | ||
'social.apps.SocialConfig', | ||
] | ||
|
||
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 = 'PasteleriaBelen.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', | ||
'social.processors.ctx_dict', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'PasteleriaBelen.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
} | ||
} | ||
|
||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/2.0/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/2.0/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'es-pe' | ||
|
||
TIME_ZONE = 'UTC' | ||
|
||
USE_I18N = True | ||
|
||
USE_L10N = True | ||
|
||
USE_TZ = True | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/2.0/howto/static-files/ | ||
|
||
STATIC_URL = '/static/' | ||
|
||
#configuración media | ||
MEDIA_URL = '/media/' | ||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | ||
|
||
#Configuración de email: | ||
EMAIL_HOST = 'smtp.mailtrap.io' | ||
EMAIL_HOST_USER = 'e1b613e4c98312' | ||
EMAIL_HOST_PASSWORD = 'f49495daf55e97' | ||
EMAIL_PORT = '2525' | ||
|
||
#Auth redirect | ||
#LOGIN_REDIRECT_URL = 'home' | ||
LOGOUT_REDIRECT_URL = 'home' | ||
|
||
#Emails de prueba para los clientes registrados (Restablecimiento de contraseña) | ||
if DEBUG: | ||
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend" | ||
EMAIL_FILE_PATH = os.path.join(BASE_DIR, "sent_emails") | ||
else: | ||
#Aquí se configuraría un email real de producción | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""PasteleriaBelen URL Configuration | ||
The `urlpatterns` list routes URLs to views. For more information please see: | ||
https://docs.djangoproject.com/en/2.0/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, include | ||
|
||
from django.conf import settings | ||
|
||
urlpatterns = [ | ||
path('', include('core.urls')), | ||
#path('users/', include('users.urls')), | ||
path('services/', include('services.urls')), | ||
path('blog/', include('blog.urls')), | ||
path('page/', include('pages.urls')), | ||
path('contact/', include('contact.urls')), | ||
path('catalog/', include('catalog.urls')), | ||
path('admin/', admin.site.urls), | ||
#paths de Auth | ||
path('accounts/', include('django.contrib.auth.urls')), | ||
path('accounts/', include('registration.urls')), | ||
] | ||
|
||
|
||
#comprobamos si el debug está en marcha | ||
if settings.DEBUG: | ||
from django.conf.urls.static import static | ||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for PasteleriaBelen 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/2.0/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PasteleriaBelen.settings") | ||
|
||
application = get_wsgi_application() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.contrib import admin | ||
from .models import Category, Post | ||
|
||
# Register your models here. | ||
class CategoryAdmin(admin.ModelAdmin): | ||
readonly_fields = ('created', 'updated') | ||
|
||
class PostAdmin(admin.ModelAdmin): | ||
readonly_fields = ('created', 'updated') | ||
#Tuneando el administrador | ||
list_display=('title', 'author', 'published', 'post_categories') | ||
#Que se ordenen por dos campos | ||
ordering = ('author', 'published') | ||
#Mostrando formulario de búsqueda | ||
search_fields=('title','content','author__username', 'categories__name') | ||
#Agregando jerarquía de fechas | ||
date_hierarchy='published' | ||
#Generando un campo de filtrado para búsqueda | ||
list_filter=('author__username', 'categories__name') | ||
|
||
#Método para poder mostrar categorías que tiene la entrada | ||
def post_categories(self, obj): | ||
#obj hace referencia a cada instancia o entrada | ||
return ", ".join([c.name for c in obj.categories.all().order_by('name')]) | ||
#sobreescribiendo un método para cambiar el nombre de la descripción | ||
post_categories.short_description='Categoría' | ||
|
||
admin.site.register(Category, CategoryAdmin) | ||
admin.site.register(Post, PostAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BlogConfig(AppConfig): | ||
name = 'blog' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Generated by Django 2.0.2 on 2018-10-11 16:19 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Category', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100, verbose_name='Nombre')), | ||
('created', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creación')), | ||
('updated', models.DateTimeField(auto_now=True, verbose_name='Fecha de edición')), | ||
], | ||
options={ | ||
'verbose_name': 'Categoría', | ||
'verbose_name_plural': 'Categorías', | ||
'ordering': ['-created'], | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Post', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(max_length=200, verbose_name='Título')), | ||
('content', models.TextField(verbose_name='Contenido')), | ||
('published', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Fecha de publicación')), | ||
('image', models.ImageField(blank=True, null=True, upload_to='blog', verbose_name='Imagen')), | ||
('created', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de creación')), | ||
('updated', models.DateTimeField(auto_now=True, verbose_name='Fecha de edición')), | ||
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Autor')), | ||
('categories', models.ManyToManyField(to='blog.Category', verbose_name='Categorías')), | ||
], | ||
options={ | ||
'verbose_name': 'Entrada', | ||
'verbose_name_plural': 'Entrada', | ||
'ordering': ['-created'], | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.db import models | ||
from django.utils.timezone import now | ||
from django.contrib.auth.models import User | ||
|
||
# Creando modelos para categorías y entradas o posts | ||
class Category(models.Model): | ||
name = models.CharField(max_length=100, verbose_name='Nombre') | ||
created = models.DateTimeField(verbose_name='Fecha de creación', auto_now_add=True) | ||
updated = models.DateTimeField(verbose_name='Fecha de edición', auto_now=True) | ||
|
||
class Meta: | ||
verbose_name = 'Categoría' | ||
verbose_name_plural = 'Categorías' | ||
ordering = ['-created'] | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
class Post(models.Model): | ||
title = models.CharField(max_length=200, verbose_name='Título') | ||
content = models.TextField(verbose_name='Contenido') | ||
published = models.DateTimeField(verbose_name='Fecha de publicación', default=now) | ||
image = models.ImageField(verbose_name='Imagen', upload_to='blog', null=True, blank=True) | ||
author = models.ForeignKey(User, verbose_name='Autor', on_delete=models.CASCADE) | ||
categories = models.ManyToManyField(Category, verbose_name='Categorías', related_name='get_posts') | ||
created = models.DateTimeField(verbose_name='Fecha de creación', auto_now_add=True) | ||
updated = models.DateTimeField(verbose_name='Fecha de edición', auto_now=True) | ||
|
||
class Meta: | ||
verbose_name = 'Entrada' | ||
verbose_name_plural = 'Entrada' | ||
ordering = ['-created'] | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
#Observación: con related_name, cambiamos el nombre de la relación many to many, | ||
# para poder buscar una relación dentro de otra. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{% extends 'core/base.html' %} | ||
|
||
{% load static %} | ||
|
||
{% block title %}Blog{% endblock %} | ||
|
||
{% block content %} | ||
|
||
{% for post in posts %} | ||
<section class="page-section cta"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-xl-9 mx-auto"> | ||
<div class="cta-innerv text-center rounded"> | ||
<h2 class="section-heading mb-5"> | ||
<span class="section-heading-upper">{{post.published | date:"SHORT_DATE_FORMAT"}}</span> | ||
<span class="section-heading-lower">{{post.title}}</span> | ||
</h2> | ||
<p class="mb-0"> | ||
<img class="mx-auto d-flex rounded img-fluid mb-3 mb-lg-0" src="{{post.image.url}}" alt=""> | ||
</p> | ||
<p class="mb-0 mbt">{{post.content | linebreaks}}</p> | ||
<p class="mb-0 mbt"> | ||
<span class="section-heading-under">Publicado por <em><b>{{post.author}}</b></em> en | ||
<!-- <em><a href="#" class="link">General</a>, <a href="#" class="link">Ofertas</a></em> --> | ||
{% for category in post.categories.all %} | ||
<em> | ||
<a href="{% url 'category' category.id %}" class="link">{{category.name}}</a>{% if not forloop.last %},{% endif %} | ||
</em> | ||
{% endfor %} | ||
</span> | ||
</p> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
{% endfor %} | ||
|
||
{% endblock %} | ||
|
||
|
||
|
Oops, something went wrong.