diff --git a/reddit/cron.py b/reddit/cron.py index bb191b0..a8c42c2 100644 --- a/reddit/cron.py +++ b/reddit/cron.py @@ -7,33 +7,33 @@ from reddit.models import RedditAccount from reddit.api import Inbox class UpdateAPIs(): - """ - Updates all Reddit API elements in the database - """ - @property - def _logger(self): - if not hasattr(self, '__logger'): - self.__logger = logging.getLogger(__name__) - return self.__logger + """ + Updates all Reddit API elements in the database + """ + @property + def _logger(self): + if not hasattr(self, '__logger'): + self.__logger = logging.getLogger(__name__) + return self.__logger - last_update_delay = 604800 - - def job(self): - delta = datetime.timedelta(seconds=self.last_update_delay) + last_update_delay = 604800 + + def job(self): + delta = datetime.timedelta(seconds=self.last_update_delay) - print delta - self._logger.debug("Updating accounts older than %s" % (datetime.datetime.now() - delta)) + print delta + self._logger.debug("Updating accounts older than %s" % (datetime.datetime.now() - delta)) - for acc in RedditAccount.objects.filter(last_update__lt=(datetime.datetime.now() - delta)): - self._logger.info("Updating %s" % acc.username) + for acc in RedditAccount.objects.filter(last_update__lt=(datetime.datetime.now() - delta)): + self._logger.info("Updating %s" % acc.username) - try: - acc.api_update() - except RedditAccount.DoesNotExist: - acc.delete() - else: - acc.save() - time.sleep(.5) + try: + acc.api_update() + except RedditAccount.DoesNotExist: + acc.delete() + else: + acc.save() + time.sleep(.5) class APIKeyParser: @@ -58,14 +58,21 @@ class ProcessValidations(): Grabs all Reddit Mail and processes validations """ + @property + def _logger(self): + if not hasattr(self, '__logger'): + self.__logger = logging.getLogger(__name__) + return self.__logger + def job(self): inbox = Inbox(settings.REDDIT_USER, settings.REDDIT_PASSWD) for msg in inbox: - if not msg.was_comment and msg.new: + if not msg.was_comment: try: acc = RedditAccount.objects.get(username__iexact=msg.author) - if not acc.validated and msg.body == acc.user.username: + if not acc.validated and msg.subject == "Validation: %s" % acc.user.username: + self._logger.info("Validated %s" % acc.user.username) acc.validated = True acc.save() except RedditAccount.DoesNotExist: diff --git a/templates/sso/profile.html b/templates/sso/profile.html index d812d87..8908a17 100644 --- a/templates/sso/profile.html +++ b/templates/sso/profile.html @@ -83,8 +83,7 @@ setup.
This is a list of all your current linked Reddit accounts
{% if redditaccounts %} -To verify your Reddit account, login on Reddit then click -this link and put your Auth username in the message.
+To validate your Reddit account, login on Reddit then click the link next to the account, fill in some text in the message and click send.
| Username | Created Date | Validated | |
|---|---|---|---|
| {{ acc.username }} | {{ acc.date_created }} | -{% if acc.validated %}Yes{% else %}No{% endif %} | +{% if acc.validated %}Yes{% else %}No (Validate){% endif %} |