Origami icon indicating copy to clipboard operation
Origami copied to clipboard

Added Functionality to the Modify button

Open Caffetaria opened this issue 6 years ago • 4 comments

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 -

  1. initialised the properties 'modifiedDemoName', 'modifiedDemoDescription', 'modifiedDemoPython', 'modifiedDemoCuda', 'modifiedDemoOS' and 'modifiedDemoSourceCode' in 'this.state'.
  2. updated the database with the changed information in the function modifyProject().
  3. defined functions for each of the newly initialised properties in state. These functions set the the new, changed value to each of the properties.
  4. 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):

screen shot 2018-11-30 at 7 49 24 am

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.

Caffetaria avatar Nov 30 '18 01:11 Caffetaria

@techytushar Thank you so much! I'll work on the fixes and submit again tomorrow. Thanks for the feedback!

Caffetaria avatar Nov 30 '18 17:11 Caffetaria

@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.

Caffetaria avatar Dec 01 '18 12:12 Caffetaria

Hi, I made the following changes in views.py in lines 484 and 485 to get to the source of the problem- screen shot 2018-12-02 at 7 39 39 am

However after modification, in the database, only the name gets updated correctly but the link to source code gets updated with ('u ,') screen shot 2018-12-02 at 7 40 20 am

So the issue appears to be on the Django/Postgres backend and not with what's happening on the React front.

Caffetaria avatar Dec 02 '18 02:12 Caffetaria

@techytushar I have fixed the form validation for now as the other issue seems to be related to the database.

Caffetaria avatar Dec 02 '18 06:12 Caffetaria