mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
upload: Add a quota field to Realm.
This commit is contained in:
20
zerver/migrations/0137_realm_upload_quota_gb.py
Normal file
20
zerver/migrations/0137_realm_upload_quota_gb.py
Normal 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),
|
||||
),
|
||||
]
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user