Commit 3917e42b authored by David Seaward's avatar David Seaward
Browse files

Additional merges from production.


Signed-off-by: David Seaward's avatarDavid Seaward <david.seaward@puri.sm>
parents b9da85cc 47a7dbed
Pipeline #55110 failed with stages
in 2 minutes and 7 seconds
......@@ -7,6 +7,7 @@ docs/api/
categories.json
confusables.json
*.kdev4
scripts/
### Basic template
......
......@@ -17,6 +17,8 @@ logger = get_task_logger(__name__)
def purge_users_pending_cart():
pending_carts = ChosenReward.objects.filter(is_pending=True)
now = timezone.now()
total_pending = len(pending_carts)
count_pending = 0
for pending_cart in pending_carts:
try:
......@@ -30,28 +32,31 @@ def purge_users_pending_cart():
paid = sub is not None
if time_pending.total_seconds() > 60 * 60 * 24 and not paid:
count_pending += 1
# Delete LDAP entry
try:
ldap_user = LdapPerson.objects.filter(uid=username)
ldap_user.delete()
except Exception as e:
logger.exception("Could not delete user {} from LDAP.".format(username))
logger.exception("Could not delete user {} from LDAP.".format(username), e)
# Delete WooCommerce account
try:
user.delete_woocommerce_account()
except Exception as e:
logger.exception("Could not delete user {} from WooCommerce.".format(username))
logger.exception("Could not delete user {} from WooCommerce.".format(username), e)
# Finally delete user
try:
user.delete()
except Exception as e:
logger.exception("Could not delete user {} from Django.".format(username))
logger.exception("Could not delete user {} from Django.".format(username), e)
except Exception as e:
logger.exception("Could not delete pending user {}.".format(username))
logger.exception("Could not delete pending user {}.".format(username), e)
logger.info("Purged {count} of {total} pending users.".format(count=count_pending, total=total_pending))
def import_service_storage_data(service):
......@@ -110,3 +115,4 @@ def import_services_storage_data():
for s in settings.MEASURED_SERVICES:
serv_name = settings.LM_SERVICES.get_name_by_code(s)
import_service_storage_data(serv_name)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment