Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed clientmodel to addressmodel. Deleted the Client class (now us…

…eless).

Changed the rest of the tests/shop accordingly
  • Loading branch information...
commit 5ad5f853bc5f0347e7669c01c2a25f2197d17618 1 parent 3fc9259
@chrisglass authored
View
2  example/settings.py
@@ -136,7 +136,7 @@
'south',
'polymorphic', # We need polymorphic installed for the shop
'shop', # The django SHOP application
- 'shop.clientmodel',
+ 'shop.addressmodel',
'myshop', # the project we just created
)
View
2  runtests.sh
@@ -4,7 +4,7 @@ args=("$@")
num_args=${#args[@]}
index=0
-suite='shop clientmodel'
+suite='shop addressmodel'
coverage=false
documentation=false
ci=false
View
0  shop/clientmodel/migrations/__init__.py → shop/addressmodel/__init__.py
File renamed without changes
View
8 shop/clientmodel/admin.py → shop/addressmodel/admin.py
@@ -1,11 +1,11 @@
#-*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.admin.options import ModelAdmin
-from shop.clientmodel.models import Client, Country, Address
+from shop.addressmodel.models import Country, Address
-class ClientAdmin(ModelAdmin):
- pass
-admin.site.register(Client, ClientAdmin)
+#class ClientAdmin(ModelAdmin):
+# pass
+#admin.site.register(Client, ClientAdmin)
class CountryAdmin(ModelAdmin):
pass
View
26 shop/clientmodel/models.py → shop/addressmodel/models.py
@@ -6,27 +6,6 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
-class Client(models.Model):
- user = models.OneToOneField(User, related_name="client")
-
- date_of_birth = models.DateField(null=True, blank=True)
- created = models.DateTimeField(auto_now_add=True)
-
- class Meta(object):
- verbose_name = _('Client')
- verbose_name_plural = _('Clients')
-
- def __unicode__(self):
- return "ClientProfile for %s %s" % (self.user.first_name, self.user.last_name)
-
- def shipping_address(self):
- return Address.objects.filter(client=self).filter(is_shipping=True)[0]
-
- def billing_address(self):
- return Address.objects.filter(client=self).filter(is_billing=True)[0]
-
-
-
class Country(models.Model):
name = models.CharField(max_length=255)
@@ -39,8 +18,6 @@ class Meta(object):
class Address(models.Model):
- #client = models.ForeignKey(Client, related_name="addresses")
-
user_shipping = models.OneToOneField(User, related_name='shipping_address', blank=True, null=True)
user_billing = models.OneToOneField(User, related_name='billing_address', blank=True, null=True)
@@ -51,9 +28,6 @@ class Address(models.Model):
state = models.CharField(max_length=255)
country = models.ForeignKey(Country, blank=True, null=True)
- #is_shipping = models.BooleanField() # Is it the default shipping address?
- #is_billing = models.BooleanField() # is it the default billing address?
-
class Meta:
verbose_name_plural = "addresses"
View
0  shop/clientmodel/tests/__init__.py → shop/addressmodel/tests/__init__.py
File renamed without changes
View
16 shop/clientmodel/tests/client.py → shop/addressmodel/tests/client.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
-from shop.clientmodel.models import Client, Country, Address
+from shop.addressmodel.models import Country, Address
from django.test.testcases import TestCase
class ClientTestCase(TestCase):
@@ -11,10 +11,6 @@ def create_fixtures(self):
first_name="Test",
last_name = "Toto")
- self.client = Client()
- self.client.user = self.user
- self.client.save()
-
self.country = Country.objects.create(name='CH')
self.address = Address()
@@ -36,11 +32,11 @@ def create_fixtures(self):
self.address2.save()
- def test_unicode_method_works(self):
- self.create_fixtures()
- expected = "ClientProfile for Test Toto"
- text = self.client.__unicode__()
- self.assertEqual(expected, text)
+# def test_unicode_method_works(self):
+# self.create_fixtures()
+# expected = "ClientProfile for Test Toto"
+# text = self.client.__unicode__()
+# self.assertEqual(expected, text)
def test_unicode_method_works_for_null_user_info(self):
self.create_fixtures()
View
0  shop/clientmodel/__init__.py
No changes.
View
117 shop/clientmodel/migrations/0001_initial.py
@@ -1,117 +0,0 @@
-# encoding: utf-8
-import datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
-
- # Adding model 'Client'
- db.create_table('clientmodel_client', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('user', self.gf('django.db.models.fields.related.OneToOneField')(related_name='client', unique=True, to=orm['auth.User'])),
- ('date_of_birth', self.gf('django.db.models.fields.DateField')(null=True, blank=True)),
- ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
- ))
- db.send_create_signal('clientmodel', ['Client'])
-
- # Adding model 'Country'
- db.create_table('clientmodel_country', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
- ))
- db.send_create_signal('clientmodel', ['Country'])
-
- # Adding model 'Address'
- db.create_table('clientmodel_address', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('user_shipping', self.gf('django.db.models.fields.related.OneToOneField')(blank=True, related_name='shipping_address', unique=True, null=True, to=orm['auth.User'])),
- ('user_billing', self.gf('django.db.models.fields.related.OneToOneField')(blank=True, related_name='billing_address', unique=True, null=True, to=orm['auth.User'])),
- ('address', self.gf('django.db.models.fields.CharField')(max_length=255)),
- ('address2', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
- ('zip_code', self.gf('django.db.models.fields.CharField')(max_length=20)),
- ('city', self.gf('django.db.models.fields.CharField')(max_length=20)),
- ('state', self.gf('django.db.models.fields.CharField')(max_length=255)),
- ('country', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['clientmodel.Country'], null=True, blank=True)),
- ))
- db.send_create_signal('clientmodel', ['Address'])
-
-
- def backwards(self, orm):
-
- # Deleting model 'Client'
- db.delete_table('clientmodel_client')
-
- # Deleting model 'Country'
- db.delete_table('clientmodel_country')
-
- # Deleting model 'Address'
- db.delete_table('clientmodel_address')
-
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'clientmodel.address': {
- 'Meta': {'object_name': 'Address'},
- 'address': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'address2': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
- 'city': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
- 'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['clientmodel.Country']", 'null': 'True', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'state': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'user_billing': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'billing_address'", 'unique': 'True', 'null': 'True', 'to': "orm['auth.User']"}),
- 'user_shipping': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'shipping_address'", 'unique': 'True', 'null': 'True', 'to': "orm['auth.User']"}),
- 'zip_code': ('django.db.models.fields.CharField', [], {'max_length': '20'})
- },
- 'clientmodel.client': {
- 'Meta': {'object_name': 'Client'},
- 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
- 'date_of_birth': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'client'", 'unique': 'True', 'to': "orm['auth.User']"})
- },
- 'clientmodel.country': {
- 'Meta': {'object_name': 'Country'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- }
- }
-
- complete_apps = ['clientmodel']
View
2  shop/tests/order.py
@@ -5,7 +5,7 @@
from django.test.testcases import TestCase
from shop.cart.modifiers_pool import cart_modifiers_pool
from shop.models.cartmodel import Cart, CartItem
-from shop.clientmodel.models import Address, Country
+from shop.addressmodel.models import Address, Country
from shop.models.ordermodel import Order, OrderItem, ExtraOrderPriceField, \
OrderPayment
from shop.models.productmodel import Product
View
14 shop/tests/payment.py
@@ -5,7 +5,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.test.testcases import TestCase
from shop.backends_pool import backends_pool
-from shop.clientmodel.models import Address, Client, Country
+from shop.addressmodel.models import Address, Country
from shop.models.ordermodel import Order, OrderItem, ExtraOrderItemPriceField, \
ExtraOrderPriceField
from shop.payment.backends.pay_on_delivery import PayOnDeliveryBackend
@@ -110,10 +110,6 @@ def setUp(self):
last_name = "Toto")
self.user.save()
- self.client = Client()
- self.client.user = self.user
- self.client.save()
-
self.country = Country.objects.create(name='CH')
self.address = Address()
@@ -148,8 +144,8 @@ def setUp(self):
ship_address = self.address
bill_address = self.address2
- self.order.shipping_name = "%s %s" %(self.address.client.user.first_name,
- self.address.client.user.last_name)
+ self.order.shipping_name = "%s %s" %(self.user.first_name,
+ self.user.last_name)
self.order.shipping_address = ship_address.address
self.order.shipping_address2 = ship_address.address2
@@ -157,8 +153,8 @@ def setUp(self):
self.order.shipping_state = ship_address.state
self.order.shipping_country = ship_address.country.name
- self.order.shipping_name = "%s %s" %(self.address.client.user.first_name,
- self.address.client.user.last_name)
+ self.order.shipping_name = "%s %s" %(self.user.first_name,
+ self.user.last_name)
self.order.billing_address = bill_address.address
self.order.billing_address2 = bill_address.address2
self.order.billing_zip_code = bill_address.zip_code
View
2  shop/tests/util.py
@@ -3,7 +3,7 @@
from django.contrib.auth.models import User, AnonymousUser
from django.core.exceptions import ImproperlyConfigured
from django.test.testcases import TestCase
-from shop.clientmodel.models import Address, Country
+from shop.addressmodel.models import Address, Country
from shop.models.cartmodel import Cart
from shop.util.address import get_shipping_address_from_request, \
assign_address_to_request, get_billing_address_from_request
View
14 shop/tests/views_checkout.py
@@ -1,7 +1,7 @@
#-*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.test.testcases import TestCase
-from shop.clientmodel.models import Country, Address
+from shop.addressmodel.models import Country, Address
from shop.models.ordermodel import Order
from shop.tests.util import Mock
from shop.views.checkout import CheckoutSelectionView
@@ -168,12 +168,12 @@ def check_order_address(self):
self.assertEqual(order.shipping_country, self.s_add.country.name)
self.assertEqual(order.billing_name, self.b_add.name)
- self.assertEqual(order.shipping_address, self.b_add.address)
- self.assertEqual(order.shipping_address2, self.b_add.address2)
- self.assertEqual(order.shipping_city, self.b_add.city)
- self.assertEqual(order.shipping_zip_code, self.b_add.zip_code)
- self.assertEqual(order.shipping_state, self.b_add.state)
- self.assertEqual(order.shipping_country, self.b_add.country.name)
+ self.assertEqual(order.billing_address, self.b_add.address)
+ self.assertEqual(order.billing_address2, self.b_add.address2)
+ self.assertEqual(order.billing_city, self.b_add.city)
+ self.assertEqual(order.billing_zip_code, self.b_add.zip_code)
+ self.assertEqual(order.billing_state, self.b_add.state)
+ self.assertEqual(order.billing_country, self.b_add.country.name)
def test_assigning_to_order_from_view_works(self):
view = CheckoutSelectionView(request=self.request)
View
2  shop/util/address.py
@@ -7,7 +7,7 @@
"""
Load the class specified by the user as the Address Model.
"""
-AddressModel = load_class(getattr(settings,'SHOP_ADDRESS_MODEL', None) or 'shop.clientmodel.models.Address')
+AddressModel = load_class(getattr(settings,'SHOP_ADDRESS_MODEL', None) or 'shop.addressmodel.models.Address')
#===============================================================================
# Addresses handling
View
1  tests/testapp/.coveragerc
@@ -2,6 +2,7 @@
branch = True
source =
shop
+ addressmodel
omit =
../../*migrations*
../../*tests*
View
2  tests/testapp/settings.py
@@ -100,7 +100,7 @@
'django.contrib.admindocs',
'polymorphic', # We need polymorphic installed for the shop
'shop', # The django SHOP application
- 'shop.clientmodel',
+ 'shop.addressmodel',
'project', # the test project application
)
Please sign in to comment.
Something went wrong with that request. Please try again.