Know user logged in to Trac project in ITicketChangeListener - trac

i have a plugin in Trac project who send notifications emails when ticket action changed (created, closed, ...)
i want to know the user logged in to Trac to know if i must send or not my notification email.
For Example : i'm a logged in user, i will accept a ticket, so :
the reporter receive notification mail (ok for me)
the owner receive notification mail (ok for me)
i don't want to receive mail (i must know the logged in trac user)
this is my code :
class TicketPostCreateOrUpdateActions(Component):
implements(ITicketChangeListener)
def ticket_changed(self, ticket, comment, author, old_values):
_onw_wsdl = SOAPpy.SOAPProxy("http://xxxxxxxx")
# cas fermeture ou réouverture d'un ticket
if old_values.has_key('status')==1 and old_values['status'] is not ticket['status'] and ticket['reporter'] != ticket['owner']:
_onw_wsdl.TracTicketStatusChanged(ticket.id, ticket['reporter'], ticket['summary'], ticket['milestone'], ticket['status'])
elif old_values.has_key('owner')==1 and old_values['owner'] is not ticket['owner']:
_onw_wsdl.TracTicketReassignationChanged(ticket.id, ticket['owner'], ticket['summary'], ticket['priority'], ticket['description'], 're-affectation')
elif comment:
_onw_wsdl.TracTicketCommentModified(ticket.id, ticket['owner'], ticket['reporter'], ticket['summary'], comment)
thanks for your help

Related

Telegram bot unban command

This is my code to unban a user by replying to a message previously left by the user in the bot. But I also want to implement the /unban id command to be able to unban a user by their id. But I don't know how to do it. Please, help.
#bot.message_handler(commands=["unban"], func=Filters.is_answer)
def unblock(message):
user_id = (
Message.select()
.where(Message.id == message.reply_to_message.message_id)
.get()
.from_
)
try:
Block.select().where(Block.user_id == user_id).get().delete_instance()
bot.send_message(user_id, "you have been unbanned"),
except Block.DoesNotExist:
pass
bot.send_message(
message.chat.id, ("{user_id} has been unbanned").format(user_id=user_id)
)
I thought to just read the entire contents of the /unban command through message.text, but I didn’t see any errors, but the command stopped working

Odoo v8 survey user invitation and number answer per user issue?

