Mark views as non-atomic if the request method is "safe"
This avoid unnecessary transactions for GET / HEAD / OPTIONS / TRACE
http methods. Also only set ATOMIC_REQUESTS on the default database
(the one used for writes)
This should fix most of our current Django 2.x and DRF deprecation warnings that we see during test runs.
* Uses `remote_field.model` in amo/utils instead of `remote_field.to`
* Uses `is_anonymous` and `is_authenticated` as properties instead of functions
* Replaces drf `@detail_route` with `@action(detail=True)`
Fixes#9432
- Refactor auth register and login to *both* send `user_logged_in` signal
- Use that signal to set `last_login_ip` (django uses it to set `last_login`)
- Also send that signal when authenticating through JWT tokens
- Deprecate the `*_attempt` fields that no longer make sense with FxA auth
Fix#7333
Port code and tests to Django 1.11.
* Update requirements to Django 1.11.14, remove session_csrf
* Use --run-syncdb for migration calls
* Remove unused setup-docker script
* Port code and tests to Django 1.11.
* Remove django-session-csrf everywhere, it got replaced by django's own
session csrf protection
* Make sure we are calling `client.get()` with `follow=True` where necessary
* Replace django.core.urlresolvers import with django.urls
* Port custom `IconWidgetRenderer` to Django 1.11 as `IconTypeSelect`
* Properly use `_queryset_class` for custom manager classes
* Make use of `base_manager_name` on our models `Meta` instead of `use_for_related_objects`
on the manager where appropriate. This is required to make translations, soft-delete
and more work. See comment on Addons.Meta for more details.
* Various fixes along the way to make tests work
* Port form errors for locale editing forms to Django 1.11 and make use of
form.add_error instead of our own custom process
* Mark TestDetailPage.test_304 as xfail for now, somehow Etags seem to be broken
for that view during tests but work fine in manual tests
* Fix amo.celery, we cannot have any imports at the module-level that may
import the ORM
* Fix global_settings context processor for 500-server error cases
* Fix `changed_data` handling in `AMOModelForm`
* Remove `queryset_transform` and implement it directly in amo/models
* Fix pagination, Django changed how `num_pages` work and how `count` can be overwritten
* Add a new test that tests database transforms as `BaseQuerysetTestCase`
* Make sure `legacy_redirect` only appends `?` if there are actual GET parameters
* Re-implement `LicenseRadioChoiceInput` as `LicenseRadioSelect` which is now Django 1.11 compatible
* Remove our custom `form_kwargs` uplift from Django 1.9
* Correct how we're using `Category.objects.create` and only pass `db_name` instead of `name`, previously
this didn't error but now it (luckily!) does
* Update `FileSelectWidget` to correctly work with Django 1.11, use custom rendering
* Fix decorator ordering for `files.views:browse`
* Update database settings to correctly use `TEST` object
* Fix `select_related` call in `RatingViewSet`
* Remove custom `DateTimeCast` implementation
* Fix `addon_factory` calls in `reviewers/tests/test_views.py` to correctly set
`is_webextension`
* Port our `TranslationDescriptor` and `TranslatedField` to Django 1.11. Also, make sure form error handling works
* Add a new test that checks that `default=None` is a valid setting for translation fields
* Add a new test that checks that translations from related fields are correctly fetched
* Remove possible ambiguity from translations `TestWidget` tests
* Make sure that the correct `MEDIA_URL` is set in `TestDownloadsUnlistedVersions` to fix
external cdn tests
* Remove custom happyforms code. Django cleans text fields now by default
* Move translations app to the top of INSTALLED_APPS, add a lengthy comment
* Pass additional arguments to contribute_to_class, fix smaller nits
* Set MEDIA_URL and STATIC_URL to an external value by default. That's how they're configured in dev, stage and prod anyway.
Please note that we didn't replace all our custom form rendering with proper templated widgets yet. This will
happening in some follow-up work.
Fixes#5271, Fixes#1569
Remove ability to edit any collection through the frontend with Collections:Edit permission
Admin:Curation gives you the ability to edit collections owned by mozilla through
the frontend. Anything else (i.e., modifying other collections) must be done
through the admin tools.
I couldn't find *any* usage data for the statistics archive APIs both in
DataDog and NewRelic so I declare them as safe to remove for now.
From what I can tell we don't limit stats lookups in the dashboard as #1416
never got implemented.
This eases our load on EFS and saves money, especially if that data never really got
used.
Let's think about more future-proof stats solutions instead of keeping
all these hacks.
Fixes#1415
Now that we have post-reviewers, content reviewers, legacy reviewers,
we want to get rid of this old decorator and do something a little
more fine-grained
* Add isort to our codebase.
This is the first draft, please feel free to discuss this but I'm
generally open to change that style later on.
I just want to start making more and more of our code-style a rule
instead of something we have to take care of during code reviews.
* Ignore safe_xml file
* Don't change safe_lxml_etree
* Fix import unifification going bonkers, I don't blame isort though, this was creepy.
* Fix signin.test_views
* More flake8
* Use style number 4, hanging grid
* django group only contains django now, move above 3rd party group
* Remove pytest-isort for now to avoid isort being imported during tests.
isort has a super bad module that sets the defaultsystemencoding to
utf-8 and breaks our tests that ensure that our settings are *never*
unicode strings. If the default system encoding is set to utf-8 these
tests just work since the bytestring will be implicitly encoded to utf-8
instead of ascii which is the python2 default.
https://github.com/timothycrosley/isort/blob/develop/isort/pie_slice.py#L145
* Update elasticsearch-dsl from 5.3.0 to 5.4.0
* Remove legacy 'Result' usage.
* There is no such thing as -_score, see elastic/elasticsearch-dsl-py/#458 for more details.
* Unify ESPaginator implementations.
This adds a `legacy_compat_mode` for our old search API but perfectly
applies max-window-result limitation fixes from the new search api.
Fixes#6083Fixes#6053
* Fix flake8
* Fix flake8
* Add documentation, reverse compat argument
* Split up pagination into api.pagination and amo.pagination utils
* Fix another import
* Replace SortedDict with OrderedDict
* Replace get_field_by_name() by get_field()
* Consider warnings as errors to catch DeprecationWarnings
* Upgrade pytest django, since it generates a lot of deprecation warnings
* Ignore DeprecationWarning from django-csp
* Replace old option parsing syntax in management commands
* Replace request.REQUEST with request.POST
* Replace custom sql to create indexes by model options
* Replace get_all_field_names() with get_fields()
* don't keep this
* Try removing the create-db, we're having errors at teardown
* Fix commands args parsing
* Re-consider DeprecationWarnings as errors
* Remove usage of Context()
* Fix DeprecationWarning caused by paypal PaypalError self.message
* Fix linter test using exception.message
* Fix mock to prevent passing a callable to a queryset filter
* Remove reference to non-existent fixture
* django.forms.util module has been renamed. Use django.forms.utils instead
* (WIP) Support zh-hant & zh-hans instead of zh-TW and zh-CN, respectively.
* Don't pass callable to queryset
* ignore jwt deprecation warnings
* Don't use TestCase.urls anymore
* test against exception message directly
* Simplify nested context managers
* Restore this usage of Context(), it's still valid
* Restore setup.cfg
* Revert "(WIP) Support zh-hant & zh-hans instead of zh-TW and zh-CN, respectively."
This reverts commit 7d82b59850.
* fix flake8
Loads of clean-ups along the way.
Fixes#1573
* Moves all helpers modules to templatetags.jinja_helpers - there are a few things in there that aren't jinja related so there'll be a follow-up to split that later
* Update Jinja2 to 2.9.6
* Add django-jinja 2.3.1
* move some jingo-minify helpers to olympia.lib to avoid any jingo imports
* unified |f and |fe helpers into one |format_html helper that always escapes everything unless the input is already |safe
* Move helpers, add requirements, fix imports.
* Give backend a proper name
* Port f and fe filters from jingo
* Make start porting reviews jinja helpers module, make first test pass
* Get a handful more tests working, get rid of get_env, more and more jingo calls.
* Disable extension matching, render .txt templates too, fixes more stats tests
* Fix csv_header template to produce some reasonable and csv parsable
* Set trim_blocks to be compatible with jingo
* Unify |f and |fe into one |format that simplifies escaping rules. Update tests.
I think having one unified |format filter is beneficial, especially
given that our current escaping rules were kinda complicated and allowed
for seriously dangerous combinations even with autoescape activated.
Now everything passed as an argument to |format is explicitly escaped
unless marked as |safe, there's no way around that anymore.
* Naive first version using |format instead of |f and |fe, might need more review.
* Fix format for unicode strings
* Rename |format to |format_html
* Move nl2br_xhtml to amo.jinja_helpers, use it in all our templates.
* Move datetime filter to our code temporarily, fix mocks, fix recursive error
* Move csrf call to django_jinja csrf_token tag, fix addons templatetags
* Fix |class_selected usage, fix render_with to get registered
* Remove hack from zadmin, fix zadmin templatetags
* Fix user delete photo test, don't rely on proper context updates that happen in order.
* Fix more nl2br tests
* Fix detail page escape, django escapes differently than jinja
* Remove context from edit_review_reply_form
* Fix date created format filter usage
* Remove templates setting user, fix can_review
* Fix collect_add_widget to not inherit the global context
* Remove happy unicode client
* Cleanup can_review, add tests
* Fix tests, django use different html character for double quote escaping
* Switch to firefox latest to check ui-tests
* Cleanup and fix do_truncate
* Remove jingo, copy jingo-minify helpers that depend on jingo to our lib for now
* Rename nl2br_xhtml -> nl2br
* Jinja 2.9 compat for reviews truncate filter
* Don't use TEMPLATE_DEBUG
* Set default value for q, happens on index page.
* Fix jinja2 formatting with newstyle gettext
* Replace BaseTestCase usage with our TestCase in tests that need the db
* BaseTestCase does not mock ES, but those tests can trigger ES requests
by doing saves.
* Use Q instead of F
* Start getting the first few tests working
* Upgrade elasticsearch libs to latest versions
* Attempt to fix mapping deprecation warnings, stored fields, and how filters work
* Fix get_es_filter
* Temporary fixes and debugs to get more tests to pass
* Enable custom index settings again
* Add comment, questioning custom index settings
* Fix addons.test_indexers
* Fix stats mapping
* Fix result hit passing around the system
* Fix search filter tests
* Make sure all changes are properly flushed before emptying the index
* Explicitly refresh after creating a new add-on in filter_by_category
* Try and fix tags boosting, this is untested though...
* Start fixing filtered referencing tests...
* Fix fields vs source, es5 only allows returning fields via _source unless they're explicitly stored in the mapping which is not recommended.
* More type: phrase -> match_phrase
* Fix ListSearchResults hit flattening
* Fix 'and' filters
* Fix source filtering for .values_dict()
* Improve debugging, fix source filtering, fix multiple filter handling
* Fix tag boosting in legacy search views.
* Implement explicit query extension to implement tag matching.
* Fix test_and
* Correctly retrieve stored fields in zadmin compat_results
* Make stats views compatible with new es API.
* Fix view themes with new ES API
* Fix elasticsearch commands, reindex and tests
* Fix reindex cron
* Fix test for fuzzy matching.
* We had prefix_length=4 since ages but apparently it didn't work as expected?
* Fix extra_filter_or
* Lots of test fixes to amo.test_search
* Fix compatibility report tests by calling setUp() properly
* Don't nest tags boost in another list
* Fix legacy api test. There is only one add-on matching 'Firefox' but two matching 'Fox'... don't ask me why this ever worked... probably magic?
* Fix deprecated usage of in, use terms instead.