Welcome to this ReMo Portal documentation!¶
This is the developer’s documentation for ReMo Portal.
About ReMo Portal¶
Mozilla Reps web tools and portal is the next phase of tools for the Mozilla Reps program. Its purpose is to provide the required tools for the day to day operations of the hundreds of Reps signed up in the program. Diversity of the Reps and Geographic distribution are key features of the program and those tools should help unify community practices and tools of mozillians around the world.
To learn more about it and the release schedule visit ReMo Portal project page.
For comments and/or questions about ReMo Portal or this documentation please ping us on #remo-dev.
Contents¶
Installation¶
VirtualEnv Installation¶
Getting your own development environment.
Preparing Your System¶
Prerequisites: You ‘ll need python, virtualenv, pip, git and mysql-server.
For debian based systems:
$ sudo apt-get install python-dev python-pip python-virtualenv git mysql-server libmysqlclient-dev \ libxslt1.1 libxml2 libxml2-dev libxslt1-dev libffi-dev
For other Linux distributions, you can consult the documentation of your distribution.
Build the Environment¶
When you want to start contributing…
Fork the main ReMo repository (https://github.com/mozilla/remo) on GitHub.
Clone your fork to your local machine:
$ git clone git@github.com:YOUR_USERNAME/remo.git remo (lots of output - be patient...)
Create your python virtual environment.:
$ cd remo/ $ virtualenv --no-site-packages venv
Activate your python virtual environment.:
$ source venv/bin/activate
Install development requirements.:
(venv)$ python ./bin/pipstrap.py (venv)$ pip install --require-hashes --no-deps -r requirements/dev.txt
Note
When you activate your python virtual environment ‘venv’ (virtual environment’s root directory name) will be prepended to your PS1.
Note
Since you are using a virtual environment all the python packages you will install while the environment is active, will be available only within this environment. Your system’s python libraries will remain intact.
Configure your local ReMo installation.:
(venv)$ cp env-dist .env
Uncomment the line for DATABASE_URL in .env to point to the localhost hostname.
Setting up a MySQL database for development:
Install the MySQL server. Many Linux distributions provide an installable package. If your OS does not, you can find downloadable install packages on the MySQL site.
Start the mysql client program as the mysql root user:
$ mysql -u root -p Enter password: ........ mysql>
Create a
remo
database:mysql> create database remo character set utf8;
Sync DB.:
(venv)$ ./manage.py migrate --noinput
Create an admin account.
Create your own admin account:
(venv)$ ./manage.py createsuperuser
Update product_details package.
Package product_details provides information about countries. We use it in country selection lists. The information get pulled form mozilla’s SVN, so we need to fetch it at least once. To update run:
(venv)$ ./manage.py update_product_details
Collect static files.
Various packages provide static files. We need to collect them in the STATIC_DIR:
(venv)$ ./manage.py collectstatic
Load demo data (optional).
Depending on what you are going to develop you may need to have some demo data.
To load demo users run (within your virtual env):
(venv)$ ./manage.py loaddata demo_users
To load demo functional areas run:
(venv)$ ./manage.py loaddata demo_functional_areas
To load demo mobilizing expertise run:
(venv)$ ./manage.py loaddata demo_mobilising_skills
To load demo mobilizing learning interests run:
(venv)$ ./manage.py loaddata demo_mobilising_interests
To load demo events run:
(venv)$ ./manage.py loaddata demo_events
To fetch bugzilla bugs run:
(venv)$ ./manage.py fetch_bugs
Note
Fetching bugzilla bug requires a Mozilla Reps Admin account on Bugzilla. Ping nemo-yiannis or tasos on #remo-dev to give you access if your project requires it.
Run tests:
(venv)$ ./manage.py test
Docker Installation¶
Getting your own development environment.
Preparing Your System¶
- You need to install docker in your system. The installation guide covers many operating systems but for now we only support Linux.
- We are using an orchestration tool for docker called docker-compose that helps us automate the procedure of initiating our docker containers required for development. Installation instructions can be found in Compose’s documentation. Version required: 1.0.1 or newer.
Build the Environment¶
When you want to start contributing…
Clone your fork to your local machine:
$ git clone git@github.com:YOUR_USERNAME/remo.git remo (lots of output - be patient...) $ cd remo
Configure your local ReMo installation:
$ cp env-dist .env
Update the product details:
$ docker-compose run web python manage.py update_product_details -f
Create the database tables and run the migrations:
$ docker-compose run web python manage.py migrate --noinput
Create your own admin account:
$ docker-compose run web ./manage.py createsuperuser
Add demo users:
$ docker-compose run web ./manage.py loaddata demo_users
Add demo functional areas:
$ docker-compose run web ./manage.py loaddata demo_functional_areas
Add demo mobilizing expertise:
$ docker-compose run web ./manage.py loaddata demo_mobilising_skills
Add demo mobilizing learning interests:
$ docker-compose run web ./manage.py loaddata demo_mobilising_interests
Add demo events:
$ docker-compose run web ./manage.py loaddata demo_events
Running ReMo¶
Run ReMo:
$ docker-compose up (lots of output - be patient...) or $ docker-compose run --rm --service-ports web (this enables the output of print() on the docker output)
Open the local site and develop!
Run tests:
$ docker-compose run web ./manage.py test
Static files setup¶
Installing LESS Preprocessor¶
Install Node.js for vagrant users
Install prerequisites:
~$ sudo apt-get install g++ libssl-dev build-essential
Download latest Node.js source code (eg.):
~$ wget http://nodejs.org/dist/v0.10.20/node-v0.10.20.tar.gz
Extract source code:
~$ tar -zxf node-v0.10.20.tar.gz
To build Node.js, run inside the extracted folder:
~$ ./configure ~$ make ~$ sudo make install
Note
For other development environments (eg. virtualenv), follow the Node.js installation guide or use your package manager if a package is available.
Install lessc using npm:
~$ sudo npm install -g less
Fire up the development server¶
These are the steps to run locally your development server.
VirtualEnv Installation¶
Start django devserver.
Within your virtual environment you can start django devserver by running:
(venv)$ ./manage.py runserver
Visit our local installation of the ReMo Portal.
You are done! Point Firefox to 127.0.0.1:8000.
Creating demo data using factories¶
In order to populate our development environment with data in an automated way, we have implemented model factories using Factory Boy.
Factory Boy is a fixtures replacement for Python. For more details visit the project’s documentation.
Using factories¶
By default, model factories get instantiated using the associated model fields. On top of that we provide additional attributes to add extra functionality in object creation. For example:
To create a single model object from a factory class (eg.
UserFactory
) use thecreate()
method:user = UserFactory.create()
To create multiple model objects at once (eg. 10) use the
create_batch()
method:users = UserFactory.create_batch(10)
To customize your demo data you can override model attributes (eg.
username
):user = UserFactory.create(username='example')
remo
factory classes¶
Here is the list of the implemented model factories we have in remo
and their associated PostGeneration methods
that help in some complex definitions of our models.
remo.profiles
factory classes¶
UserFactory
groups
: List of strings with group names to add to user groups- (eg.
['Rep', 'Council']
)
UserProfileFactory
functional_areas
: List ofFunctionalArea
objects to add to user functional areasrandom_functional_areas
:Boolean
. PopulatesUserProfile
with random functional areas of random length.initial_council
:Boolean
.UserProfile
object has itself as mentor.
FunctionalAreaFactory
remo.events
factory classes¶
EventFactory
categories
: List ofFunctionalArea
objects to add to event categories.random_categories
:Boolean
AttendanceFactory
remo.reports
factory classes¶
NGReportFactory
ActivityFactory
CampaignFactory
remo.remozilla
factory classes¶
BugFactory
add_cc_users
: List of users to add to bug cc field
remo.voting
factory classes¶
PollFactory
VoteFactory
RadioPollFactory
RadioPollChoiceFactory
RangePollFactory
RangePollChoiceFactory
Factory examples¶
To
create_batch
of users (eg. 10) with random functional areas that belong to the initial councilfrom remo.profiles.tests import UserFactory kwargs = { 'groups': ['Reps', 'Mentor', 'Council'], 'userprofile__random_functional_areas': True, 'userprofile__initial_council': True } users = UserFactory.create_batch(10, **kwargs)
To
create_batch
of past events (eg. 10) with random categories and 10 attendeesfrom remo.events.tests import EventFactory, AttendanceFactory events = EventFactory.create_batch(10, random_categories=True) for event in events: AttendanceFactory.create_batch(10, event=event)
Note
The above script creates new users for
event.owner
,event.attendance.user
and new swag and budget bugs.To
create
a poll with 10 radio and range poll choicesfrom remo.voting.tests import * poll = PollFactory.create() radio_poll = RadioPollFactory.create(poll=poll) range_poll = RangePollFactory.create(poll=poll) radio_poll_choices = RadioPollChoiceFactory.create_batch(10, radio_poll=radio_poll) range_poll_choices = RangePollChoiceFactory.create_batch(10, range_poll=range_poll)
\ Sort by:\ best rated\ newest\ oldest\
\\
Add a comment\ (markup):
\``code``
, \ code blocks:::
and an indented block after blank line