Skip to content

Commit

Permalink
Update test, Init Contact Form [NOT FINISHED]
Browse files Browse the repository at this point in the history
  • Loading branch information
avara1986 committed Jul 9, 2014
1 parent 3faf3d7 commit d6722b8
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[run]
source =
webiste
avara
webiste
omit =
avara/wsgi.py
autoload/*
dbindexer/*
django/*
Expand Down
14 changes: 11 additions & 3 deletions avara/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
has_djangoappengine = False
DEBUG = True
TEMPLATE_DEBUG = DEBUG

from djangoappengine.utils import on_production_server
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
# Project dir carga hasta nombre-proyecto/nombre-proyecto (a la altura de
Expand Down Expand Up @@ -44,10 +46,12 @@
'website',
'autoload',
'dbindexer',
'djangoappengine',
'appengine_toolkit',
)

#if on_production_server:
INSTALLED_APPS = INSTALLED_APPS + (
'appengine_toolkit',
)
DATABASES['native'] = DATABASES['default']
DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}
#DATABASES['default']['DOMAIN'] = 'a-vara.appspot.com'
Expand Down Expand Up @@ -203,7 +207,11 @@
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'a.vara.1986@gmail.com'
#EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
if on_production_server:
EMAIL_BACKEND = 'djangoappengine.mail.AsyncEmailBackend'
else:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

#EMAIL_BACKEND = 'common.mail.EmailBackend'

APPENGINE_TOOLKIT = {
Expand Down
8 changes: 6 additions & 2 deletions avara/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

urlpatterns = patterns('',
# Examples:
url(r'^', include('website.urls')),
# url(r'^avara/', include('avara.foo.urls')),
url(r'^$', include('website.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'^media/(?P<path>.*)$','django.views.static.serve', {'document_root': settings.MEDIA_ROOT,}),
)

if settings.DEBUG is False:
urlpatterns += patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
)
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Django==1.5.8
GoogleAppEngineCloudStorageClient==1.9.5.0
Pillow==2.5.0
argparse==1.2.1
django-appengine-toolkit==0.2.1
python-memcached==1.53
wsgiref==0.1.2
django-model-utils==2.0.3
South==0.8.4
GoogleAppEngineCloudStorageClient==1.9.5.0
Pillow==2.5.0
argparse==1.2.1
django-appengine-toolkit==0.2.1
python-memcached==1.53
wsgiref==0.1.2
django-model-utils==2.0.3
South==0.8.4
8 changes: 8 additions & 0 deletions website/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# encoding: utf-8
from django import forms
from website.models import Contact


class ContactForm(forms.ModelForm):
class Meta:
model = Contact
13 changes: 12 additions & 1 deletion website/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# encoding: utf-8
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

# Create your models here.

@python_2_unicode_compatible
class Contact(models.Model):
name = models.CharField(_('name'), max_length=230)
email = models.EmailField(_('email address'))
comment = models.CharField(_('Comment'), max_length=250, blank=True)

def __str__(self):
return self.title
8 changes: 8 additions & 0 deletions website/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import Client
from website.models import Contact


class avaraTestCase(TestCase):
Expand All @@ -16,3 +17,10 @@ def setUp(self):
def test_get_200(self):
index_res = self.client.get(reverse('index'))
self.assertEqual(index_res.status_code, 200)

def test_post_forms_contact(self):
contact_url = reverse('index')
contact_res = self.client.post(contact_url, {'name': 'Alberto',
'email': 'a.vara.1986@gmail.com',
'comment': 'Pruba'})
self.assertEqual(contact_res.status_code, 200)
2 changes: 0 additions & 2 deletions website/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from avara import settings
from django.conf.urls import patterns, include, url
'''
ajax_urlpatterns = patterns('apps.cms.attendees.ajax',
Expand All @@ -11,5 +10,4 @@
)
urlpatterns = patterns('',
url(r'^', include(views_urlpatterns)),
#url(r'^' + settings.RIA_URL + '', include(ajax_urlpatterns)),
)

0 comments on commit d6722b8

Please sign in to comment.