-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added forced cache clearing when T&C or UT&C are updated.
- Loading branch information
Showing
6 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
"""Django Apps Config""" | ||
|
||
# pylint: disable=C1001,E0202,W0613 | ||
|
||
from django.apps import AppConfig | ||
import logging | ||
|
||
LOGGER = logging.getLogger(name='termsandconditions') | ||
|
||
|
||
class TermsAndConditionsConfig(AppConfig): | ||
"""App config for TermsandConditions""" | ||
name = 'termsandconditions' | ||
verbose_name = "Terms and Conditions" | ||
|
||
def ready(self): | ||
import termsandconditions.signals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" Signals for Django """ | ||
|
||
# pylint: disable=C1001,E0202,W0613 | ||
|
||
import logging | ||
from django.core.cache import cache | ||
from django.dispatch import receiver | ||
from .models import TermsAndConditions, UserTermsAndConditions | ||
from django.db.models.signals import post_delete, post_save | ||
|
||
LOGGER = logging.getLogger(name='termsandconditions') | ||
|
||
|
||
@receiver(post_save, sender=UserTermsAndConditions) | ||
@receiver(post_delete, sender=UserTermsAndConditions) | ||
def user_terms_updated(sender, **kwargs): | ||
"""Called when user terms and conditions is changed - to force cache clearing""" | ||
LOGGER.debug("User T&C Updated Signal Handler") | ||
if kwargs.get('instance').user: | ||
cache.delete('tandc.not_agreed_terms_' + kwargs.get('instance').user.username) | ||
|
||
|
||
@receiver(post_save, sender=TermsAndConditions) | ||
@receiver(post_delete, sender=TermsAndConditions) | ||
def terms_updated(sender, **kwargs): | ||
"""Called when terms and conditions is changed - to force cache clearing""" | ||
LOGGER.debug("T&C Updated Signal Handler") | ||
cache.delete('tandc.active_terms_ids') | ||
cache.delete('tandc.active_terms_list') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters