Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85614453
Send_Modify_Mail.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Sep 30, 08:16
Size
3 KB
Mime Type
text/x-python
Expires
Wed, Oct 2, 08:16 (2 d)
Engine
blob
Format
Raw Data
Handle
21197081
Attached To
R3600 invenio-infoscience
Send_Modify_Mail.py
View Options
## $Id$
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN.
##
## CDS Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## CDS Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
__revision__
=
"$Id$"
## Description: function Send_Modify_Mail
## This function sends an email saying the document has been
## correctly updated
## Author: T.Baron
## PARAMETERS: addressesMBI: email addresses to which the mail is sent
## fieldnameMBI: name of the file containing the modified
## fields
## sourceDoc: name of the type of document
## emailFile: name of the file containing the email of the
## user
import
os
import
re
from
invenio.config
import
\
CFG_SITE_URL
,
\
CFG_SITE_ADMIN_EMAIL
,
\
CFG_SITE_NAME
,
\
CFG_SITE_SUPPORT_EMAIL
,
\
CFG_SITE_URL
from
invenio.websubmit_config
import
CFG_WEBSUBMIT_COPY_MAILS_TO_ADMIN
from
invenio.mailutils
import
send_email
def
Send_Modify_Mail
(
parameters
,
curdir
,
form
,
user_info
=
None
):
FROMADDR
=
'
%s
Submission Engine <
%s
>'
%
(
CFG_SITE_NAME
,
CFG_SITE_SUPPORT_EMAIL
)
global
sysno
,
rn
if
parameters
[
'emailFile'
]
is
not
None
and
parameters
[
'emailFile'
]
!=
""
and
os
.
path
.
exists
(
"
%s
/
%s
"
%
(
curdir
,
parameters
[
'emailFile'
])):
fp
=
open
(
"
%s
/
%s
"
%
(
curdir
,
parameters
[
'emailFile'
]),
"r"
)
sub
=
fp
.
read
()
fp
.
close
()
sub
=
sub
.
replace
(
"
\n
"
,
""
)
else
:
sub
=
""
# Copy mail to:
addresses
=
parameters
[
'addressesMBI'
]
addresses
=
addresses
.
strip
()
m_fields
=
parameters
[
'fieldnameMBI'
]
type
=
parameters
[
'sourceDoc'
]
rn
=
re
.
sub
(
"[
\n\r
]+"
,
""
,
rn
)
if
os
.
path
.
exists
(
"
%s
/
%s
"
%
(
curdir
,
m_fields
)):
fp
=
open
(
"
%s
/
%s
"
%
(
curdir
,
m_fields
),
"r"
)
fields
=
fp
.
read
()
fp
.
close
()
fields
=
fields
.
replace
(
"
\n
"
,
" | "
)
fields
=
re
.
sub
(
"[|
\n\r
]+$"
,
""
,
fields
)
else
:
fields
=
""
email_txt
=
"Dear Sir or Madam,
\n
%s
%s
has just been modified.
\n
Modified fields:
%s
\n\n
"
%
(
type
,
rn
,
fields
)
if
CFG_SITE_URL
!=
""
and
sysno
!=
""
:
email_txt
+=
"You can check the modified document here:
\n
"
email_txt
+=
"<
%s
/record/
%s
>
\n\n
"
%
(
CFG_SITE_URL
,
sysno
)
email_txt
+=
"Please note that the modifications will be taken into account in a couple of minutes.
\n\n
Best regards,
\n
The
%s
Server support Team"
%
CFG_SITE_NAME
# send the mail
send_email
(
FROMADDR
,
sub
,
"
%s
modified"
%
rn
,
email_txt
,
copy_to_admin
=
CFG_WEBSUBMIT_COPY_MAILS_TO_ADMIN
)
return
""
Event Timeline
Log In to Comment