Page MenuHomec4science

youralerts.py
No OneTemporary

File Metadata

Created
Tue, Jun 25, 08:19

youralerts.py

## $Id$
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006 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.
"""PERSONAL FEATURES - YOUR ALERTS"""
__lastupdated__ = """$Date$"""
import sys
import time
import zlib
import urllib
import time
from mod_python import apache
from invenio.config import weburl, sweburl, cdslang, cdsname
from invenio.webpage import page
from invenio import webalert
from invenio.webuser import getUid, page_not_authorized
from invenio.access_control_config import CFG_ACCESS_CONTROL_LEVEL_SITE
from invenio.messages import gettext_set_language
import invenio.template
webalert_templates = invenio.template.load('webalert')
### CALLABLE INTERFACE
def display(req, p="n", ln = cdslang):
uid = getUid(req)
# load the right message language
_ = gettext_set_language(ln)
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "../youralerts.py/display")
return page(title=_("Display searches"),
body=webalert.perform_display(p,uid, ln = ln),
navtrail= """<a class="navtrail" href="%(sweburl)s/youraccount/display">%(account)s</a>""" % {
'sweburl' : sweburl,
'account' : _("Your Account"),
},
description="CDS Personalize, Display searches",
keywords="CDS, personalize",
uid=uid,
language=ln,
req=req,
lastupdated=__lastupdated__)
def input(req, idq, name="", freq="week", notif="y", idb=0, error_msg="", ln = cdslang):
uid = getUid(req)
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "../youralerts.py/input")
# load the right message language
_ = gettext_set_language(ln)
html = webalert.perform_input_alert("add", idq, name, freq, notif, idb,uid, ln = ln)
if error_msg != "":
html = webalert_templates.tmpl_errorMsg(
ln = ln,
error_msg = error_msg,
rest = html,
)
return page(title=_("Set a new alert"),
body=html,
navtrail= """<a class="navtrail" href="%(sweburl)s/youraccount/display">%(account)s</a>""" % {
'sweburl' : sweburl,
'account' : _("Your Account"),
},
description="CDS Personalize, Set a new alert",
keywords="CDS, personalize",
uid=uid,
language=ln,
req=req,
lastupdated=__lastupdated__)
def modify(req, idq, old_idb, name="", freq="week", notif="y", idb=0, error_msg="", ln = cdslang):
uid = getUid(req)
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "../youralerts.py/modify")
# load the right message language
_ = gettext_set_language(ln)
html = webalert.perform_input_alert("update", idq, name, freq, notif, idb, uid, old_idb, ln = ln)
if error_msg != "":
html = webalert_templates.tmpl_errorMsg(
ln = ln,
error_msg = error_msg,
rest = html,
)
return page(title=_("Modify alert settings"),
body=html,
navtrail= """<a class="navtrail" href="%(sweburl)s/youraccount/display">%(account)s</a>""" % {
'sweburl' : sweburl,
'account' : _("Your Account"),
},
description="CDS Personalize, Modify alert settings",
keywords="CDS, personalize",
uid=uid,
language=ln,
req=req,
lastupdated=__lastupdated__)
def list(req, ln = cdslang):
uid = getUid(req)
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "../youralerts.py/list")
# load the right message language
_ = gettext_set_language(ln)
return page(title=_("Display alerts"),
body=webalert.perform_list_alerts(uid, ln = ln),
navtrail= """<a class="navtrail" href="%(sweburl)s/youraccount/display">%(account)s</a>""" % {
'sweburl' : sweburl,
'account' : _("Your Account"),
},
description="CDS Personalize, Display alerts",
keywords="CDS, personalize",
uid=uid,
language=ln,
req=req,
lastupdated=__lastupdated__)
def add(req, name, freq, notif, idb, idq, ln = cdslang):
uid = getUid(req)
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "../youralerts.py/add")
# load the right message language
_ = gettext_set_language(ln)
try:
html=webalert.perform_add_alert(name, freq, notif, idb, idq, uid, ln = ln)
except webalert.AlertError, e:
return input(req, idq, name, freq, notif, idb, e, ln = ln)
return page(title=_("Display alerts"),
body=html,
navtrail= """<a class="navtrail" href="%(sweburl)s/youraccount/display">%(account)s</a>""" % {
'sweburl' : sweburl,
'account' : _("Your Account"),
},
description="CDS Personalize, Display alerts",
keywords="CDS, personalize",
uid=uid,
language=ln,
req=req,
lastupdated=__lastupdated__)
def update(req, name, freq, notif, idb, idq, old_idb, ln = cdslang):
uid = getUid(req)
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "../youralerts.py/update")
# load the right message language
_ = gettext_set_language(ln)
try:
html=webalert.perform_update_alert(name, freq, notif, idb, idq, old_idb,uid, ln = ln)
except webalert.AlertError, e:
return modify(req, idq, old_idb, name, freq, notif, idb, e, ln = ln)
return page(title=_("Display alerts"),
body=html,
navtrail= """<a class="navtrail" href="%(sweburl)s/youraccount/display">%(account)s</a>""" % {
'sweburl' : sweburl,
'account' : _("Your Account"),
},
description="CDS Personalize, Display alerts",
keywords="CDS, personalize",
uid=uid,
language=ln,
req=req,
lastupdated=__lastupdated__)
def remove(req, name, idu, idq, idb, ln = cdslang):
uid = getUid(req)
if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
return page_not_authorized(req, "../youralerts.py/remove")
# load the right message language
_ = gettext_set_language(ln)
return page(title=_("Display alerts"),
body=webalert.perform_remove_alert(name, idu, idq, idb, uid, ln = ln),
navtrail= """<a class="navtrail" href="%(sweburl)s/youraccount/display">%(account)s</a>""" % {
'sweburl' : sweburl,
'account' : _("Your Account"),
},
description="CDS Personalize, Display alerts",
keywords="CDS, personalize",
uid=uid,
language=ln,
req=req,
lastupdated=__lastupdated__)

Event Timeline