mirror of https://github.com/zulip/zulip.git
Annotate zilencer/models.py and fix str types in zilencer views.
This commit is contained in:
parent
55611cd21a
commit
1f2b3588d2
|
@ -1,26 +1,34 @@
|
|||
from django.db import models
|
||||
from django.db.models import Manager
|
||||
from six import text_type
|
||||
|
||||
import zerver.models
|
||||
|
||||
def get_deployment_by_domain(domain):
|
||||
# type: (text_type) -> Deployment
|
||||
return Deployment.objects.get(realms__domain=domain)
|
||||
|
||||
class Deployment(models.Model):
|
||||
realms = models.ManyToManyField(zerver.models.Realm, related_name="_deployments")
|
||||
is_active = models.BooleanField(default=True)
|
||||
realms = models.ManyToManyField(zerver.models.Realm,
|
||||
related_name="_deployments") # type: Manager
|
||||
is_active = models.BooleanField(default=True) # type: bool
|
||||
|
||||
# TODO: This should really become the public portion of a keypair, and
|
||||
# it should be settable only with an initial bearer "activation key"
|
||||
api_key = models.CharField(max_length=32, null=True)
|
||||
api_key = models.CharField(max_length=32, null=True) # type: text_type
|
||||
|
||||
base_api_url = models.CharField(max_length=128)
|
||||
base_site_url = models.CharField(max_length=128)
|
||||
base_api_url = models.CharField(max_length=128) # type: text_type
|
||||
base_site_url = models.CharField(max_length=128) # type: text_type
|
||||
|
||||
@property
|
||||
def endpoints(self):
|
||||
# type: () -> Dict[str, text_type]
|
||||
return {'base_api_url': self.base_api_url, 'base_site_url': self.base_site_url}
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
# type: () -> text_type
|
||||
|
||||
# TODO: This only does the right thing for prod because prod authenticates to
|
||||
# staging with the zulip.com deployment key, while staging is technically the
|
||||
# deployment for the zulip.com realm.
|
||||
|
|
|
@ -19,12 +19,13 @@ from .error_notify import notify_server_error, notify_browser_error
|
|||
|
||||
import time
|
||||
|
||||
from six import text_type
|
||||
from typing import Dict, Optional, Any
|
||||
|
||||
client = get_redis_client()
|
||||
|
||||
def has_enough_time_expired_since_last_message(sender_email, min_delay):
|
||||
# type: (str, float) -> bool
|
||||
# type: (text_type, float) -> bool
|
||||
# This function returns a boolean, but it also has the side effect
|
||||
# of noting that a new message was received.
|
||||
key = 'zilencer:feedback:%s' % (sender_email,)
|
||||
|
@ -47,16 +48,16 @@ def get_ticket_number():
|
|||
|
||||
@has_request_variables
|
||||
def submit_feedback(request, deployment, message=REQ(validator=check_dict([]))):
|
||||
# type: (HttpRequest, Deployment, Dict[str, str]) -> HttpResponse
|
||||
# type: (HttpRequest, Deployment, Dict[str, text_type]) -> HttpResponse
|
||||
domainish = message["sender_domain"]
|
||||
if get_realm("zulip.com") not in deployment.realms.all():
|
||||
domainish += " via " + deployment.name
|
||||
domainish += u" via " + deployment.name
|
||||
subject = "%s" % (message["sender_email"],)
|
||||
|
||||
if len(subject) > 60:
|
||||
subject = subject[:57].rstrip() + "..."
|
||||
|
||||
content = ''
|
||||
content = u''
|
||||
sender_email = message['sender_email']
|
||||
|
||||
# We generate ticket numbers if it's been more than a few minutes
|
||||
|
|
Loading…
Reference in New Issue