Skip to content

Commit

Permalink
renamed all instances of Contact to TransientContact
Browse files Browse the repository at this point in the history
  • Loading branch information
brosner committed Apr 15, 2010
1 parent cd550f4 commit c8d18d9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions contacts_import/admin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.contrib import admin

from contacts_import.models import Contact
from contacts_import.models import TransientContact


class ContactAdmin(admin.ModelAdmin):
class TransientContactAdmin(admin.ModelAdmin):
pass


admin.site.register(Contact, ContactAdmin)
admin.site.register(TransientContact, TransientContactAdmin)
9 changes: 6 additions & 3 deletions contacts_import/backends/persistance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from contacts_import.models import Contact
from contacts_import.models import TransientContact


class BasePersistance(object):
Expand All @@ -22,8 +22,11 @@ def default_status(self):
}

def persist_contact(self, contact, status, credentials):
obj, created = Contact.objects.get_or_create(user=credentials["user"],
email=contact["email"], defaults={"name": contact["name"]})
obj, created = TransientContact.objects.get_or_create(
user = credentials["user"],
email = contact["email"],
defaults = {"name": contact["name"]}
)
status["total"] += 1
if created:
status["imported"] += 1
Expand Down
6 changes: 3 additions & 3 deletions contacts_import/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.contrib.auth.models import User

from contacts_import.models import Contact
from contacts_import.models import TransientContact


class BasicTest(TestCase):
Expand All @@ -29,9 +29,9 @@ def tests_views(self):
self.assertEqual(response.status_code, 302)

def test_contact_display(self):
Contact.objects.create(user=self.bob, name="Bjarne Stroustrup",
TransientContact.objects.create(user=self.bob, name="Bjarne Stroustrup",
email="bjarne@making.life.hard.com")
Contact.objects.create(user=self.bob, name="Guido van Rossum",
TransientContact.objects.create(user=self.bob, name="Guido van Rossum",
email="guido@python.org")

response = self.client.get(reverse("import_contacts"))
Expand Down
6 changes: 3 additions & 3 deletions contacts_import/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from contacts_import.forms import VcardImportForm
from contacts_import.backends.importers import GoogleImporter, YahooImporter
from contacts_import.models import Contact
from contacts_import.models import TransientContact
from contacts_import.settings import RUNNER, CALLBACK


Expand Down Expand Up @@ -76,12 +76,12 @@ def import_contacts(request, template_name="contacts_import/import_contacts.html
return HttpResponseRedirect("%s?page=%s" % (request.path, page_num-1))
elif "finish" in request.POST:
if not selected:
Contact.objects.filter(user=request.user).delete()
TransientContact.objects.filter(user=request.user).delete()
return HttpResponseRedirect(reverse("import_contacts"))
# give control over to the callback which is required to
# return a HttpResponse
response = callback(request, selected)
Contact.objects.filter(user=request.user).delete()
TransientContact.objects.filter(user=request.user).delete()
return response
else:
form = VcardImportForm()
Expand Down

0 comments on commit c8d18d9

Please sign in to comment.