Origami
Origami copied to clipboard
Added Functionality to the Modify button
Fix #272 The Modify button on the My Demos page does not work.
Description
On clicking the Modify button of a demo, the previously entered data(which was entered during the time of creation of the demo) is pre-filled. The user can make the necessary changes. If he clicks on the "Click me to modify!" button the changes will be saved. To do this I have made the following changes in Origami/src/components/user/nonghUserProfile.js -
- initialised the properties 'modifiedDemoName', 'modifiedDemoDescription', 'modifiedDemoPython', 'modifiedDemoCuda', 'modifiedDemoOS' and 'modifiedDemoSourceCode' in 'this.state'.
- updated the database with the changed information in the function modifyProject().
- defined functions for each of the newly initialised properties in state. These functions set the the new, changed value to each of the properties.
- written HTML code to display the modified data. Note: Task type cannot be changed due to restrictions in the database.
Reviewers
@techytushar @vpn1997 @RishabhJain2018
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Other
Screenshots (if appropriate):

Checklist:
- [x] My code follows the code style (modified PEP8) of this project.
- [ ] I have updated the documentation accordingly.
- [x] The code has been tested locally.
@techytushar Thank you so much! I'll work on the fixes and submit again tomorrow. Thanks for the feedback!
@techytushar - I researched the issue and it appears that it is related to how Django handles unicode characters. From the documentation:
Django adopts a “lazy” approach to decoding form data. The data in an HttpRequest object is only decoded when you access it. In fact, most of the data is not decoded at all. Only the HttpRequest.GET and HttpRequest.POST data structures have any decoding applied to them. Those two fields will return their members as Unicode data. All other attributes and methods of HttpRequest return data exactly as it was submitted by the client.
In the case of the modify we are calling upon the modifyDeployed.js module which makes a put request (the addDeployed.js module makes a post request.)
Any thoughts or suggestions on how to proceed? For now, I can finish the form validation.
Hi,
I made the following changes in views.py in lines 484 and 485 to get to the source of the problem-
However after modification, in the database, only the name gets updated correctly but the link to source code gets updated with ('u ,')
So the issue appears to be on the Django/Postgres backend and not with what's happening on the React front.
@techytushar I have fixed the form validation for now as the other issue seems to be related to the database.