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
f294688157
test_stripe: Add CallableT cast.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-11-10 15:54:27 -08:00
Anders Kaseorg
4e9d587535
python: Pass query parameters as a dict when making GET requests.
...
This provides automatic URL-encoding.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-27 13:47:02 -07: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
Anders Kaseorg
dd48dbd912
docs: Add spaces to “check out”, “log in”, “set up”, “sign up” as verbs.
...
“Checkout”, “login”, “setup”, and “signup” are nouns, not verbs.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-13 15:47:13 -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
b06253049a
stripe: Change `assert_called` to `assert_called_once`.
...
Prefer using `assert_called_once` to protect against places where a
mock might be reused, and in so doing have been previously called,
thus making the second usage of `assert_called` not assert anything of
note.
2020-09-23 15:29:47 -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
0228acf0f5
rest: Add rest_path shortcut for path with rest_dispatch.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-22 10:51:00 -07:00
Anders Kaseorg
5297e4a30a
urls: Use unqualified imports.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-22 10:51:00 -07:00
Anders Kaseorg
e70f2ae58d
rest: Specify rest_dispatch handlers by function, not by string.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-22 10:46:28 -07:00
Anders Kaseorg
faf600e9f5
urls: Remove unused URL names and shorten others.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-22 10:46:28 -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
bef46dab3c
python: Prefer kwargs form of dict.update.
...
For less inflation by Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-03 17:51:09 -07:00
Anders Kaseorg
9048f79e53
test_stripe: Simplify with iterable unpacking.
...
Issue suggested by the flake8-comprehensions plugin, although the
solution is simpler.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg
ab120a03bc
python: Replace unnecessary intermediate lists with generators.
...
Mostly suggested by the flake8-comprehension plugin.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Vishnu KS
d3c7277f77
billing: Show sponsorship message for organization on STANDARD_FREE.
...
Fixes #16180
2020-08-24 18:25:01 -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
Alex Vandiver
2928bbc8bd
logging: Report stack_info on logging.exception calls.
...
The exception trace only goes from where the exception was thrown up
to where the `logging.exception` call is; any context as to where
_that_ was called from is lost, unless `stack_info` is passed as well.
Having the stack is particularly useful for Sentry exceptions, which
gain the full stack trace.
Add `stack_info=True` on all `logging.exception` calls with a
non-trivial stack; we omit `wsgi.py`. Adjusts tests to match.
2020-08-11 10:16:54 -07:00
Anders Kaseorg
219fc36051
stripe_fixtures: Fix incorrectly normalized JSON.
...
JSON does not allow leading zeros.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-08-07 15:05:01 -07:00
Anders Kaseorg
a329b538d2
test_helpers: Fix instrument_url decorator type.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-08-07 10:53: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
d3834f8b9a
emails: Simplify requested by line in sponsorship email.
2020-07-24 17:39:46 -07:00
Vishnu KS
1a1396d07e
support: Show customer plan details in support page.
2020-07-24 17:37:41 -07:00
Vishnu KS
f6cbb9177a
models: Add plan_name attribute to CustomerPlan.
2020-07-24 17:37:41 -07:00
Vishnu KS
67bacd6e31
billing: Don't allow guest users to upgrade.
2020-07-22 16:57:49 -07:00
Vishnu KS
cb01a7f599
billing: Restrict access to billing page to realm owners and billing admins.
2020-07-22 16:57:49 -07:00
Clara Dantas
8b30e03d4b
models.py: Add get_role_name function in UserProfile class.
...
This function returns the name of the user role that we can use
to display in error report emails.
2020-07-21 16:12:16 -07:00
Steve Howell
c44500175d
database: Remove short_name from UserProfile.
...
A few major themes here:
- We remove short_name from UserProfile
and add the appropriate migration.
- We remove short_name from various
cache-related lists of fields.
- We allow import tools to continue to
write short_name to their export files,
and then we simply ignore the field
at import time.
- We change functions like do_create_user,
create_user_profile, etc.
- We keep short_name in the /json/bots
API. (It actually gets turned into
an email.)
- We don't modify our LDAP code much
here.
2020-07-17 11:15:15 -07:00
Mateusz Mandera
dd5349096f
test_stripe: Fix invalid UserProfile creation.
2020-07-15 19:29:24 +02:00
Vishnu KS
108ad84944
billing: Use no-reply address as from_address in sponsorship emails.
2020-07-14 00:36:31 -07:00
Steve Howell
0b65abcdf5
pointer: Remove pointer from UserProfile.
...
Most of the changes here are just that we no
longer need to provide a value for pointer
when we create UserProfile objects.
2020-07-03 13:08:40 +00: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
e883567146
test_stripe: Fix a type: ignore issue.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-23 11:29:54 -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
Vishnu KS
98cd52cc3e
billing: Mention how the licenses are managed in /billing.
2020-06-18 16:30:48 -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
74c17bf94a
python: Convert more percent formatting to Python 3.6 f-strings.
...
Generated by pyupgrade --py36-plus.
Now including %d, %i, %u, and multi-line strings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-14 23:27:22 -07:00
Anders Kaseorg
1ed2d9b4a0
logging: Use logging.exception and exc_info for unexpected exceptions.
...
logging.exception() and logging.debug(exc_info=True),
etc. automatically include a traceback.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-14 23:27:22 -07:00
Anders Kaseorg
0d6c771baf
python: Guard against default value mutation with read-only types.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-13 15:31:27 -07:00