rgsoc-teams icon indicating copy to clipboard operation
rgsoc-teams copied to clipboard

Updating comment from /mentors/applications/:id page results in 404

Open kytrinyx opened this issue 7 years ago • 54 comments

When reviewing applications, I am able to successfully create a comment on the mentors/applications/:id page, however when attempting to update the comment it returns a 404.

kytrinyx avatar Feb 28 '18 20:02 kytrinyx

@kytrinyx I would like to work on this issue

stlireri avatar Mar 03 '18 14:03 stlireri

Hey @stlireri, thank you so much for offering to help on this issue!

Since this is a bug that affects this year’s mentor reviewing phase, it would need to be implemented in the next few days.

Would you have time to begin looking into it this weekend? I’d be happy to help you along the way and answer any of your questions if you need help. Feel free to message or ping me!

We also have some other issues that are up for grabs if you’re interested in contributing and are worried about the time pressure 😄 In short, your help is highly appreciated!

hola-soy-milk avatar Mar 03 '18 15:03 hola-soy-milk

thanks @ramonh for offering to help. Am currently having an issue with installations part. am getting a weird error.

stlireri avatar Mar 04 '18 17:03 stlireri

Hi @stlireri, sure thing! What's the error you're getting?

hola-soy-milk avatar Mar 04 '18 17:03 hola-soy-milk

after running "bundle exec rails db:setup", i get this error 'Created database 'rgsocteams_development' FATAL: role "stella_ireri" does not exist Couldn't create database for {"adapter"=>"postgresql", "database"=>"rgsocteams_test", "host"=>"localhost", "min_messages"=>"error"} rails aborted! '

stlireri avatar Mar 04 '18 18:03 stlireri

@stlireri it sounds like you need to run createuser -P -s rgsoc (from the README)

$ createuser -P -s rgsoc
Enter password for new role: rgsoc
Enter it again: rgsoc

Feel free to make the password empty (just hit enter). That's what I usually do locally unless I have production or protected data.

kytrinyx avatar Mar 04 '18 18:03 kytrinyx

Thanks for your help @kytrinyx ! That ought'a do it

hola-soy-milk avatar Mar 04 '18 19:03 hola-soy-milk

Thanks alot @kytrinyx , it finally worked! I can now access the teams app in development.

stlireri avatar Mar 06 '18 20:03 stlireri

Am trying to replicate the error as described by @kytrinyx but i don't seem to find the applications page. Kindly help out @kytrinyx and @ramonh.

stlireri avatar Mar 06 '18 21:03 stlireri

Nice one! I'm glad to see you're up and running.

So if you haven't already, please go through the steps in the Quick start guide.

Take a look at the output after running the command bundle exec rake routes. The URL to have a look at the current list of applications as a mentor is /mentors/applications. You can access this locally by opening localhost:3000/mentors/applications in your browser.

Hope this steers you in the right direction! If you need further help, please let me know and good luck!

hola-soy-milk avatar Mar 06 '18 23:03 hola-soy-milk

when i try to navigate to that URL, i get an error stating project maintainer required . How do i go about this?

stlireri avatar Mar 07 '18 18:03 stlireri

Hey! Right, so the problem here is that your local user isn't maintaining any accepted projects for your local season of RGSoC.

If you take a look at the mentors controller, you'll find this line:

redirect_to '/', alert: "Project maintainer required" unless current_user.project_maintainer?

This right here is what's stopping you from seeing the applications.

Let's take a look at the user model to find the method on this line:

Project.accepted.where(submitter: self).any?

Right, so we need this user to have an accepted project!

If you take a look at the project model you'll see that a project has a submitter and season it belongs to. It also has a state machine, with the default state being proposed.

So what we need is a Project submitted by you, the current user, to be accepted and assigned to the current Season.

There are a few ways to do this:

  • You can create one through the project creation page on your local instance of the teams app
  • You can create one manually by running bin/rails console and creating a Project model manually

Of course, once you do this, you'll probably need some Application records that are applying to work on this new Project! You can do this similarly.

Phew! I hope this wasn't too much at once, and that this gets you back on track! Let me know if I can help you further, please!

hola-soy-milk avatar Mar 07 '18 19:03 hola-soy-milk

thanks @ramonh for the analysis on the flow of the application with regard to the mentors. i now understand it better. meanwhile, tried creating a project via the console and run the following projects = Project.create(name: "Automation Framework", submitter_id: 33, season_id: 1, mentor_name: "tester", mentor_github_handle: "tester", mentor_email: nil, url: nil, description: "a atesting framework", issues_and_features: nil, beginner_friendly: true, aasm_state: "accepted", tags: [], source_url: nil, comments_locked: false, code_of_conduct: nil, requirements: nil, license: nil) but when trying to save the created project by running projects.save , it returns false

