Added more error detection to the Reddit app, also moved is_valid to the model

This commit is contained in:
2010-12-21 11:43:02 +00:00
parent b68391bed6
commit 9cc910e78c
3 changed files with 48 additions and 30 deletions

View File

@@ -10,27 +10,6 @@ class RedditAccountAdmin(admin.ModelAdmin):
fields = ('user', 'username', 'validated')
#form = RedditAccountForm
def is_valid(self, obj):
if not obj.date_created:
return False
# Account 3 months old?
if (date.today() - obj.date_created.date()).days >= 90:
return True
# Account created after 9/2/10 and before 13/2/10
if obj.date_created.date() >= date(2010, 2, 9) and obj.date_created.date() <= date(2010, 2, 13):
return True
return False
is_valid.short_description = 'Dreddit Eligible'
is_valid.boolean = True
def save_model(self, request, obj, form, change):
if not obj.pk:
obj.api_update()