Source.Python Project Manager
This Django app will be used to host Source.Python plugins, sub-plugins, and custom packages.
Want to help develop this application?
If you wish to contribute to this application, follow the instructions below on how to set it up locally.
Local setup
- Clone the repository
- Create a virtual environment
- Some IDEs, like Pycharm, come with tools to automatically create the virtual environment.
- If you have to set it up yourself, there are plenty of online guides to help you.
- We may Docker-ize the app in the future, which will make this a little simpler, but will require you to install/run Docker.
- Log into your virtual environment to complete the rest of these steps.
- Run
pip install -r pip-requirements/local.txt
to install all the Python/Django requirements. - Run the migrate management command to create the tables/columns in your database.
- Run the
create_game_instances
management command to create the Game objects. - Run the createsuperuser management command to create your main user.
- Run the
associate_super_user
management command to associate the Super User you just created with a ForumUser object.- Arguments for the command are:
- username - The username of the Super User.
- forum_id - The user id from the Source.Python forums.
- Arguments for the command are:
- If you want to create a test (non-Super User) User, run the
create_test_user
management command.- Arguments for the command are:
- username - The username of the User.
- password - The password to use for the User.
- forum_id - The user id from the Source.Python forums.
- Arguments for the command are:
- If you want additional users to test with, run the
create_random_users
management command.- Arguments for the command are:
- count - The number of random Users to create.
- Arguments for the command are:
- Run the server using the runserver management command.
- Some IDEs, like Pycharm, have tools to run the server instead of manually running the command in a console window.
Authentication (logging in)
You can log in one of two ways.
- The Django Admin can be used to log in your Super User you created above.
- A simple login page is available (local only) via the
/accounts/login
page.
Either way will allow you to login and view/utilize all the APIs except for the Django Admin. Certain APIs require you to be logged in, whether as a regular user or a Super User.
APIs
Walkable REST APIs
The REST APIs that the frontend will eventually be built off of can be found at /api
. They are walkable, meaning the APIs are laid out before you on each page, so just click a link to navigate to another API. Some will require you to add a Project name to the URL path.
Each REST API should also show a list of filters and ordering fields, along with examples.
GET calls do not require the user to be logged in. POST calls require the user to be logged in. PATCH and DELETE calls require the user to be logged in, as well as be either the owner or a contributor for the Project (ie package/plugin/sub-plugin contributor). DELETE cannot be called on Projects themselves, just on the associated models.
Games
/api/games
- displays the existing games along with their slug and icon
- allows for GET
Packages
/api/packages/projects
- displays all Packages
- allows for GET, POST, and PATCH
- POST not only requires base information for the
, but also information for the first release (ie notes, version, and zip file). - PATCH requires the package to be added to the URL path (ie
/api/packages/packages/
)
/api/packages/contributors/
- displays the contributors for the given
. - allows for GET, POST, and DELETE
- POST and DELETE can only be executed by the owner of the Project
- DELETE requires the id to be added to the URL path (ie
/api/packages/contributors/
)/
/api/packages/games/
- displays all associated games for the given
. - allows for GET, POST, and DELETE
- DELETE requires the id to be added to the URL path (ie
/api/packages/games/
)/
/api/packages/images/
- displays all images for the given
. - allows for GET, POST, and DELETE
- DELETE requires the id to be added to the URL path (ie
/api/packages/images/
)/
/api/packages/releases/
- displays all releases for the given
. - allows for GET and POST
- you cannot currently PATCH or DELETE a release, though the Django Admin does allow for it if a User happens to make a mistake.
/api/packages/tags/
- displays all images for the given
. - allows for GET, POST, and DELETE
- DELETE requires the id to be added to the URL path (ie
/api/packages/tags/
)/
Plugins
- All the same APIs for Packages exist for Plugins (using
plugins
andpackages
and
/api/plugins/paths/
- displays the Sub-Plugin paths allowed for the given
. For instance, GunGame allows for custom Sub-Plugins but requires them to be located in the ../plugins/custom
directory and include a file as/ .py - For example:
../plugins/custom/gg_assists/gg_assists.py
- allows for GET, POST, PATCH, and DELETE
Sub-Plugins
- All the same APIs for Packages exist for Sub-Plugins, though they require the
- For example:
/api/sub-plugins/contributors/
/
Tags
/api/tags
- displays all created tags
- tags are created via the
Project Tag
APIs listed above forPackages
,Plugins
, andSub-Plugins
. - allows for GET
- tags can be black-listed by an Admin/Super User in the Django Admin. due to the black-listing, tags should not be deleted.
Users
/api/users
- displays all created users
- allows for GET
Admin
Since you have created a Super User, you should be able to log into /admin
using your username/password. This will allow you to test the Django Admin functionality if you are working on it.
Statistics
There is also a /statistics
page to display certain statistics for your local environment from a project, user, and download perspective.
User Frontend
Eventually we will be adding /plugins
and /packages
, as well as /plugins/
for a frontend User experience. These all still need built, so if you have Javascript experience and are willing to help out, it would be much appreciated. The first obstacle will be to determine which Javascript framework to use. This really depends on what people know, but Vue or React would be preferred.
Testing
Unit Testing
To run the Django test suite, run pytest
. The output will show you any tests that are failing. It will also show you a list of warnings, which will help with deprecated functionalities that may need updated in the future.
pytest
also creates a coverage report that can be found at htmlcov/index.html
. This report shows where there are gaps in the coverage.
Linting
To run the linters, run prospector
. The output will tell you where there are coding standards violations that need fixed.