Exemple #1
0
class AddContactTests(TestCase):
    def setUp(self):
        self.view = AddContact()
        self.form = mock.Mock(spec=AddContactForm)
        self.form.save = mock.Mock(return_value=mock.Mock(id=1))
        self.form.cleaned_data = {}

    def test_has_expected_permissions_properties(self):
        self.assertEqual(self.view.permission_required, 'contacts.add_user')
        self.assertTrue(self.view.raise_exception)

    def test_form_valid_calls_save_on_form(self):
        self.view.form_valid(self.form)
        self.form.save.assert_called_with()

    def test_form_valid_calls_save_on_object(self):
        self.view.form_valid(self.form)
        self.view.object.save.assert_called_with()

    def test_form_valid_sets_an_unusable_password(self):
        self.view.form_valid(self.form)
        self.view.object.set_unusable_password.assert_called_once_with()
class AddContactTests(TestCase):

    def setUp(self):
        self.view = AddContact()
        self.form = mock.Mock(spec=AddContactForm)
        self.form.save = mock.Mock(return_value=mock.Mock(id=1))
        self.form.cleaned_data = {}

    def test_has_expected_permissions_properties(self):
        self.assertEqual(self.view.permission_required, 'contacts.add_user')
        self.assertTrue(self.view.raise_exception)

    def test_form_valid_calls_save_on_form(self):
        self.view.form_valid(self.form)
        self.form.save.assert_called_with()

    def test_form_valid_calls_save_on_object(self):
        self.view.form_valid(self.form)
        self.view.object.save.assert_called_with()

    def test_form_valid_sets_an_unusable_password(self):
        self.view.form_valid(self.form)
        self.view.object.set_unusable_password.assert_called_once_with()
Exemple #3
0
from django.conf.urls import url
from contacts.views import (AddContact, UpdateContact, DeleteContact,
                            ListContacts, SendActivationEmailView,
                            UpdatePersonalInfo, ListContactsExport)

urlpatterns = [
    url(r'edit/$', AddContact.as_view(), name='contact_add'),
    url(r'edit/(?P<pk>\d+)/$', UpdateContact.as_view(), name='contact_update'),
    url(r'delete/(?P<pk>\d+)/$',
        DeleteContact.as_view(),
        name='contact_delete'),
    url(r'activate/(?P<pk>\d+)/$',
        SendActivationEmailView.as_view(),
        name='contact_claim_account'),
    url(r'personal/$', UpdatePersonalInfo.as_view(), name='personal_edit'),
    url(r'export_as_csv/$',
        ListContactsExport.as_view(), {'format': 'csv'},
        name='contact_list_csv'),
    url(r'export_as_excel/$',
        ListContactsExport.as_view(), {'format': 'excel'},
        name='contact_list_excel'),
    url(r'$', ListContacts.as_view(), name='contact_list'),
]
Exemple #4
0
 def setUp(self):
     self.view = AddContact()
     self.form = mock.Mock(spec=AddContactForm)
     self.form.save = mock.Mock(return_value=mock.Mock(id=1))
     self.form.cleaned_data = {}
Exemple #5
0
from django.conf.urls import url
from contacts.views import (
    AddContact, UpdateContact, DeleteContact, ListContacts,
    SendActivationEmailView,
    UpdatePersonalInfo, ListContactsExport
)


urlpatterns = [
    url(r'edit/$', AddContact.as_view(), name='contact_add'),
    url(r'edit/(?P<pk>\d+)/$', UpdateContact.as_view(),
        name='contact_update'),
    url(r'delete/(?P<pk>\d+)/$', DeleteContact.as_view(),
        name='contact_delete'),
    url(r'activate/(?P<pk>\d+)/$', SendActivationEmailView.as_view(),
        name='contact_claim_account'),
    url(r'personal/$', UpdatePersonalInfo.as_view(), name='personal_edit'),
    url(r'export_as_csv/$', ListContactsExport.as_view(), {'format': 'csv'},
        name='contact_list_csv'),
    url(r'export_as_excel/$', ListContactsExport.as_view(), {'format': 'excel'},
        name='contact_list_excel'),
    url(r'$', ListContacts.as_view(), name='contact_list'),
]
Exemple #6
0
from django.conf.urls import url
from contacts.views import EditContact, AddContact, DeleteContact

urlpatterns = [
    url(r'^edit_contact/(?P<id_contact>\d{1,})/$', EditContact.as_view(), name='edit_contact'),
    url(r'^add_contact/$', AddContact.as_view(), name="add_contact"),
    url(r'^delete_contact/(?P<id_contact>\d{1,})/$', DeleteContact.as_view(), name="delete_contact"),
]
 def setUp(self):
     self.view = AddContact()
     self.form = mock.Mock(spec=AddContactForm)
     self.form.save = mock.Mock(return_value=mock.Mock(id=1))
     self.form.cleaned_data = {}
Exemple #8
0
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.contrib.auth.decorators import login_required

from contacts.views import AddContact, ListContact, Home
from django.conf import settings

urlpatterns = patterns(
    '',
    # Examples:
    #url(r'^$', home),
    url(r'^$', Home.as_view(template_name="home.html"), name="home"),
    url(r'^contact/create$',
        login_required(AddContact.as_view(template_name="createcontact.html")),
        name='createcontact'),
    url(r'^contact/list$',
        login_required(ListContact.as_view(template_name="allcontacts.html")),
        name='allcontact'),
    url(r'^Imagenes/(?P<path>.*)$', 'django.views.static.serve', {
        'document_root': settings.MEDIA_ROOT,
    }),

    # url(r'^$', ListPost.as_view(template_name="listpost.html") , name='home'),
    # url(r'^detalle/(?P<pk>\d+)$', DetailPost.as_view(template_name="detailpost.html") , name='detalle'),
    # url para CRUD para usuarios
    # url(r'^post/create$', login_required(PostCreate.as_view(template_name="post_form.html")) , name='createpost')# ,
    # url(r'^post/(?P<pk>\d+)/update$', login_required(PostUpdate.as_view(template_name="post_form.html")) , name='updatepost'),
    # url(r'^post/(?P<pk>\d+)/delete$', login_required(PostDelete.as_view(template_name="post_form.html")) , name='deletepost'),
    # formulario propio
    # url(r'^post/(?P<pk>\d+)/add_comment$', login_required(AddComment.as_view(template_name="add_comentario.html")) , name='add_comment'),