Anders Kaseorg
e7ed907cf6
python: Convert deprecated Django ugettext alias to gettext.
...
django.utils.translation.ugettext is a deprecated alias of
django.utils.translation.gettext as of Django 3.0, and will be removed
in Django 4.0.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-15 18:01:34 -07:00
Siddharth Asthana
80c9243c6a
support: Create RealmAuditLog when updating sponsorship status.
2021-04-03 08:01:46 -07:00
Siddharth Asthana
233c4d520c
support: Create RealmAuditLog when updating billing_method.
...
This commit also makes acting_user as a mandantory argument and fixes
the tests accordingly.
2021-04-03 08:01:46 -07:00
Siddharth Asthana
44c34cb39a
support: Create RealmAuditLog when approving sponsorship.
2021-04-03 08:01:46 -07:00
Siddharth Asthana
6945ed3587
support: Pass acting_user to attach_discount_to_realm.
2021-04-03 08:01:46 -07:00
Siddharth Asthana
c3f37c2a64
support: Pass acting_user to do_change_plan_type.
...
acting_user is now a mandatory field, so wherever this function is used,
we are passing acting_user as well.
2021-04-03 08:01:46 -07:00
Mateusz Mandera
09fc79f911
actions: Remove realm argument to internal_send_private_message.
...
The argument is redundant.
2021-02-23 15:26:47 -08:00
Anders Kaseorg
6e4c3e41dc
python: Normalize quotes with Black.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00
Anders Kaseorg
11741543da
python: Reformat with Black, except quotes.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00
Vishnu KS
bd2642a7b8
billing: Make attach discount update the current price per license.
2020-12-17 17:09:20 -08:00
Vishnu KS
480288643c
billing: Create calculate_discounted_price_per_license.
2020-12-17 17:09:20 -08:00
Vishnu KS
71efcca679
stripe: Create get_price_per_license function.
2020-12-17 17:09:20 -08:00
Anders Kaseorg
f461a64a6b
i18n: Fix some ineffective calls to ugettext at top level.
...
Translation has no effect when we don’t yet know what language we’re
translating for.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-18 14:31:15 -07:00
Vishnu KS
510efbc1a8
support: Add option to change billing method.
2020-09-28 15:37:49 -07:00
Vishnu KS
dbaea757ae
billing: Create downgrade_at_the_end_of_billing_cycle.
2020-09-28 15:37:49 -07:00
Vishnu KS
b8b2e443bc
stripe: Create void_all_open_invoices.
2020-09-28 15:37:49 -07:00
Vishnu KS
0d30f59c97
billing: downgrade_now -> downgrade_now_without_creating_additional_invoice.
2020-09-28 15:37:49 -07:00
Alex Vandiver
ab4f6b54ea
stripe: Do not log credit card issues as errors.
...
Problems with the card itself should not be logged as errors -- while
perhaps notable in aggregate, they are not worthy of being logged to
Sentry, for instance.
Downgrade these to `info`; continue to log other problems at the
`error` level. This updates tests for this change, and in so doing
corrects a test that does not do its job, due to a missing
`reset_mock`.
2020-09-23 15:29:47 -07:00
Anders Kaseorg
b7b7475672
python: Use standard secrets module to generate random tokens.
...
There are three functional side effects:
• Correct an insignificant but mathematically offensive bias toward
repeated characters in generate_api_key introduced in commit
47b4283c4b4c70ecde4d3c8de871c90ee2506d87; its entropy is increased
from 190.52864 bits to 190.53428 bits.
• Use the base32 alphabet in confirmation.models.generate_key; its
entropy is reduced from 124.07820 bits to the documented 120 bits, but
now it uses 1 syscall instead of 24.
• Use the base32 alphabet in get_bigbluebutton_url; its entropy is
reduced from 51.69925 bits to 50 bits, but now it uses 1 syscall
instead of 10.
(The base32 alphabet is A-Z 2-7. We could probably replace all of
these with plain secrets.token_urlsafe, since I expect most callers
can handle the full urlsafe_b64 alphabet A-Z a-z 0-9 - _ without
problems.)
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-09 15:52:57 -07:00
Anders Kaseorg
61d0417e75
python: Replace ujson with orjson.
...
Fixes #6507 .
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-08-11 10:55:12 -07:00
Anders Kaseorg
60a25b2721
docs: Fix spelling errors caught by codespell.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-08-11 10:23:06 -07:00
Vishnu KS
5b0b1efb15
support: Add functionality to approve sponsorship requests.
...
This should make it much easier to process these requests.
2020-07-24 17:55:38 -07:00
Vishnu KS
4c6350fa4b
billing: Add option to request a sponsorship in /upgrade.
2020-07-01 16:45:38 -07:00
Anders Kaseorg
f2e7076e2a
decorator: Replace type: ignore with cast, avoid Any.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-30 18:58:23 -07:00
Anders Kaseorg
8667e632c8
python: Use isinstance with a tuple for testing multiple types.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-30 18:58:23 -07:00
Anders Kaseorg
b95fc4858d
corporate: Replace unchecked cast calls with assert.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-22 17:11:42 -07:00
Vishnu KS
508ba663dc
billing: Wrap make_end_of_cycle_updates_if_needed with transaction.atomic.
...
Otherwise, the plan would be left in an inconsistent state if one of the
queries fail.
2020-06-18 17:34:03 -07:00
Vishnu KS
cde4486f8c
billing: Support switching from monthly to annual plan.
2020-06-18 17:34:03 -07:00
Anders Kaseorg
f364d06fb5
python: Convert percent formatting to .format for translated strings.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-15 16:24:46 -07:00
Anders Kaseorg
5dc9b55c43
python: Manually convert more percent-formatting to f-strings.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-14 23:27:22 -07:00
Anders Kaseorg
69c0959f34
python: Fix misuse of Optional types for optional parameters.
...
There seems to have been a confusion between two different uses of the
word “optional”:
• An optional parameter may be omitted and replaced with a default
value.
• An Optional type has None as a possible value.
Sometimes an optional parameter has a default value of None, or None
is otherwise a meaningful value to provide, in which case it makes
sense for the optional parameter to have an Optional type. But in
other cases, optional parameters should not have Optional type. Fix
them.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-13 15:31:27 -07:00
Anders Kaseorg
365fe0b3d5
python: Sort imports with isort.
...
Fixes #2665 .
Regenerated by tabbott with `lint --fix` after a rebase and change in
parameters.
Note from tabbott: In a few cases, this converts technical debt in the
form of unsorted imports into different technical debt in the form of
our largest files having very long, ugly import sequences at the
start. I expect this change will increase pressure for us to split
those files, which isn't a bad thing.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 16:45:32 -07:00
Anders Kaseorg
67e7a3631d
python: Convert percent formatting to Python 3.6 f-strings.
...
Generated by pyupgrade --py36-plus.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-10 15:02:09 -07:00
Anders Kaseorg
8dd83228e7
python: Convert "".format to Python 3.6 f-strings.
...
Generated by pyupgrade --py36-plus --keep-percent-format, but with the
NamedTuple changes reverted (see commit
ba7906a3c6
, #15132 ).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-08 15:31:20 -07:00
Vishnu Ks
66b1ad7002
billing: User FREE_TRIAL_DAYS instead of FREE_TRIAL_MONTHS.
2020-05-16 14:52:01 -07:00
Vishnu KS
f1b1bf5a0d
billing: Add support for Zulip Standard free trial.
2020-05-11 17:20:54 -07:00
Vishnu Ks
66a437bbf1
billing: Restrict max licenses to 1000 during upgrade via invoice.
2020-05-11 17:09:49 -07:00
Anders Kaseorg
7271fb68aa
logging: Pass format arguments to unconventionally-named loggers too.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-02 16:37:07 -07:00
Vishnu KS
3f69500765
billing: Rename downgrade_realm_for_deactivation to downgrade_now.
2020-04-28 22:05:49 -07:00
Anders Kaseorg
fead14951c
python: Convert assignment type annotations to Python 3.6 style.
...
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 11:02:32 -07:00
Anders Kaseorg
f8c95cda51
mypy: Add specific codes to type: ignore annotations.
...
https://mypy.readthedocs.io/en/stable/error_codes.html
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 10:46:33 -07:00
Stefan Weil
d2fa058cc1
text: Fix some typos (most of them found and fixed by codespell).
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2020-03-27 17:25:56 -07:00
Vishnu KS
8b24d40585
billing: Create get_current_plan_by_realm helper function.
2020-03-25 10:54:10 -07:00
Vishnu KS
83da23c0d4
billing: Rename get_current_plan to get_current_plan_by_customer.
...
Also add tests.
2020-03-25 10:54:10 -07:00
Vishnu KS
9a2c64f3f4
billing: Create get_customer_by_realm helper function.
2020-03-25 10:54:10 -07:00
Vishnu KS
f8ddab58ba
billing: Downgrade plan to Limited during realm deactivation.
...
The realm would be instantly downgraded to Limited plan when
deactivated. Any extra users that were added in the final month
would not be charged.
2020-03-25 10:54:10 -07:00
Tim Abbott
f83871c182
corporate: Consistently use delivery_email for billing.
...
This is yet another corner case where EMAIL_ADDRESS_VISIBILITY_ADMINS
broke existing code.
2019-11-18 17:02:57 -08:00
Anders Kaseorg
93b1c3d94b
settings: Extract config file functions to a module.
...
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-13 12:38:45 -08:00
Rishi Gupta
0b39263ec0
billing: Rename get_seat_count to get_latest_seat_count.
...
This will help as our billing system becomes more async to accommodate
on-prem billing.
2019-10-21 16:06:18 -07:00
Rishi Gupta
e10361a832
models: Replace is_guest and is_realm_admin with UserProfile.role.
...
This new data model will be more extensible for future work on
features like a primary administrator.
2019-10-06 16:24:37 -07:00