mirror of https://github.com/zulip/zulip.git
mypy: Change six.text_type to typing.Text in confirmation/models.py.
Example commit for GCI.
This commit is contained in:
parent
c5d3c09a4a
commit
fdae58f96b
|
@ -20,8 +20,7 @@ from django.utils.timezone import now
|
|||
from confirmation.util import get_status_field
|
||||
from zerver.lib.utils import generate_random_token
|
||||
from zerver.models import PreregistrationUser
|
||||
from typing import Optional, Union, Any
|
||||
from six import text_type
|
||||
from typing import Optional, Union, Any, Text
|
||||
|
||||
try:
|
||||
import mailer
|
||||
|
@ -34,7 +33,7 @@ except ImportError:
|
|||
B16_RE = re.compile('^[a-f0-9]{40}$')
|
||||
|
||||
def check_key_is_valid(creation_key):
|
||||
# type: (text_type) -> bool
|
||||
# type: (Text) -> bool
|
||||
if not RealmCreationKey.objects.filter(creation_key=creation_key).exists():
|
||||
return False
|
||||
days_sofar = (now() - RealmCreationKey.objects.get(creation_key=creation_key).date_created).days
|
||||
|
@ -44,11 +43,11 @@ def check_key_is_valid(creation_key):
|
|||
return False
|
||||
|
||||
def generate_key():
|
||||
# type: () -> text_type
|
||||
# type: () -> Text
|
||||
return generate_random_token(40)
|
||||
|
||||
def generate_activation_url(key, host=None):
|
||||
# type: (text_type, Optional[str]) -> text_type
|
||||
# type: (Text, Optional[str]) -> Text
|
||||
if host is None:
|
||||
host = settings.EXTERNAL_HOST
|
||||
return u'%s%s%s' % (settings.EXTERNAL_URI_SCHEME,
|
||||
|
@ -57,7 +56,7 @@ def generate_activation_url(key, host=None):
|
|||
kwargs={'confirmation_key': key}))
|
||||
|
||||
def generate_realm_creation_url():
|
||||
# type: () -> text_type
|
||||
# type: () -> Text
|
||||
key = generate_key()
|
||||
RealmCreationKey.objects.create(creation_key=key, date_created=now())
|
||||
return u'%s%s%s' % (settings.EXTERNAL_URI_SCHEME,
|
||||
|
@ -82,7 +81,7 @@ class ConfirmationManager(models.Manager):
|
|||
return False
|
||||
|
||||
def get_link_for_object(self, obj, host=None):
|
||||
# type: (Union[ContentType, int], Optional[str]) -> text_type
|
||||
# type: (Union[ContentType, int], Optional[str]) -> Text
|
||||
key = generate_key()
|
||||
self.create(content_object=obj, date_sent=now(), confirmation_key=key)
|
||||
return generate_activation_url(key, host=host)
|
||||
|
@ -90,7 +89,7 @@ class ConfirmationManager(models.Manager):
|
|||
def send_confirmation(self, obj, email_address, additional_context=None,
|
||||
subject_template_path=None, body_template_path=None,
|
||||
host=None):
|
||||
# type: (ContentType, text_type, Optional[Dict[str, Any]], Optional[str], Optional[str], Optional[str]) -> Confirmation
|
||||
# type: (ContentType, Text, Optional[Dict[str, Any]], Optional[str], Optional[str], Optional[str]) -> Confirmation
|
||||
confirmation_key = generate_key()
|
||||
current_site = Site.objects.get_current()
|
||||
activate_url = generate_activation_url(confirmation_key, host=host)
|
||||
|
@ -143,7 +142,7 @@ class Confirmation(models.Model):
|
|||
verbose_name_plural = _('confirmation emails')
|
||||
|
||||
def __unicode__(self):
|
||||
# type: () -> text_type
|
||||
# type: () -> Text
|
||||
return _('confirmation email for %s') % (self.content_object,)
|
||||
|
||||
class RealmCreationKey(models.Model):
|
||||
|
|
Loading…
Reference in New Issue