Ecotrust / usvi

1 stars 4 forks source link

fixed bug timestamp bug #326

Closed wraithan closed 10 years ago

wraithan commented 10 years ago

In the save method it was being compensated for in the survey models but the account models didn't have anything in save to fix this. I changed to the preferred django method of using auto_now_add=True on DateTimeField. Below is an example of what is happening and why this is a problem.

import datetime

class Test(object):
    field = datetime.datetime.now()

test1 = Test()
test2 = Test()

print test1.field == test2.field
>>> True

datetime.datetime.now() is being evaluated at class definition time, not instantiation, which is causing it to always be the same value. Also patching Ecotrust/solomon but because the save method was compensating in each case, I felt this was higher priority to send a PR for.