Congratulations, we have everything installed, now it’s time to start working on the project. Here are some guidelines and scenarios to help you get started.
- MS Windows users: replace
manage.pycommands from the Open-Knesset directory, with the virtualenv activated.
Commits and Pull Requests¶
Make it easier for you and the maintainers, increasing the chances of a pull request getting accepted:
- No big Pull Requests. It makes reviewing and ensuring correctness hard. If possible, break it to smaller commits/pulls, each related to a specific issue.
- Always work on a specific issue from our issue tracker. Open new issue if needed and claim it in the comments.
- Discuss big things in the Open Knesset Developers group.
We need to make sure we’re in sync with changes done by others (upstream).
Please do this every time before you start developing:
Update the code and requirements¶
Enter the Open-Knesset directory, and run:
git pull firstname.lastname@example.org:hasadna/Open-Knesset.git master
Running this command requires having SSH keys registered with github. If you don’t have these, or if you don’t understand what this means and do not want to look it up, you can use:
git pull https://github.com/hasadna/Open-Knesset.git master
If requirements.txt was modified, make sure all of them are installed (no harm running this command even in case of no changes):
pip install -r requirements.txt
We recommend running the pip command from the parent diretory (the
virtualenv’s root), as it may create an
src directory when pulling
packages from git repos. in that case:
`pip install -r Open-Knesset/requirements.txt`
Run migrations and tests¶
./manage.py migrate ./manage.py test # by default the browser tests use firefox - make sure it's installed first ./manage.py test --testrunner=knesset.browser_test_runner.Runner
If there are any failures, contact the other developers in the oknesset-dev group to see if that’s something you should worry about.
See Development Tips for a few bash functions that may help.
- Write tests for everything that you code.
- Keep performance in mind - test the number of db queries your code performs
./manage.py runserverand accessing a page that runs the code you changed. See the output of the dev-server before and after your change.
Adding a field to existing model¶
We use South to manage database schema migrations. The work process is:
- Add the field you want to model SampleModel in app sample_app
- python manage.py schemamigration sample_app –auto this generates a new migration under sample_app/migrations. You should review it to make sure it does what you’ve expected.
- python manage.py migrate runs the migration against the database.
- Don’t forget to git add and commit the migration file.
After you code¶
./manage.py test# make sure you didn’t break anything
./manage.py test --testrunner=knesset.browser_test_runner.Runner# run the browser tests (see Browser testing)
git status# to see what changes you made
git diff filename# to see what changed in a specific file
git add filename# for each file you changed/added.
git commit -m "commit message"
Please write a sensible commit message, and include “fix#: [number]” of the issue number you’re working on (if any).
git push# push changes to git repo
go to github.com and send a “pull request” so your code will be reviewed and pulled into the main branch, make sure the base repo is hasadna/Open-Knesset.