-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add messaging to order (closes #327) #350
Conversation
Yay, very good idea! Messaging is done in a plugin, so this would need to go into a deface override. See this example. |
@@ -40,6 +40,15 @@ def group_id=(group_id) | |||
add_recipients Group.find(group_id).users unless group_id.blank? | |||
end | |||
|
|||
def order_id=(order_id) | |||
@order_id = order_id | |||
unless order_id.blank? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this check?
ad deface) i know, but I wasn't able to get it working :-/ |
What did you try with deface? |
create a file in orders/show folder with similar content of your example |
Ok, I'm trying now with deface - and run into the old bug where |
Oh, and why not making the "x Ordergroups" a messaging link instead of the mail button? This would be in-line with other user names being a link to send a message. |
Yes, that was exactly the error I got. |
That's the title attribute, a hyperlink could go to the messaging screen. |
If I do it that way I get some kind of "layering problem": a create_mail_link_for_ordergroups function should only need a list of order groups as parameter. The message page requires the order_id instead and passing a list of order groups/users via URL does not seam like a perfect solution for me either. |
I like the design pattern that info displayed on the screen is also a way to interact with it. In this way: seeing the ordergroups allows one to do something with it - sending them a message. I think the technical problem of how to create the link is solvable. We can still use the order_id (since that can be used to get the same list of ordergroups). |
7dd849b
to
124f77f
Compare
Thanks for your work! Testing this, I'm a bit confused on the message page, since it shows no addressee. I see a number of options:
|
at least on my installation it adds all recipients to the recipients field. any idea? i had some "browser caching" problems at the beginning too, but they were gone later :-/ |
Ok, I'll try again. The code looks ok in that respect. |
@order_id = order_id | ||
for ordergroup in Order.find(order_id).ordergroups | ||
add_recipients ordergroup.users | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be shorter and more performant
add_recipients Order.find(order_id).ordergroups unless order_id.blank?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly me, that wouldn't work at all. Perhaps another has_many :through
in Order would work, but let's leave it this way :o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I couldn't resist. If you like:
# in app/models/order.rb
has_many :ordergroups, :through => :group_orders
has_many :users_ordered, :through => :ordergroups, :source => :users
# in plugins/messages/app/models/message.rb#order_id=
add_recipients Order.find(order_id).users_ordered if order_id
No description provided.