Pragati Agrawal
bd9b74436c
org settings: Enable message_retention_days in org settings UI.
...
Since production testing of `message_retention_days` is finished, we can
enable this feature in the organization settings page. We already had this
setting in frontend but it was bit rotten and not rendered in templates.
Here we replaced our past text-input based setting with a
dropdown-with-text-input setting approach which is more consistent with our
existing UI.
Along with frontend changes, we also incorporated a backend change to
handle making retention period forever. This change introduces a new
convertor `to_positive_or_allowed_int` which only allows positive integers
and an allowed value for settings like `message_retention_days` which can
be a positive integer or has the value `Realm.RETAIN_MESSAGE_FOREVER` when
we change the setting to retain message forever.
This change made `to_not_negative_int_or_none` redundant so removed it as
well.
Fixes : #14854
2020-05-08 14:09:31 -07:00
Tim Abbott
a702894e0e
middleware: Stop using X_REAL_IP.
...
The comment was wrong, in that REMOTE_ADDR is where the real external
IP was; X_REAL_IP was the loadbalancer's IP.
2020-05-08 11:40:54 -07:00
Anders Kaseorg
bdc365d0fe
logging: Pass format arguments to logging.
...
https://docs.python.org/3/howto/logging.html#optimization
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-05-02 10:18:02 -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
Mateusz Mandera
2000608a9e
report_error: Fix inaccurate docstring.
...
do_report_error isn't actually below.
2020-03-09 13:54:58 -07:00
Anders Kaseorg
fd7803e7f4
settings: Unset STATIC_ROOT in development.
...
Django’s default FileSystemFinder disallows STATICFILES_DIRS from
containing STATIC_ROOT (by raising an ImproperlyConfigured exception),
because STATIC_ROOT is supposed to be the result of collecting all the
static files in the project, not one of the potentially many sources
of static files.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-24 17:40:31 -07:00
Anders Kaseorg
079ddae4c8
minify-js: Remove; everything has been migrated to Webpack.
...
min/sockjs-0.3.4.min.js is not used.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-03 13:58:21 -07:00
Anders Kaseorg
4e21cc0152
views: Remove unused imports.
...
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-02-02 17:23:43 -08:00
Tim Abbott
142d9cb63f
report: Allow error-reporting views from unauthed users.
...
This should make it possible for blueslip error reports to be sent on
our logged-out portico pages, which should in turn make it possible to
debug any such issues as they occur.
2018-12-16 15:44:48 -08:00
Michael J. Sullivan
d5ee801d60
mypy: Set local_partial_types = True.
...
The daemon implicitly sets this flag, so set it explicitly and fix all
of the type errors.
2018-05-21 22:41:00 -07:00
Tim Abbott
79e8bff8fa
views: Change use of typing.Text to str.
...
This is the first part of a general migration of our typing codebase
to use the simpler `str` for strings.
2018-04-23 18:51:23 -07:00
Aditya Bansal
6c1a50da76
csp_reports: Add endpoint to handle logging of reports sent by clients.
2018-04-11 23:01:13 +05:30
rht
1324d9f000
mypy: Use Python 3 type syntax in zerver/views.
2017-12-30 07:34:05 -05:00
Robert Hönig
0e0a8a2b14
queue processor tests: Call consume by default.
...
This significantly improves the API for queue_json_publish to not be
overly focused on what the behavior of this function should be in our
unit tests.
2017-11-26 11:45:34 -08:00
Tim Abbott
054952a44a
docs: Update links from codebase to point to ReadTheDocs.
2017-11-16 10:53:49 -08:00
rht
a93b7c40a7
zerver: Text-wrap long lines exceeding 110.
2017-11-10 16:29:32 -08:00
neiljp (Neil Pilgrim)
42f5eea61f
mypy: Improve typing of request.pyi (REQ).
...
This expands request.pyi to type-check the arguments passed into REQ.
Tweaked by tabbott to fix the report.py annotations.
2017-11-04 20:26:03 -07:00
Greg Price
68b0a419ec
decorator: Cut a bunch of dead imports of two view decorators.
...
Saw these when grepping for these two decorators; they're actually
more numerous than the surviving use sites are. Cut out the noise.
2017-11-04 19:27:00 -07:00
Tim Abbott
5467296f60
decorators: Use human_users_only more aggressively.
2017-10-27 15:16:13 -07:00
Tim Abbott
1cd017288d
views: Fix imports of REQ/has_request_variables from the wrong place.
...
These were never in zerver/decorator.py, and so it makes sense to
import them zerver/lib/request.py, mostly for ease of finding things.
2017-10-27 15:07:31 -07:00
rht
45e8ce559d
zerver/views: Use python 3 syntax for typing.
2017-10-26 21:58:22 -07:00
derAnfaenger
1792dcbd09
tests: Call real consume method of queue processors.
...
This switches to more real tests for a first batch of
queue_json_publish() calls that don't cause trouble when
used with call_consume_tests=True.
2017-10-26 14:58:03 -07:00
Alena Volkova
5515a075ec
urls: Move the report endpoints to be API-style routes.
2017-10-17 22:05:56 -07:00
Tim Abbott
a466bf8a47
report: Fix handling of reports with no more_info.
2017-10-12 17:38:28 -07:00
Tim Abbott
b3b5d5b7cd
report: Avoid sending raw message content in error reporting.
...
This fixes a violation of Zulip's privacy policies (that error
reporting never contain message content) in the previous commit.
2017-10-11 17:44:05 -07:00
Tim Abbott
ce7ab0474d
error_notify: Add IP address to browser error reports.
...
This should make debugging a bit more convenient when we want to know
which of a user's clients was involved.
2017-10-04 13:46:05 -07:00
Tim Abbott
0744961afe
docs: Add more comprehensive documentation on error reporting.
...
Fixes #2232 .
2017-09-27 19:47:08 -07:00
rht
15ca13c8de
zerver/views: Remove absolute_import.
2017-09-27 10:00:39 -07:00
Tim Abbott
1338c6fa0c
report: Fix path to find webpack bundle source maps.
...
The previous code only worked for release tarballs, which has the
source maps in both places.
2017-08-01 08:55:45 -07:00
Pweaver (Paul Weaver)
5932896ebb
Fix browser error reporting to find webpack source map files.
...
When we switched to using webpack, source map files weren't being
logged in the expected place.
2017-07-28 16:01:23 -07:00
neiljp (Neil Pilgrim)
8611a2cafa
tidying: Combine multiple 'import typing' lines onto one line.
2017-07-16 16:43:21 -07:00
Rishi Gupta
ef532bbbb1
statsd: Change keys to use Realm.string_id instead of domain.
2017-03-13 09:51:02 -07:00
Raghav Jajodia
a3a03bd6a5
mypy: Added Dict, List and Set imports.
...
Fixed mypy errors associated with the upgrade.
2017-03-04 14:33:44 -08:00
Tim Abbott
a1d296b802
report: Use DEVELOPMENT instead of DEBUG setting.
...
This fixes a weird issue where the following sequences of tests would fail:
test-backend
zerver.tests.test_messages.PersonalMessagesTest.test_personal_to_self
zerver.tests.test_report.TestReport.test_report_error
zerver.tests.test_templates.TemplateTestCase.test_custom_tos_template
It appears that all 3 tests are required for the failure.
While it's not entirely clear what the cause is, a very likely factor
is that settings.DEBUG is special, and so changing it at runtime is
likely to cause weird problems like this.
We fix this by replacing it with settings.DEVELOPMENT, which has the
same value in all environments, but doesn't have this problem of being
a special Django thing.
2017-02-28 21:44:41 -08:00
Elliott Jin
7ed10da4ad
test-backend: Raise zerver/views/report.py test coverage to 100%.
2017-02-28 20:06:00 -08:00
Tim Abbott
eeca69cb4b
mypy: Clean up more optional types.
2017-02-10 23:53:44 -08:00
Tim Abbott
e69c4458c6
errors: Use hostname to report deployment.
2017-01-28 13:07:09 -08:00
Tim Abbott
0dd5d6cea0
errors: Separate browser error reporting from backend.
2017-01-27 10:27:41 -08:00
Tim Abbott
dd9e0b8463
errors: Move do_report_error into zerver/lib/.
2017-01-23 23:18:28 -08:00
Juan Verhook
535ce90272
mypy: Convert zerver/views to use typing.Text.
2016-12-26 13:43:09 -08:00
nikolay
abc2ff4a06
pep8: Fix many rule E128 violations.
...
[Tweaked by tabbott to adjust some approaches used in wrapping]
2016-12-03 13:33:31 -08:00
Eklavya Sharma
e0dbaf1031
Use universal_newlines=True in subprocess.check_output.
...
In python 3, subprocess uses bytes for input and output if
universal_newlines=False (the default). It uses str for input and
output if universal_newlines=True.
Since we mostly deal with strings, add universal_newlines=True to
subprocess.check_output.
2016-07-26 12:06:41 -07:00
Taranjeet Singh
10afbc06f9
zerver/views/report.py: Fix line with length greater than 120.
...
zerver/views/report.py: Capture string in temporary variables.
2016-07-18 14:42:39 -07:00
acrefoot
e4ed9195dc
Remove rest_dispatch hack and optimize imports.
...
For a long time, rest_dispatch has had this hack where we have to
create a copy of it in each views file using it, in order to directly
access the globals list in that file. This removes that hack, instead
making rest_dispatch just use Django's import_string to access the
target method to use.
[tweaked and reorganized from acrefoot's original branch in various
ways by tabbott]
2016-06-24 16:11:03 -07:00
Babak
ad895eb690
Annotate zerver/views/report.py.
2016-06-11 18:42:37 -07:00
Tim Abbott
960144a49e
Desupport using uninstantiated REQ with has_request_variables.
...
This makes life difficult for doing static type annotations, and
didn't make the code look that much better anyway.
2016-05-31 07:31:15 -07:00
Tim Abbott
e64a3d0fae
Move reporting views to their own file.
2015-11-24 05:20:37 -08:00