separate repository from Ajapaik-web for Wikimedia OAUTH and image uploading
> git clone [email protected]:Ajapaik/ajapaik-mwapi.git
> cd ajapaik-mwapi
> python3 -m venv venv
> source venv/bin/activate
> venv/bin/python3 -m pip install --upgrade pip
> pip install -r requirements.txt
> cd src
> cp server/settings/local.example.py server/settings/local.py
- USE_BETA_COMMONS defines if we are using Wikimedia production or Beta-cluster. Use Beta for developing.
- SECRET_KEY value is long random string
- CSRF_TRUSTED_ORIGINS and ALLOWED_HOSTS should match to your hostname if it is other than localhost
- SOCIAL_AUTH* = Oauth1 consumer settings. See My first Django OAuth tool for more info.
- Wikimedia: https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose
- Wikimedia Beta-Cluster: https://meta.wikimedia.beta.wmflabs.org/wiki/meta:Special:OAuthConsumerRegistration/propose
To request changes to the software configuration, the creation of new Beta Cluster wikis or user rights, please file a task in Phabricator. If you are doing more testing then you can request Oauth approval rights to beta cluster for yourself.
- Oauth version: OAuth 1.0a consumer
- Application name: use a name that indicates that you are developing locally
- Leave "This consumer is for use only by " unchecked
- Contact email address: Use a valid email where you can be reached.
- Applicable project: All is fine
- OAuth "callback" URL: http://127.0.0.1:8000/
- Select: Allow consumer to specify a callback in requests and use "callback" URL above as a required prefix.
- Types of grants being requested: (for uploading photos) .* Edit existing pages .* Create, edit, and move pages .* Upload new files .* Upload, replace, and move files
- Public RSA key: You can leave this empty at the moment.
> python manage.py makemigrations webservice
> python manage.py migrate
## Start test server
> python manage.py runserver 8000
Open https://127.0.0.1:8000/ with browser and do OAUTH login.
Making server visible on the public internet. Example only (command needs to be edited to get it working)
> sudo -u username ssh -N -L 8000:127.0.0.1:8000 [email protected] -i /home/username/.ssh/id_rsa
This will show users logged in
> python manage.py userinfo
This will upload one random image from Wikimedia Commons to Beta Commons
> python manage.py uploadtest
> rm src/server/db.sqlite3
> rm -rf src/webservice/migrations/*
> python manage.py makemigrations webservice
> python manage.py migrate