From 11c2b762758bfc1138895900bfc0acf3f5d4a243 Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Fri, 7 Jul 2017 00:28:37 -0700 Subject: [PATCH] confirmation: Remove util.get_status_field and settings.STATUS_FIELDS. Unnecessarily general for our needs. --- confirmation/models.py | 6 ++---- confirmation/settings.py | 2 -- confirmation/util.py | 13 ------------- 3 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 confirmation/util.py diff --git a/confirmation/models.py b/confirmation/models.py index b9a401d696..f80002132f 100644 --- a/confirmation/models.py +++ b/confirmation/models.py @@ -14,7 +14,6 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey from django.utils.timezone import now as timezone_now -from confirmation.util import get_status_field from zerver.lib.send_email import send_email from zerver.lib.utils import generate_random_token from zerver.models import PreregistrationUser, EmailChangeStatus @@ -42,9 +41,8 @@ class ConfirmationManager(models.Manager): return False obj = confirmation.content_object - status_field = get_status_field(obj._meta.app_label, obj._meta.model_name) - setattr(obj, status_field, getattr(settings, 'STATUS_ACTIVE', 1)) - obj.save() + obj.status = getattr(settings, 'STATUS_ACTIVE', 1) + obj.save(update_fields=['status']) return obj return False diff --git a/confirmation/settings.py b/confirmation/settings.py index 092cd04a2b..779141ab52 100644 --- a/confirmation/settings.py +++ b/confirmation/settings.py @@ -7,5 +7,3 @@ from typing import Any, Dict __revision__ = '$Id: settings.py 12 2008-11-23 19:38:52Z jarek.zgoda $' STATUS_ACTIVE = 1 - -STATUS_FIELDS = {} # type: Dict[Any, Any] diff --git a/confirmation/util.py b/confirmation/util.py deleted file mode 100644 index da4cb309ca..0000000000 --- a/confirmation/util.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright: (c) 2008, Jarek Zgoda - -__revision__ = '$Id: util.py 3 2008-11-18 07:33:52Z jarek.zgoda $' - -from django.conf import settings - -def get_status_field(app_label, model_name): - # type: (str, str) -> str - model = '%s.%s' % (app_label, model_name) - mapping = getattr(settings, 'STATUS_FIELDS', {}) - return mapping.get(model, 'status')