stlireri avatar Mar 08 '18 20:03 stlireri

@stlireri after it returns false, go ahead and try puts projects.errors.full_messages, that should tell you why it's failing.

kytrinyx avatar Mar 08 '18 20:03 kytrinyx

great! it worked, i had missed a mentors email which was a required field. Thanks

stlireri avatar Mar 08 '18 20:03 stlireri

Hi @kytrinyx @ramonh i am trying to make an application using my local instance impersonating a student, which fails when i try to save a profile because of the email part. apparently no team has 2 students already so i have to add one to make the team complete.Is it possible to use a student who is already in another team?

stlireri avatar Mar 10 '18 16:03 stlireri

What is the exact error you’re getting when you try to save?

kytrinyx avatar Mar 11 '18 05:03 kytrinyx

HI @stlireri, yes please! Would be good to know the error.

Furthermore, you should be able to re-assign a student from one team to another using either to console or the local teams app itself.

hola-soy-milk avatar Mar 11 '18 12:03 hola-soy-milk

Hey @stlireri before I forget! Have a look at the db/seeds.rb file here.

There you'll find an ApplicationDraft instance that's ready to apply. Maybe you can hop on the console, set the appropriate project and see if you can manually apply it?

Hope this helps!

hola-soy-milk avatar Mar 11 '18 15:03 hola-soy-milk

i was able to use the application draft instance you gave at db/seeds.rb and created an application. now i am unable to find the project the application was submitted with neither can i trace the submitter. The application had the team Team Gensync .when i try to look at the application using either of the students in the team, i get a not part of a team error. How do i edit the same application so that i can get to it via its submitter?

stlireri avatar Mar 11 '18 20:03 stlireri

Hey @stlireri!

Check out the application model, here you'll find that an Application instance is linked to a project.

Try hopping onto the rails console and calling that Application's project (you can also set it here if needed :) )

Hope this helps!

hola-soy-milk avatar Mar 11 '18 22:03 hola-soy-milk

Hi @ramonh , Am still unable to locate an application that's related to a project using the rails console. Am probably missing the right command to issue via the console. i tried running applications = Application.find_by_project_id(7) Application Load (0.5ms) SELECT "applications".* FROM "applications" WHERE "applications"."project_id" = $1 LIMIT $2 [["project_id", 7], ["LIMIT", 1]] but it resulted to nil .
However, from the rails app am able to see under project named Automation Framework with id = 7 , it has one application as first choice although its in draft mode. I am the project maintainer of that project but from mentors/applications its still blank. How do i manoeuvre through all this?

stlireri avatar Mar 13 '18 19:03 stlireri

Hey @stlireri,

Sorry, I was unclear! What I meant was taking that application and setting it's project ID to the project you wish your user is a mentor of, you know what I mean?

That is, you hop on the console and call something like the following:

> application = Application.last
> project = Project.find_by_id(7).
> application.project_id = project.id
> application.save!

Here, the validation might prevent you from saving the Application, but since we're trying to figure this out, you can skip the validations (that is, by passing { validate: false } as an option parameter to the save! call.

Hope this helps!

hola-soy-milk avatar Mar 13 '18 21:03 hola-soy-milk

Finally i got to the error described in the issue.

stlireri avatar Mar 15 '18 20:03 stlireri

Yay! 🎉 Nice one

hola-soy-milk avatar Mar 15 '18 20:03 hola-soy-milk

The error i get when trying to update a mentors comment is No route matches [PATCH] "/mentors/comments". From rake routes i can see that the url matching [PATCH] for mentors comment is mentors_comment_path. Again from the mentors/comments_controller.rb, the update method redirects to mentors_application_path which renders the index and show actions for mentors applications and not mentors comment. Finally from mentors/application/comments view, the form for application comments has a specific url tag thats renders the create action only. Kindly help me understand where i should apply the changes.

stlireri avatar Mar 15 '18 21:03 stlireri

Nice one @stlireri! Nearly there.

Take a look at the form partial for comments. The url attribute of the form is mentors_comments_path, which isn't quite right. We want, in the case of an edit (update), that it be a different URL.

So the question is, how do we distinguish between a new and existing comment? This answer from Stack Overflow might have the answer.

Hope this helps!

hola-soy-milk avatar Mar 15 '18 21:03 hola-soy-milk

Hi @ramonh , I took a look at the stack overflow solution but i haven't implemented it yet. So i have created a new branch from my local repository. Is that all i have to do before i can start editing the form partial for comments file locally?

stlireri avatar Mar 17 '18 18:03 stlireri

Hey @stlireri!

Sounds good, that's right! Have you already made a fork of the repository?

hola-soy-milk avatar Mar 18 '18 14:03 hola-soy-milk

yeah i did fork the repository already here it is.

stlireri avatar Mar 18 '18 15:03 stlireri