Open bacharakis opened 6 years ago
@alexdor Hello Alex, we are trying to add an HFOSS BooleanInput to the admin console, and then, if it is selected, we'd like to have a method execute that will add 'HFOSS' to the tags of the project. Can you help us with the syntax for executing a method if the BooleanInput is set to true?
Hello @katiehrenchir in order to implement this functionality 2 tasks need to be completed. For the frontend a new boolean field should be added on the src/routes/Admin/components/Projects.tsx file
For the backend, the project model needs to be updated to include a boolean field that indicates whether this project is 'HFOSS' or not (with the default value set to false). In order to achieve that a new column needs to be created at the database and the project model needs to be updated with the new field. Once the model is updated the backend will automatically include the new field on every Get, Post and Put request.
Please let me know if you would like more info about any specific part : )
Ok! We have added the BooleanInput component to the create and edit sections of src/routes/Admin/components/Projects.tsx
<BooleanInput label="HFOSS?" />
and then we also just added this to the backend's Projects.go file
HFOSS bool
json:"HFOSS" db:"HFOSS"
Now we would like to have some code that adds 'HFOSS' to the tags of the Project based upon the value of the HFOSS boolean field
you also need to add a new database migration. You need to create a migration similar to this one migrations/20180830162007_AddTagsToRepos.up.fizz but with the column that you want. You can generate a migration file by running this command buffalo db generate fizz add_hfoss_column_to_projects
We don't want to create a new column for HFOSS in the database, we just want to add or remove the HFOSS tag from the existing Tags based on the BooleanInput value... can this be accomplished with an "action" instead of a database change?
Unfortunately, this can't be done by a simple action. The reason is that tags are parsed automatically by GitHub, if you add a tag (with the current setup) it will be overwritten when the project is fetched from GitHub. Another approach (instead of creating a boolean field in the database) is to create a new column of type array (named AdminTags, or something similar) that would store all the extra tags that an admin wants to add to this project.
How often is the project "fetched"? Is it every time the page is loaded, or only when the project object is created/edited?
Each project is “fetched” approximately once every 30’ from the worker On Thu, 27 Sep 2018 at 21.01, Katie Hrenchir notifications@github.com wrote:
How often is the project "fetched"? Is it every time the page is loaded, or only when the project object is created/edited?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/ossn/fixme/issues/13#issuecomment-425206440, or mute the thread https://github.com/notifications/unsubscribe-auth/AICth6sOewP9snxqdIwIX6xWVIdp4JYZks5ufSBpgaJpZM4W7iWB .
Alex, this is our migration
add_column("projects", "HFOSS", "boolean", {"null": true})
and we added this line to the admin Projects file
<BooleanField source="HFOSS" label="HFOSS?" />
Christos said that the environment should automatically do the migration for us? However, the admin console's projects list now says "No results found" so something about this is wrong, I suspect the migration. I think this added HFOSS to the Projects table, right?
I would suggest to change the migration to
add_column("projects", "HFOSS", "boolean", {"default": false})
In order to run the migration, stop and start the running docket instance
On Thu, 27 Sep 2018 at 21.10, Katie Hrenchir notifications@github.com wrote:
Alex, this is our migration add_column("projects", "HFOSS", "boolean", {"null": true})
and we added this line to the admin Projects file
Christos said that the environment should automatically do the migration for us? However, the admin console's projects list now says "No results found" so something about this is wrong, I suspect the migration. I think this added HFOSS to the Projects table, right?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/ossn/fixme/issues/13#issuecomment-425209438, or mute the thread https://github.com/notifications/unsubscribe-auth/AICth_44u-UeEI6FZ2dOObSBXGhrs5Kmks5ufSK1gaJpZM4W7iWB .
Alex, here is the output: https://pastebin.com/1eXwtCyK
@katiehrenchir could you upload the source code somewhere as well so I can try to see why is the migration not running? (You could push it to your fork of the repo)
Alex, I have pushed the changes to my fork of the backend.
I've left a comment with a possible issue, when you have a look and let me know if it worked : )
@alexdor is this being worked on now?
@siddhant1 no I've left my comments here https://github.com/katiehrenchir/fixme_backend/commit/4fa6636bd25a46b9cae13d1d9ca24ace1041a05b
Add an HFOSS filter on the UI/filters list