Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the need for a user profile. #3

Open
vandorjw opened this issue Apr 24, 2014 · 1 comment
Open

Remove the need for a user profile. #3

vandorjw opened this issue Apr 24, 2014 · 1 comment

Comments

@vandorjw
Copy link

Currently the model looks like the following:

class Invoice(models.Model):
    user = models.ForeignKey(User)
    currency = models.ForeignKey(Currency, blank=True, null=True)
    address = models.ForeignKey(Address, related_name='%(class)s_set')

What do you think of breaking out the user, currency, and address, and instead, linking Invoice to 'Customer' in the following manner.

class Country(models.Model):
    name = models.CharField( ... )
    ...

class Region(models.Model): # state/province/region
    country = models.ForeignKey(Country)
    ...

class Locality(models.Model): # city/town/hamlet
    region = models.ForeignKey(Region)
    ...

class Address(models.Model):
    locality = models.ForeignKey(Locality)
    ...

class Currency(models.Model):
    country = models.ManyToManyField(Country)
    ...        

class Customer(models.Model):
    address = models.ForeignKey(Address)
    ...

class Invoice(models.Model):
    customer = models.ForeignKey(Customer)

    def address(self):
        return self.customer.address

    def currency(self):
        return self.customer.address.city.state.country.currency

A currency is an attribute of a country. However, a currency has nothing to do with an address. We could even add official_languages as a field to County, and have translations based on that, but it would be difficult to know when to stop. So that being said, maybe it is best to keep currency as a field in invoice.

Let me know what you think.

I forked and made some changes, but won't make a PR until I write test, and make sure everything works.

@simonluijk
Copy link
Owner

I am undecided on this. I would like to see address and currency overridable. I will think about this and get back to you later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants