tangentlabs/django-oscar — pull request #330 by elbaschid (2012-10-05 01:29:26+00:00)
Title: Add fix for OrderDiscount model when offer deleted

I found a minor issue in the ``OrderDiscount`` model when an offer is deleted. The model does not store the ``offer.name`` and the ``description()`` method breaks when trying to return the name of the offer.

I am not sure if the solution that I am proposing in this PR is appropriate but I think it lines up with the way e.g. addresses are handled in orders as well. I added the ``order_name`` value that is populated on save if not supplied explicitly. This should prevent existing code from breaking.

I also added populating ``voucher_code`` on save when not supplied as an argument to be consistent here. Feel free to remove it if you don't think this is appropriate.

**Additional notes:**

* Auto-generating the south migrations created a bunch of ``alter_column`` commands that don't have anything to do with changes I made. I am not sure if previous changes have not been reflected in the migrations or if there's something wrong with my auto-generation. Feel free to remove the alter statements from the migrations if they are wrong/unnecessary/in the wrong place.

* I added a data migration set for the offer discount field I created. I hope that's appropriate.

* I am not sure if returning an empty string in ``description()`` is the right way to go when no offer name is available but it would render as the string representation of ``None`` otherwise. So I figured it is definitely better than the alternative here.