Skip to content

J0WI/fxoss

 
 

Repository files navigation

FirefoxOS Scaling Website (FXOSS) ================================

Below you will find basic setup and deployment instructions for the FXOSS project. To begin you should have the following applications installed on your local development system:

- Python >= 2.6 (2.7 recommended)
- `pip >= 1.1 <http://www.pip-installer.org/>`_
- `virtualenv >= 1.7 <http://www.virtualenv.org/>`_
- `virtualenvwrapper >= 3.0 <http://pypi.python.org/pypi/virtualenvwrapper>`_
- PostgreSQL >= 9.1.11
- git >= 1.7

Getting Started

To setup your local environment you should create a virtualenv and install the necessary requirements:

mkvirtualenv fxoss -r $PWD/requirements/dev.txt

Then create a local settings file and set your DJANGO_SETTINGS_MODULE to use it:

cp $PWD/project/settings/local.py-dist $PWD/project/settings/local.py

Create the PostgreSQL database and run the initial syncdb/migrate:

createdb fxoss
python manage.py syncdb

Due to extensions to the Page Model, the initial migrations require special attention. This will be resolved in a future version. To migrate the site, you will need to temporarily add the following snippet to projects.settings.base.EXTRA_MODEL_FIELDS:

(
    "mezzanine.pages.models.Page.closing",
    "TextField",  # 'django.db.models.' is implied if path is omitted.
    ("Closing Paragraph",),
    {"default": '', "blank": True},
),
 (
    "mezzanine.pages.models.Page.subtitle",
    "CharField",  # 'django.db.models.' is implied if path is omitted.
    ("Subtitle",),
    {"max_length": 128, "default": '', "blank": True},
)

Next, execute the following:

python manage.py migrate sandstone 0004

Remove the fields from the settings file and continue with the remaing migrations:

python manage.py migrate

You should now be able to run the development server:

python manage.py runserver

Deployment

TODO

Fixtures

Load the default fixtures for the site. Currently, the only fixtures that exist define a Content Authors Group. To run:

python manage.py loaddata fixture_groups.json

Adding Languages

Content translations are managed using django-modeltranslation. Currently selected fields on the Page, RichTextPage, Link, Form and Field models are translated. The current settings are managed in project/translation.py. Because of the way django-modeltranslation manages the translations, adding additional languages requires a migration of the tables related to these models. The migrations for these models is stored in project/migrations and managed by South.

To create a new translation migration simply add the language to the LANGUAGES setting and run:

python manage.py schemamigration pages adding<language> --auto python manage.py schemamigration forms adding<language> --auto

Naming the migrations adding_<language> is not required but the auto-generated names are much more difficult to read and understand.

Unfortunately the default migration files generated by South are also not entirely reliable. You might see errors like:

django.core.exceptions.FieldError: Local field 'title_fr' in class 'Link' clashes with field of similar name from base class 'Page'

RichTextPage, Link and Form models are all extensions of the Page model yet for some reason South tries to add the columns to both base Page table and the subclassed tables. However these additional columns aren't needed. You need to remove references to the Page columns title, description from these models' migrations and frozen ORM references. Once those have been cleaned up you can apply the migrations:

python manage.py migrate pages forms

Be sure that you clean up both the forwards and backwards migrations in case the migration needs to be rolled back.

About

The code for mobilepartners.mozilla.org

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 56.2%
  • Python 29.1%
  • JavaScript 14.7%