Add docker support
This commit is contained in:
0
django/project/__init__.py
Normal file
0
django/project/__init__.py
Normal file
9
django/project/admin.py
Normal file
9
django/project/admin.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from django.contrib import admin
|
||||
from .models import Project
|
||||
|
||||
|
||||
class ProjectAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ('created', 'updated',)
|
||||
|
||||
|
||||
admin.site.register(Project, ProjectAdmin)
|
||||
6
django/project/apps.py
Normal file
6
django/project/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProjectConfig(AppConfig):
|
||||
name = 'project'
|
||||
verbose_name = 'Proyectos'
|
||||
30
django/project/forms.py
Normal file
30
django/project/forms.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from django import forms
|
||||
|
||||
|
||||
class ContactForm(forms.Form):
|
||||
name = forms.CharField(
|
||||
label="Nombre",
|
||||
required=True,
|
||||
widget=forms.TextInput(
|
||||
attrs={'placeholder': 'Nombre'}
|
||||
),
|
||||
min_length=3,
|
||||
max_length=100)
|
||||
|
||||
email = forms.EmailField(
|
||||
label="Email",
|
||||
required=True,
|
||||
widget=forms.EmailInput(
|
||||
attrs={'placeholder': 'user@page.domain'}
|
||||
),
|
||||
min_length=3,
|
||||
max_length=100)
|
||||
|
||||
content = forms.CharField(
|
||||
label="Mensaje",
|
||||
required=True,
|
||||
widget=forms.Textarea(
|
||||
attrs={'placeholder': 'Mensaje'}
|
||||
),
|
||||
min_length=10,
|
||||
max_length=1000)
|
||||
0
django/project/migrations/__init__.py
Normal file
0
django/project/migrations/__init__.py
Normal file
33
django/project/models.py
Normal file
33
django/project/models.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
title = models.CharField(
|
||||
max_length=200, verbose_name='Titulo')
|
||||
|
||||
decription = models.TextField(
|
||||
verbose_name='Descripción')
|
||||
|
||||
image = models.ImageField(
|
||||
verbose_name='Imagen',
|
||||
upload_to='projects/uploads/%Y/%m/%d/')
|
||||
|
||||
link = models.URLField(
|
||||
null=True, blank=True,
|
||||
verbose_name='Sitio web')
|
||||
|
||||
created = models.DateTimeField(
|
||||
auto_now_add=True,
|
||||
verbose_name='Fecha de creación')
|
||||
|
||||
updated = models.DateTimeField(
|
||||
auto_now=True,
|
||||
verbose_name='Fecha de modificación')
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'proyecto'
|
||||
verbose_name_plural = 'proyectos'
|
||||
ordering = ["-created"]
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
154
django/project/templates/trabajo/index.djhtml
Normal file
154
django/project/templates/trabajo/index.djhtml
Normal file
File diff suppressed because one or more lines are too long
3
django/project/tests.py
Normal file
3
django/project/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
7
django/project/urls.py
Normal file
7
django/project/urls.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.home, name="home"),
|
||||
# path('filename', views.i2pfile, name='i2pfile'),
|
||||
]
|
||||
45
django/project/views.py
Normal file
45
django/project/views.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from django.shortcuts import render, redirect
|
||||
from django.urls import reverse
|
||||
from django.core.mail import EmailMessage
|
||||
from .models import Project
|
||||
from .forms import ContactForm
|
||||
from personalsite.settings import (
|
||||
EMAIL_FROM,
|
||||
EMAIL_TO
|
||||
)
|
||||
|
||||
|
||||
def home(request):
|
||||
projects = Project.objects.all()
|
||||
|
||||
# Form
|
||||
contact_form = ContactForm()
|
||||
if request.method == "POST":
|
||||
contact_form = ContactForm(data=request.POST)
|
||||
if contact_form.is_valid():
|
||||
name = request.POST.get('name', '')
|
||||
email = request.POST.get('email', '')
|
||||
content = request.POST.get('content', '')
|
||||
# Send Email
|
||||
msg = EmailMessage(
|
||||
"Personal-Site: Nuevo mensaje",
|
||||
"De {} <{}>\n\nEscribió:\n\n{}".format(name, email, content),
|
||||
EMAIL_FROM,
|
||||
[EMAIL_TO],
|
||||
reply_to=[email],
|
||||
)
|
||||
try:
|
||||
msg.send(fail_silently=False)
|
||||
# ok
|
||||
return redirect(reverse('home')+"?ok")
|
||||
except:
|
||||
# Fail
|
||||
return redirect(reverse('home')+"?fail")
|
||||
# EndForm
|
||||
|
||||
return render(request, 'trabajo/index.djhtml',
|
||||
{'projects': projects, 'form': contact_form})
|
||||
|
||||
|
||||
# def i2pfile(request):
|
||||
# return render(request, 'trabajo/filename')
|
||||
Reference in New Issue
Block a user