Issue 64 investigate auto filling games and contributors from itch io#127
Open
Games4Doritos wants to merge 27 commits intomainfrom
Open
Issue 64 investigate auto filling games and contributors from itch io#127Games4Doritos wants to merge 27 commits intomainfrom
Games4Doritos wants to merge 27 commits intomainfrom
Conversation
- Added Jam Model with three attributes: a big positive integer id, a name, and list of integer Game object id's called games Explanation of my approach to the problem: The easy way to I think to automatically fill games is to simply override the Jam model's save() function, so the populating script will automatically run every time a Jam object is saved. This function will send a http GET request to a specific URL, using the object's id as a parameter, which will hopefully return json data that lists all the games submitted to the specific jam. A Game object will be created for each listed game (they contain enough information for a detailed object), and then each of those new object's id's in the database will be appended to the Jam object's 'games' list. This may be a bit naive so we will definitely discuss - Registered the Jam model in admin.py with appropriate attributes - Added a new dependency: the python Requests library (https://requests.readthedocs.io/en/latest/), along with it's own dependencies. This is simply needed to make the http GET request in the save() function. We can look at alternatives as well, I think this is just the common python one.
-Removed Jam model and migration file - Added the id and games attributes from the Jam model as optional attributes to the event model instead. The same save() function in the Jam model has been adjusted and added to the event model, where both fields will be forced to be blank if a valid jam id isn't provided. - Removed Jam model configuration from admin.py
- Removed newest migration's dependency on the deleted Jam migration
…contributors_from_itch_io
…contributors_from_itch_io
…contributors_from_itch_io
- Added more exception handling for the save() function in the Event model, now handling the http GET request as well - Made a helper function called jamFail() to reduce redundancy - Modified how the thumbnails for Game objects are initialised in the save() function, such that each game's image is directly downloaded into the backend by making a GET request to the "cover_url" attribute - Changed help_text parameter for jamID to be more understandable
…contributors_from_itch_io
- Updated save() function for Event model such that every Game object created for a Jam has it's event attribute set to the corresponding Event object being saved
…contributors_from_itch_io
…contributors_from_itch_io
…contributors_from_itch_io
…contributors_from_itch_io
- Updated id of the my migration to the Event model unique to this branch, so it is most recent and thus no merge migration is required - Added logic in the save() function in the Event model, where it will check if the username of each of the contributors for a game is registered in a current SocialMedia object, where it will then create a GameContributor object using the Member object linked to the SocialMedia object
- Corrected spelling for some model attributes
…contributors_from_itch_io
…contributors_from_itch_io
- Made minor changes to models.py to appease flake8 - Renamed the migration that creates the jamID and games fields for the Event model to 0015 as the latest, with the latest merged migration as its dependency. This is to avoid an unnecessary migration merge.
- Added a failsafe for if a Jam's json does have a results key, but the list of results is empty - Added exception handling for downloading and saving a game's cover image - Appeased flake8
…contributors_from_itch_io
…contributors_from_itch_io
- Moved the super().save() function to the top of the Event model save() function, so the Event object itself is saved before the games are autofilled. This was to prevent an error where a created Game linked the Event object as a foreign key before it was saved.
Added super().save() back to every return statement in the Event model's save() function, so the object will be saved at the start and also saved at the end of the save() function so the games and jamID attributes are fully updated
- Switched all instances of the save() function to asave() (asynchronous save) instead. I think this solves some UNIQUE constraint integrity errors from testing
…contributors_from_itch_io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Summary
Added 2 new fields to the Event model, a positive big int called jamID and a JSONfield called games which represents a list of Game object integer id's. These fields allow for Game Jams to be a sort of variant of the Event model. If a jamID is specified, when the Event object is saved, a script will run to automatically create Game and Game Contributor objects from the Jam:
Change Form
Other Information
Related issue