plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

Flash messages don't show correct information when posting questions

Open ananyo2012 opened this issue 10 years ago • 11 comments

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before. If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

The Problem

When you post a a question then you get this show flash message Research note published. Get the word out on the discussion lists!. You are posting a question but the flash message states a research note. Try posting a question by going to this link: https://publiclab.org/post?tags=question:question&template=question&redirect=question (login required). You will see a similar behavior. This happens because questions are basically research notes tagged qith a question:foo tag. So the flash messages haven't been updated yet and it shows the previous messages while posting a note. Also flash messages displayed for first time posters should also be updated for questions.

Solution

There are two areas where you will find these messages, the admin_controller and the notes_controller. Here is the line in admin_controller: https://github.com/publiclab/plots2/blob/master/app/controllers/admin_controller.rb#L123. This message can be modified for a question for better clarification. To find whether a node is a question you node to see if it has a question power tag. For that use @node.has_power_tag('question') It returns true for a question.

Now coming to notes_controller these are the lines where the flash messages can be modified for a question:

  • https://github.com/publiclab/plots2/blob/master/app/controllers/notes_controller.rb#L148
  • https://github.com/publiclab/plots2/blob/master/app/controllers/notes_controller.rb#L150
  • https://github.com/publiclab/plots2/blob/master/app/controllers/notes_controller.rb#L188

Here also you need to follow the same way as stated before but changing the messages maybe a bit tricky as it is covered under internationalization so you have to update the text in the config/locales directory. For example:

class NotesController

  ...

  def index
    ...
    @title = I18n.t('notes_controller.research_notes')
    ...
  end

  ...

In the locale config file (https://github.com/publiclab/plots2/tree/master/config/locales/controllers/notes_controller), for each language(e.g. en - English, de - Deutsch) we may have:

#For English locale
en:
  notes_controller:
    research_notes: "Research notes"

Here are the relevant locale files related to notes_controller: https://github.com/publiclab/plots2/tree/master/config/locales/controllers/notes_controller. Find the appropriate areas that effects the flash messages mentioned and edit them.

Steps to Fix

  • [ ] claim this issue with a comment
  • [ ] set up a repository locally and make sure that all tests pass
  • [ ] start a pull request (see contributing to Public Lab software) but mark it as "in progress"
  • [ ] fix the issue following the steps above
  • [ ] try the manual test listed above
  • [ ] Think of appropriate messages that can be used here and confirm by reporting us. You also need to translate the messages in Deutsche wherever required.
  • [ ] make sure all tests pass with rake test
  • [ ] alert someone via either the developers list (see below) to have your pull request merged. This may take a few extra steps depending on when you do it, but we'll help you out!

Please email the developers list (see https://publiclab.org/developers) if you have questions!

ananyo2012 avatar Aug 21 '16 14:08 ananyo2012

@jiteshjha Can you see if any further clarification is required in this as it is also covered under internationalization. Please feel free to edit this.

ananyo2012 avatar Aug 21 '16 14:08 ananyo2012

I added a small Internationalization example -- This reminds me of writing a research note on the whole I18n procedure tonight. Thanks! You may delete these comments now.

jiteshjha avatar Aug 21 '16 14:08 jiteshjha

I would like to do this if possible. Will be my first contribution! =)

neliojrr avatar Sep 29 '16 00:09 neliojrr

That would be great! Please reach out if you need any assistance. Thanks!

On Wed, Sep 28, 2016 at 8:59 PM, Nélio Carneiro [email protected] wrote:

I would like to do this if possible. Will be my first contribution! =)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/718#issuecomment-250343606, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJxvkBmuJc-vhH8U9Z2GJrqeeWRE2ks5quw1ogaJpZM4JpTxF .

jywarren avatar Sep 29 '16 01:09 jywarren

Well... I need a help. When I create a question and then I run has_power_tag('question') return always false. I looked at SQL query generated by has_power_tag('question') and noticed that it consults community_tags and term_data columns, but nothing new was inserted there. Am I doing something wrong?

neliojrr avatar Sep 30 '16 00:09 neliojrr

Uh that shouldn't be the case. has_power_tag('question') should return true for a question. has_power_question() returns a boolean value for a node. If the node is a question it returns true otherwise false. Questions are nothing but nodes that have a question:foo tag. So you see when you call has_power_tag('question') it checks whether the node has a tag name with question: prefix as you can see in the definition here

As for the community_tags table referred by DrupalNodeCommunity Model and the term_data table referred by the DrupalTag model they are used to handle tags. The term_data table is used to store the tagname and the tag id. The community_tags table stores the node id of a node that uses a tag and the corresponding tag id.

ananyo2012 avatar Sep 30 '16 01:09 ananyo2012

Hi, @neliojrr -- how did you create the question? Are you doing it as part of a test?

There's a test for posting a new question here: https://github.com/publiclab/plots2/blob/master/test/functional/notes_controller_test.rb#L280-L290

You could add an assertion to the end of that test, like:

assert_equal flash[:notice], 'What the message should say'

That would fail until your changes to the message are added, then it would pass.

jywarren avatar Sep 30 '16 18:09 jywarren

Ok! All the tests with the new messages are passing... but when I'm doing a manual testing (running local) I still can't see the new messages that I added. I'll show my code than we can discuss about. Thank you.

#865

neliojrr avatar Oct 02 '16 16:10 neliojrr

Great -- i'll check it out there -- note I'm a bit slow at the moment but thanks very much for your work on this!

jywarren avatar Oct 05 '16 01:10 jywarren

Done! Thanks a lot!

jywarren avatar Oct 10 '16 04:10 jywarren

Hi @neliojrr! Thank you again for your valuable contribution to Public Lab. I would like to invite you to join us in a video conference to say a few words about what you contributed and how your experience was. The event is https://publiclab.org/openhour, and it’s coming right up on November 7th, at 1pm EDT which is UTC/GMT -4.

Please feel free to respond here, or else email [email protected], [email protected], [email protected].

ebarry avatar Oct 31 '16 21:10 ebarry