I'm trying to use the new version of Odoo Survey and survey_crm but I'm facing the following problems.
In the previous version there is an option of restricting number of answer per user but in this new version there is no such option (may be I don't know yet), however I tried the following:
Quizz mode (check box): I used this but still not working any user has an option to answer twice
In the invitation I used the last option (which is, Send private invitation to your audience(only one response per recipient and per invitation)) but still this option wouldn't prevent user answering more than once b/c of "Test" link in the Kanban view of Survey
when I tried to send any invitation it popups an error saying OpenERP server error even if I successfully configure my outgoing and incoming email server but when i try it again without and modification it sends with out any error.
As in v8 we are getting wizard.survey_id as "survey.survey" object , instead of id. so, override the _get_public_url function as below:
def _get_public_url(self, cr, uid, ids, name, arg, context=None):
res = dict((id, 0) for id in ids)
survey_obj = self.pool.get('survey.survey')
for wizard in self.browse(cr, uid, ids, context=context):
if isinstance(wizard.survey_id,int):
res[wizard.id] = survey_obj.browse(cr, uid, wizard.survey_id, context=context).public_url
else:
res[wizard.id] = wizard.survey_id.public_url
return res
While Share and Invite by Mail select "Send private invitation to your audience (only one response per recipient and per invitation)" option so that it sends a unique link for each contact and you can able to see those linked Tokens in Answers.
One more thing, these links won't work until and unless the Odoo server start with db-filter option(if multiple databases are present). Because, with these links data base name is not present. So, if we click on these generated links it returns an Error like "This webpage is not available".

how to show notify to current account if this account is logged in another computer

I have a windows application and it connected to a server via WCF services, database is on the server. To using this software, you have to login. So I want to show a notify to UserA, who is working on the software, if UserA's account is logged (on another computer) by another people.
Please help !
Make your logon service operation on the service return a flag which indicates if this account is being used concurrently by another user.
// Pseudocode
LogonResponse response = Service.Logon :> username, password;
if response.UserAccountIsAlreadyLoggedOn print "User logged on already!"
To do this the service would have to persist the logged-on state of all users, probably in the database.
Your logon service operation would need to query the logged-on state of the user account being presented by the operation caller.
// Pseudocode
public LogonResponse Logon (string username, string password)
{
if database.IsThisAccountAlreadyLoggedOn :> username ?
return LogonResponse :> UserAccountIsAlreadyLoggedOn = true;
otherwise
return LogonResponse :> UserAccountIsAlreadyLoggedOn = false;
}
This is the easiest way I can think of to proceed with this.

how to process incoming mails using mailman and update them into the database

am developing ruby on rails3 application where i am sending an email to user and if user replies that email then that reply content, date should be updated to the database. For this i have ProductComment model. when admin sends comment to the user it will be stored in the database. if user replies to that then database should be updated accordingly. I am trying to use mailman. I have installed the gem. But am not getting how to get the comment id, what should i write in replyto address, where to write the mailman code and from which mail i should read.
Am sending email like this:
mail(:to => #user.email, :subject => "Edit Your Product", :reply_to=>"abc#syz.com)
I am handling it in products controller like this:
require 'mailman'
Mailman::Application.run do
to 'abc#xyz.com' do
ProductComment.create(message)
end
end
Please help me to come out from this problem
Please tell me how to use mailman gem in ruby on rails3 application
there is a recent pro-episode on receiving emails with mailman on railscasts: http://railscasts.com/episodes/313-receiving-email-with-mailman
chmod +x script/mailman_server
cat mailman_test.eml | script/mailman_server
script/mailman_server
-
# script/mailman_server
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "mailman"
Mailman.config.logger = Logger.new("log/mailman.log")
Mailman.config.pop3 = {
server: 'pop.gmail.com', port: 995, ssl: true,
username: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
Mailman::Application.run do
default do
begin
Ticket.receive_mail(message)
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving message:\n#{message}"
Mailman.logger.error [e, *e.backtrace].join("\n")
end
end
end
-
def self.receive_mail(message)
ticket_id = message.subject[/^Update (\d+)$/, 1]
if ticket_id.present? && Ticket.exists?(ticket_id)
Ticket.update(ticket_id, body: message.body.decoded)
else
Ticket.create subject: message.subject, body: message.body.decoded, from: message.from.first
end
end
Postmark Inbound is a good choice. Setup like so:
Sign up for Postmark, they will give you an email which Postmark will assign to your account.
Sign up for Google Apps branded Gmail for your domain. Set up forwarding from an account to the Postmark email address. People can now email reply#yourdamin.com, and it will be forwarded to Postmark.
Create a callback URL. When Postmark receives an email it will package it up and post it to your callback. You can then access the email attributes via the params hash.
To implement replying to messages, simply add a reply to field to your outgoing message which contains a unique hash for the message, e.g.
reply+uniquehash#yourdomain.com.
This is a legal email address, and will be sent to reply#yourdomain.com. You can then parse out the hash in your callback and use it to match the reply to the original message.
Simple :)

How to change email address of a user in devise "safely"?

By default, devise uses an email address for sign up and sign in.
But I want that the email address should be allowed to be changed by the user.
If I allow the user to edit the email address, and the user specifies an "incorrect" (i.e. a typo by mistake) email address and then user signs out, and the user also forgets what the typo'ed email was, now the user account is inaccessible by the user!
How to best work around this? (except for creating a separate, unchangeable username field that will always allow user to login)
You can force the user to confirm his account again if he changes his email.
Once, you updated the password of the concerned user, you need to un-confirm the user, and then re-send the confirmation email.
To unconfirm the user :
user = User.find(1)
if user.confirmed?
user.confirmed_at = nil
user.save(:validate => false)
end
To resend the email confirmation :
user = User.find(1)
user.send_confirmation_instructions
Hope this help !
Devise does this out of the box. Here is the info from the initializer:
# If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed new email is stored in
# unconfirmed email column, and copied to email column on successful confirmation.
config.reconfirmable = true
In confirmable module you may see how it works.