* Standardises spelling for verbose names to only start to not be
title'ized
* Adds missing app_labels
* Orders attributes alphabetically
* Always inherits from parent's Meta class as it's good practice
The main benefit of this is that we relabel dashboard applications to a
format of "<original_app>_dashboard" and thus avoiding name clashes.
We should nonetheless consider moving them into the original app's
namespace, as suggested in #1383.
Only declare Oscar models if they haven't been registered before
This is necessary, as Django 1.7 enforces that a model can only be
registered once. Previously, declaring a model a second time would lead
to the second declaration being silently ignored.
The changes have been automated by this gist:
https://gist.github.com/maikhoepfel/05e047e0205f576da1a6
This commit mostly abstracts away from the app refactor that happened in
Django 1.7. It is modelled after recommendations by @aaugustin.
It also introduces a new model_registered check, which can be used
during initialisation to safely register Oscar's models only if they
haven't been registered by a fork app before. This is necessary as
Django 1.7 enforces that models are only registered once; previously the
second declaration would just be ignored silently. That is why e.g.
"from oscar.apps.catalogue.models import *" would work even if one
declared an own catalogue model.
The test suite brings it's own stock record model for testing. Django
1.7 requires that we only import models from apps in INSTALLED_APPS, so
we need to use it to avoid clashes.
Remove outdated settings and fix test runner warning with Django 1.7
ADMINS and MANAGERS aren't expected by Oscar, so we can safely
remove them. ADMINS and MANAGERS is kept for the sandbox as the hosted
sandbox (latest.oscarcommerce.com) uses the same settings and David
wouldn't get error messages otherwise.
Django 1.7 test runner changes are explained here:
214d1e1b0f/django/core/checks/compatibility/django_1_6_0.py (L17)
tl;dr: Setting it explicitly stops an annoying warning.
This change might need to be re-applied if more migrations get added
before this PR is merged into master.
More changes need to be done regarding migrations; this commit just
moves them out of the way so that Django doesn't pick them up.
Updating alert messages to address vertical spacing. Any alert message with more than one line of content should have each line wrapped in a P tag, the CSS will take care of the rest. Issue #1411
Replace countries.json fixture by management command
I started looking at this because on the mailing list, having the UK as
only shipping country led to confusion. This is mostly due to the
shipping address form hiding the country field if there's only one
country enabled, but all the validation then requiring UK postcodes and
phone numbers.
It's bothered me for a while that we're using a fixture to populate the
countries, which is at risk of becoming stale.
pycountry offers an excellent data source for a list of countries, so I
polished an existing management command to use it to populate the
country database.
This commit has two immediate effects:
* New setups will use a more current country database
* By default, all countries will be marked as shipping countries
pycountry also ships with localised names of the countries, which should
allow us to populate the database with localised country names.
* Added some docstrings because I kept having to look up details
of the implementation
* Removed index on the alpha3 and numeric code because we never use
those fields for lookups
* Turned the numeric field into a CharField as suggested
A thread on the mailing list got me looking into the linking users to
partners views:
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/django-oscar/MVdvLihnNj0/R3eecSabQjsJ
While the PartnerLinkView could programatially create the correct
permission, other parts of the codebase rely on the permission being
there. So this is not addressed, but a few issues I spotted were
remedied:
* PartnerLinkView's methods have been reordered to rough order of
execution
* Use redirect instead of the clunky HttpResponseRedirect
* Don't mark the permission name as translatable, as it's stored in the
database
Notifications are only used for "Back in stock" notifications at the
moment; and those don't set a notification body, only a subject. The
template now shows a generic "Message" line if that's the case instead
of showing an empty body.
Furthermore, the notify_user[s] functions now accept arbitrary kwargs to
set on the Notification model, which allows setting custom fields, and
importantly, the notification body.
Fixes #1407.
This required in passing a variant of our SearchForm. Be careful to not
clash with the 'search_form' context variable that is always passed in.
At least until we've decided what the search field should do; currently
it's entirely separate.
As a nice surprise, sorting results Just Works(tm).
The Haystack search form sways a bit from a regular Django form, and all
we're really interested in is calling .search() on it anyway. So I opted
to not change the view to a FormView, as the form shouldn't really ever
be invalid if not messed with, and there's nothing sensible to do apart
from just showing all results.
I removed load_all() for now and want to do some further investigating
of what a sensible way to proceed is. I suspect load_all would load
the entire (unpaginated!) result set into memory, which might be a bit
much.
Must be a left-over from removed logic, and is not used. It's a bad name
as well, as it really is the primary URL name.
I'm not opposed to views knowing about their primary URL name though.
But if that's implemented, it should tie in with the Application class.
I've slightly refactored the changes introduced in the previous commit.
Removed setting line statuses in the sandbox because for most basic
scenarios, such fine-grained control is probably not necessary. And more
advanced scenarios want a custom pipeline anyway.
Closes #1391.