upload: Add a quota field to Realm.

This commit is contained in:
Vishnu Ks
2017-12-21 04:03:17 +05:30
committed by Greg Price
parent 035d3c5e97
commit fe787c617c
2 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-01-24 20:24
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('zerver', '0136_remove_userprofile_quota'),
]
operations = [
migrations.AddField(
model_name='realm',
name='upload_quota_gb',
field=models.IntegerField(null=True),
),
]

View File

@@ -174,6 +174,8 @@ class Realm(models.Model):
DEFAULT_MAX_INVITES = 100
max_invites = models.IntegerField(default=DEFAULT_MAX_INVITES) # type: int
message_visibility_limit = models.IntegerField(null=True) # type: int
# See upload_quota_bytes; don't interpret upload_quota_gb directly.
upload_quota_gb = models.IntegerField(null=True) # type: int
# Define the types of the various automatically managed properties
property_types = dict(
@@ -257,6 +259,13 @@ class Realm(models.Model):
return self.signup_notifications_stream
return None
def upload_quota_bytes(self) -> Optional[int]:
if self.upload_quota_gb is None:
return None
# We describe the quota to users in "GB" or "gigabytes", but actually apply
# it as gibibytes (GiB) to be a bit more generous in case of confusion.
return self.upload_quota_gb << 30
@property
def subdomain(self) -> Text:
return self.string_id