This file contains hidden or 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
| from django.core.urlresolvers import reverse | |
| from django.test import TestCase | |
| from posts.models import Post | |
| class PostsViewsTestCase(TestCase): | |
| fixtures = ['posts__testdata.json'] | |
| # Prueba de la página de inicio | |
| def test_index(self): |
This file contains hidden or 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
| from django.utils import timezone | |
| from django.test import TestCase | |
| from posts.models import Post | |
| class PostTestCase(TestCase): | |
| fixtures = ['posts__testdata.json'] | |
| # Inicialización de las variables | |
| def setUp(self): |
This file contains hidden or 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
| from posts.tests.models import * | |
| from posts.tests.views import * |
This file contains hidden or 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
| from django.conf.urls import url | |
| from . import views | |
| urlpatterns = [ | |
| # Post | |
| url(r'^$' , views.index, name='posts_index'), # Listar | |
| url(r'^(?P<post_id>[0-9]+)?$' , views.obtener, name='posts_obtener'), # Obtener | |
| url(r'^crear$' , views.crear, name='posts_crear'), # Crear | |
| url(r'^crear_do$' , views.crear_do, name='posts_crear_do'), # Crear do |
This file contains hidden or 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
| [ | |
| { | |
| "pk": 1, | |
| "model": "posts.post", | |
| "fields": { | |
| "pub_fecha": "2015-05-05 16:23:42", | |
| "nombre": "Hola", | |
| "contenido": "Funciona", | |
| "autor":"Tony" | |
| } |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from django.core.management.base import BaseCommand, CommandError | |
| from posts.models import * | |
| class Command(BaseCommand): | |
| args = '' | |
| help = 'Tarea que saluda' |
This file contains hidden or 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
| from django.contrib import admin | |
| from django import forms | |
| from .models import Post | |
| ''' ******************************* Ayudas ******************************* ''' | |
| #Formato Form | |
| class Text_Form(forms.ModelForm): | |
| contenido = forms.CharField( widget=forms.Textarea ) |
This file contains hidden or 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
| from django.db import models | |
| from django.utils import timezone | |
| from datetime import timedelta | |
| class Post(models.Model): | |
| nombre = models.CharField(max_length=200) | |
| autor = models.CharField(max_length=200) | |
| contenido = models.TextField() | |
| pub_fecha = models.DateTimeField('fecha') |
This file contains hidden or 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
| {% block sidebar_content %} | |
| {% endblock sidebar_content %} | |
| <div class="well"> | |
| {% if user.is_authenticated %} | |
| <a href="/sesion/logout">Cerrar sesión</a> | |
| {% else %} | |
| <a href="/sesion/login">Iniciar sesión</a> | |
| {% endif %} | |
| </div> |
This file contains hidden or 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
| from django.http import HttpResponse | |
| from django.shortcuts import render, get_object_or_404, redirect | |
| from django.core.urlresolvers import reverse | |
| from datetime import datetime | |
| import json | |
| from .models import Post | |
| ##################################### POST #################################### |
NewerOlder