forked from ScoDoc/ScoDoc
Port all Entreprise DTML methods to Python
This commit is contained in:
parent
acdda802ab
commit
d6b6ab3ea7
921
ZEntreprises.py
921
ZEntreprises.py
@ -26,23 +26,33 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
""" Gestion des relations avec les entreprises
|
""" Gestion des relations avec les entreprises
|
||||||
|
|
||||||
|
Note: Code très ancien, porté de Zope/DTML, peu utilisable
|
||||||
|
|
||||||
|
=> Voir si des départements utilisent encore ce module et envisager de le supprimer.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import urllib
|
import urllib
|
||||||
|
import string
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
import calendar
|
||||||
|
|
||||||
from sco_zope import *
|
from sco_zope import *
|
||||||
|
from sco_permissions import ScoEntrepriseView, ScoEntrepriseChange
|
||||||
|
|
||||||
# ---------------
|
# ---------------
|
||||||
|
|
||||||
from notesdb import *
|
from notesdb import *
|
||||||
from notes_log import log
|
from notes_log import log
|
||||||
from scolog import logdb
|
from scolog import logdb
|
||||||
from sco_utils import *
|
from sco_utils import SCO_ENCODING
|
||||||
|
import sco_utils as scu
|
||||||
import html_sidebar
|
import html_sidebar
|
||||||
|
import VERSION
|
||||||
|
from gen_tables import GenTable
|
||||||
from TrivialFormulator import TrivialFormulator, TF
|
from TrivialFormulator import TrivialFormulator, TF
|
||||||
import scolars
|
import scolars
|
||||||
import string, re
|
|
||||||
import time, calendar
|
|
||||||
|
|
||||||
|
|
||||||
def _format_nom(nom):
|
def _format_nom(nom):
|
||||||
@ -78,10 +88,19 @@ class EntreprisesEditor(EditableTable):
|
|||||||
sortkey=None,
|
sortkey=None,
|
||||||
sort_on_contact=False,
|
sort_on_contact=False,
|
||||||
ZEntrepriseInstance=None,
|
ZEntrepriseInstance=None,
|
||||||
|
limit="",
|
||||||
|
offset="",
|
||||||
):
|
):
|
||||||
# list, then sort on date of last contact
|
# list, then sort on date of last contact
|
||||||
R = EditableTable.list(
|
R = EditableTable.list(
|
||||||
self, cnx, args=args, operator=operator, test=test, sortkey=sortkey
|
self,
|
||||||
|
cnx,
|
||||||
|
args=args,
|
||||||
|
operator=operator,
|
||||||
|
test=test,
|
||||||
|
sortkey=sortkey,
|
||||||
|
limit=limit,
|
||||||
|
offset=offset,
|
||||||
)
|
)
|
||||||
if sort_on_contact:
|
if sort_on_contact:
|
||||||
for r in R:
|
for r in R:
|
||||||
@ -323,7 +342,7 @@ class ZEntreprises(
|
|||||||
H.append("</ul></div>")
|
H.append("</ul></div>")
|
||||||
|
|
||||||
#
|
#
|
||||||
H.append("""<br/><br/>%s""" % icontag("entreprise_side_img"))
|
H.append("""<br/><br/>%s""" % scu.icontag("entreprise_side_img"))
|
||||||
if REQUEST["_read_only"]:
|
if REQUEST["_read_only"]:
|
||||||
H.append("""<br/><em>(Lecture seule)</em>""")
|
H.append("""<br/><em>(Lecture seule)</em>""")
|
||||||
H.append("""</div> </div> <!-- end of sidebar -->""")
|
H.append("""</div> </div> <!-- end of sidebar -->""")
|
||||||
@ -331,55 +350,835 @@ class ZEntreprises(
|
|||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Entreprises : Methodes en DTML
|
# Entreprises : Vues
|
||||||
#
|
#
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# used to view content of the object
|
|
||||||
security.declareProtected(ScoEntrepriseView, "index_html")
|
security.declareProtected(ScoEntrepriseView, "index_html")
|
||||||
index_html = DTMLFile("dtml/entreprises/index_html", globals())
|
|
||||||
|
def index_html(
|
||||||
|
self, REQUEST=None, etud_nom=None, limit=50, offset="", format="html"
|
||||||
|
):
|
||||||
|
"""Accueil module entreprises"""
|
||||||
|
# Traduit du DTML - utilise table standard
|
||||||
|
if limit:
|
||||||
|
limit = int(limit)
|
||||||
|
if offset:
|
||||||
|
offset = int(offset or 0)
|
||||||
|
|
||||||
|
if etud_nom:
|
||||||
|
entreprises = self.do_entreprise_list_by_etud(
|
||||||
|
args=REQUEST.form, sort_on_contact=True
|
||||||
|
)
|
||||||
|
table_navigation = ""
|
||||||
|
else:
|
||||||
|
entreprises = self.do_entreprise_list(
|
||||||
|
args=REQUEST.form,
|
||||||
|
test="~*",
|
||||||
|
sort_on_contact=True,
|
||||||
|
limit=limit,
|
||||||
|
offset=offset,
|
||||||
|
)
|
||||||
|
# Liens navigation précédent/suivant
|
||||||
|
webparams = {"limit": limit}
|
||||||
|
if offset:
|
||||||
|
webparams["offset"] = max((offset or 0) - limit, 0)
|
||||||
|
prev_lnk = '<a class="stdlink" href="%s">précédentes</a>' % (
|
||||||
|
REQUEST.URL0 + "?" + urllib.urlencode(webparams)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
prev_lnk = ""
|
||||||
|
if len(entreprises) >= limit:
|
||||||
|
webparams["offset"] = (offset or 0) + limit
|
||||||
|
next_lnk = '<a class="stdlink" href="%s">suivantes</a>' % (
|
||||||
|
REQUEST.URL0 + "?" + urllib.urlencode(webparams)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
next_lnk = ""
|
||||||
|
table_navigation = (
|
||||||
|
'<div class="table_nav"><span class="table_nav_prev">'
|
||||||
|
+ prev_lnk
|
||||||
|
+ '</span><span class="table_nav_mid"></span><span class="table_nav_next">'
|
||||||
|
+ next_lnk
|
||||||
|
+ "</span></div>"
|
||||||
|
)
|
||||||
|
# Ajout des liens sur la table:
|
||||||
|
for e in entreprises:
|
||||||
|
e["_nom_target"] = "entreprise_edit?entreprise_id=%(entreprise_id)s" % e
|
||||||
|
e["correspondants"] = self.do_entreprise_correspondant_list(
|
||||||
|
args={"entreprise_id": e["entreprise_id"]}
|
||||||
|
)
|
||||||
|
e["nbcorr"] = "%d corr." % len(e["correspondants"])
|
||||||
|
e["_nbcorr_target"] = (
|
||||||
|
"entreprise_correspondant_list?entreprise_id=%(entreprise_id)s" % e
|
||||||
|
)
|
||||||
|
e["contacts"] = self.do_entreprise_contact_list(
|
||||||
|
args={"entreprise_id": e["entreprise_id"]}
|
||||||
|
)
|
||||||
|
e["nbcontact"] = "%d contacts." % len(e["contacts"])
|
||||||
|
e["_nbcontact_target"] = (
|
||||||
|
"entreprise_contact_list?entreprise_id=%(entreprise_id)s" % e
|
||||||
|
)
|
||||||
|
tab = GenTable(
|
||||||
|
rows=entreprises,
|
||||||
|
columns_ids=("nom", "ville", "secteur", "nbcorr", "nbcontact"),
|
||||||
|
titles={
|
||||||
|
"nom": "Entreprise",
|
||||||
|
"ville": "Ville",
|
||||||
|
"secteur": "Secteur",
|
||||||
|
"nbcorr": "Corresp.",
|
||||||
|
"contacts": "Contacts",
|
||||||
|
},
|
||||||
|
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr(),
|
||||||
|
filename=scu.make_filename(
|
||||||
|
"entreprises_%s" % self.get_preference("DeptName")
|
||||||
|
),
|
||||||
|
caption="Entreprises du département %s" % self.get_preference("DeptName"),
|
||||||
|
html_sortable=True,
|
||||||
|
html_class="entreprise_list table_leftalign",
|
||||||
|
html_with_td_classes=True,
|
||||||
|
html_next_section=table_navigation,
|
||||||
|
base_url=REQUEST.URL0 + "?",
|
||||||
|
preferences=self.get_preferences(),
|
||||||
|
)
|
||||||
|
if format != "html":
|
||||||
|
return tab.make_page(self, format=format, REQUEST=REQUEST)
|
||||||
|
else:
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""<h2>Suivi relations entreprises</h2>""",
|
||||||
|
"""<div class="entreprise_list_table">""",
|
||||||
|
tab.html(),
|
||||||
|
"""</div>""",
|
||||||
|
self.entreprise_footer(REQUEST),
|
||||||
|
]
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
security.declareProtected(ScoEntrepriseView, "entreprise_contact_list")
|
security.declareProtected(ScoEntrepriseView, "entreprise_contact_list")
|
||||||
entreprise_contact_list = DTMLFile(
|
|
||||||
"dtml/entreprises/entreprise_contact_list", globals()
|
|
||||||
)
|
|
||||||
security.declareProtected(ScoEntrepriseView, "entreprise_correspondant_list")
|
|
||||||
entreprise_correspondant_list = DTMLFile(
|
|
||||||
"dtml/entreprises/entreprise_correspondant_list", globals()
|
|
||||||
)
|
|
||||||
# les methodes "edit" sont aussi en ScoEntrepriseView car elles permettent
|
|
||||||
# la visualisation (via variable _read_only positionnee dans entreprise_header)
|
|
||||||
security.declareProtected(ScoEntrepriseView, "entreprise_contact_edit")
|
|
||||||
entreprise_contact_edit = DTMLFile(
|
|
||||||
"dtml/entreprises/entreprise_contact_edit", globals()
|
|
||||||
)
|
|
||||||
security.declareProtected(ScoEntrepriseView, "entreprise_correspondant_edit")
|
|
||||||
entreprise_correspondant_edit = DTMLFile(
|
|
||||||
"dtml/entreprises/entreprise_correspondant_edit", globals()
|
|
||||||
)
|
|
||||||
|
|
||||||
# Acces en modification:
|
def entreprise_contact_list(self, entreprise_id=None, format="html", REQUEST=None):
|
||||||
|
"""Liste des contacts de l'entreprise"""
|
||||||
|
H = [self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises")]
|
||||||
|
if entreprise_id:
|
||||||
|
E = self.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
|
||||||
|
C = self.do_entreprise_contact_list(args={"entreprise_id": entreprise_id})
|
||||||
|
H.append(
|
||||||
|
"""<h2 class="entreprise_contact">Listes des contacts avec l'entreprise %(nom)s</h2>
|
||||||
|
"""
|
||||||
|
% E
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
C = self.do_entreprise_contact_list(args={})
|
||||||
|
H.append(
|
||||||
|
"""<h2 class="entreprise_contact">Listes des contacts</h2>
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
for c in C:
|
||||||
|
c[
|
||||||
|
"_date_target"
|
||||||
|
] = "%s/entreprise_contact_edit?entreprise_contact_id=%s" % (
|
||||||
|
REQUEST.URL1,
|
||||||
|
c["entreprise_contact_id"],
|
||||||
|
)
|
||||||
|
c["entreprise"] = self.do_entreprise_list(
|
||||||
|
args={"entreprise_id": c["entreprise_id"]}
|
||||||
|
)[0]
|
||||||
|
if c["etudid"]:
|
||||||
|
c["etud"] = self.getEtudInfo(etudid=c["etudid"], filled=1)[0]
|
||||||
|
c["etudnom"] = c["etud"]["nomprenom"]
|
||||||
|
c["_etudnom_target"] = "%s/ficheEtud?etudid=%s" % (
|
||||||
|
REQUEST.URL1,
|
||||||
|
c["etudid"],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
c["etud"] = None
|
||||||
|
c["etudnom"] = ""
|
||||||
|
|
||||||
|
tab = GenTable(
|
||||||
|
rows=C,
|
||||||
|
columns_ids=("date", "type_contact", "etudnom", "description"),
|
||||||
|
titles={
|
||||||
|
"date": "Date",
|
||||||
|
"type_contact": "Object",
|
||||||
|
"etudnom": "Étudiant",
|
||||||
|
"description": "Description",
|
||||||
|
},
|
||||||
|
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr(),
|
||||||
|
filename=scu.make_filename("contacts_%s" % self.get_preference("DeptName")),
|
||||||
|
caption="",
|
||||||
|
html_sortable=True,
|
||||||
|
html_class="contact_list table_leftalign",
|
||||||
|
html_with_td_classes=True,
|
||||||
|
base_url=REQUEST.URL0 + "?",
|
||||||
|
preferences=self.get_preferences(),
|
||||||
|
)
|
||||||
|
if format != "html":
|
||||||
|
return tab.make_page(self, format=format, REQUEST=REQUEST)
|
||||||
|
|
||||||
|
H.append(tab.html())
|
||||||
|
|
||||||
|
if not REQUEST["_read_only"]: # portage DTML, à modifier
|
||||||
|
if entreprise_id:
|
||||||
|
H.append(
|
||||||
|
"""<p class="entreprise_create"><a class="entreprise_create" href="entreprise_contact_create?entreprise_id=%(entreprise_id)s">nouveau "contact"</a></p>
|
||||||
|
"""
|
||||||
|
% E
|
||||||
|
)
|
||||||
|
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
|
security.declareProtected(ScoEntrepriseView, "entreprise_correspondant_list")
|
||||||
|
|
||||||
|
def entreprise_correspondant_list(
|
||||||
|
self,
|
||||||
|
entreprise_id=None,
|
||||||
|
format="html",
|
||||||
|
REQUEST=None,
|
||||||
|
):
|
||||||
|
"""Liste des correspondants de l'entreprise"""
|
||||||
|
E = self.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""
|
||||||
|
<h2>Listes des correspondants dans l'entreprise %(nom)s</h2>
|
||||||
|
"""
|
||||||
|
% E,
|
||||||
|
]
|
||||||
|
correspondants = self.do_entreprise_correspondant_list(
|
||||||
|
args={"entreprise_id": entreprise_id}
|
||||||
|
)
|
||||||
|
for c in correspondants:
|
||||||
|
c["nomprenom"] = c["nom"].upper() + " " + c["nom"].capitalize()
|
||||||
|
c["_nomprenom_target"] = (
|
||||||
|
"%s/entreprise_correspondant_edit?entreprise_corresp_id=%s"
|
||||||
|
% (REQUEST.URL1, c["entreprise_corresp_id"]),
|
||||||
|
)
|
||||||
|
c["nom_entreprise"] = E["nom"]
|
||||||
|
l = []
|
||||||
|
if c["phone1"]:
|
||||||
|
l.append(c["phone1"])
|
||||||
|
if c["phone2"]:
|
||||||
|
l.append(c["phone2"])
|
||||||
|
if c["mobile"]:
|
||||||
|
l.append(c["mobile"])
|
||||||
|
c["telephones"] = " / ".join(l)
|
||||||
|
c["mails"] = " ".join(
|
||||||
|
[
|
||||||
|
'<a href="mailto:%s">%s</a>' % (c["mail1"], c["mail1"])
|
||||||
|
if c["mail1"]
|
||||||
|
else "",
|
||||||
|
'<a href="mailto:%s">%s</a>' % (c["mail2"], c["mail2"])
|
||||||
|
if c["mail2"]
|
||||||
|
else "",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
c["modifier"] = (
|
||||||
|
'<a class="corr_delete" href="entreprise_correspondant_edit?%s">modifier</a>'
|
||||||
|
% c["entreprise_corresp_id"]
|
||||||
|
)
|
||||||
|
c["supprimer"] = (
|
||||||
|
'<a class="corr_delete" href="entreprise_correspondant_delete?%s">supprimer</a>'
|
||||||
|
% c["entreprise_corresp_id"]
|
||||||
|
)
|
||||||
|
tab = GenTable(
|
||||||
|
rows=correspondants,
|
||||||
|
columns_ids=(
|
||||||
|
"nomprenom",
|
||||||
|
"nom_entreprise",
|
||||||
|
"fonction",
|
||||||
|
"telephones",
|
||||||
|
"mails",
|
||||||
|
"note",
|
||||||
|
"modifier",
|
||||||
|
"supprimer",
|
||||||
|
),
|
||||||
|
titles={
|
||||||
|
"nomprenom": "Nom",
|
||||||
|
"nom_entreprise": "Entreprise",
|
||||||
|
"fonction": "Fonction",
|
||||||
|
"telephones": "Téléphone",
|
||||||
|
"mails": "Mail",
|
||||||
|
"note": "Note",
|
||||||
|
"modifier": "",
|
||||||
|
"supprimer": "",
|
||||||
|
},
|
||||||
|
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr(),
|
||||||
|
filename=scu.make_filename(
|
||||||
|
"correspondants_%s_%s" % (E["nom"], self.get_preference("DeptName"))
|
||||||
|
),
|
||||||
|
caption="",
|
||||||
|
html_sortable=True,
|
||||||
|
html_class="contact_list table_leftalign",
|
||||||
|
html_with_td_classes=True,
|
||||||
|
base_url=REQUEST.URL0 + "?",
|
||||||
|
preferences=self.get_preferences(),
|
||||||
|
)
|
||||||
|
if format != "html":
|
||||||
|
return tab.make_page(self, format=format, REQUEST=REQUEST)
|
||||||
|
|
||||||
|
H.append(tab.html())
|
||||||
|
|
||||||
|
if not REQUEST["_read_only"]: # portage DTML, à modifier
|
||||||
|
H.append(
|
||||||
|
"""<p class="entreprise_create"><a class="entreprise_create" href="entreprise_correspondant_create?entreprise_id=%(entreprise_id)s">Ajouter un correspondant dans l'entreprise %(nom)s</a></p>
|
||||||
|
"""
|
||||||
|
% E
|
||||||
|
)
|
||||||
|
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
|
security.declareProtected(ScoEntrepriseView, "entreprise_contact_edit")
|
||||||
|
|
||||||
|
def entreprise_contact_edit(self, entreprise_contact_id, REQUEST=None):
|
||||||
|
"""Form edit contact"""
|
||||||
|
c = self.do_entreprise_contact_list(
|
||||||
|
args={"entreprise_contact_id": entreprise_contact_id}
|
||||||
|
)[0]
|
||||||
|
link_create_corr = (
|
||||||
|
'<a href="%s/entreprise_correspondant_create?entreprise_id=%s">créer un nouveau correspondant</a>'
|
||||||
|
% (REQUEST.URL1, c["entreprise_id"])
|
||||||
|
)
|
||||||
|
E = self.do_entreprise_list(args={"entreprise_id": c["entreprise_id"]})[0]
|
||||||
|
correspondants = self.do_entreprise_correspondant_listnames(
|
||||||
|
args={"entreprise_id": c["entreprise_id"]}
|
||||||
|
) + [("inconnu", "")]
|
||||||
|
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""<h2 class="entreprise_contact">Suivi entreprises</h2>
|
||||||
|
<h3>Contact avec entreprise %(nom)s</h3>"""
|
||||||
|
% E,
|
||||||
|
]
|
||||||
|
tf = TrivialFormulator(
|
||||||
|
REQUEST.URL0,
|
||||||
|
REQUEST.form,
|
||||||
|
(
|
||||||
|
(
|
||||||
|
"entreprise_contact_id",
|
||||||
|
{"default": entreprise_contact_id, "input_type": "hidden"},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"entreprise_id",
|
||||||
|
{"input_type": "hidden", "default": c["entreprise_id"]},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"type_contact",
|
||||||
|
{
|
||||||
|
"input_type": "menu",
|
||||||
|
"title": "Objet",
|
||||||
|
"allowed_values": (
|
||||||
|
"Prospection",
|
||||||
|
"Stage étudiant",
|
||||||
|
"Contrat Apprentissage",
|
||||||
|
"Projet",
|
||||||
|
"Autre",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"date",
|
||||||
|
{
|
||||||
|
"size": 12,
|
||||||
|
"title": "Date du contact (j/m/a)",
|
||||||
|
"allow_null": False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"entreprise_corresp_id",
|
||||||
|
{
|
||||||
|
"input_type": "menu",
|
||||||
|
"title": "Correspondant entreprise",
|
||||||
|
"explanation": link_create_corr,
|
||||||
|
"allow_null": True,
|
||||||
|
"labels": [x[0] for x in correspondants],
|
||||||
|
"allowed_values": [x[1] for x in correspondants],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"etudiant",
|
||||||
|
{
|
||||||
|
"size": 16,
|
||||||
|
"title": "Etudiant concerné",
|
||||||
|
"allow_null": True,
|
||||||
|
"default": c["etudid"],
|
||||||
|
"explanation": "nom (si pas ambigu) ou code",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"enseignant",
|
||||||
|
{"size": 16, "title": "Enseignant (tuteur)", "allow_null": True},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"description",
|
||||||
|
{
|
||||||
|
"input_type": "textarea",
|
||||||
|
"rows": 3,
|
||||||
|
"cols": 40,
|
||||||
|
"title": "Description",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
cancelbutton="Annuler",
|
||||||
|
initvalues=c,
|
||||||
|
submitlabel="Modifier les valeurs",
|
||||||
|
readonly=REQUEST["_read_only"],
|
||||||
|
)
|
||||||
|
|
||||||
|
if tf[0] == 0:
|
||||||
|
H.append(tf[1])
|
||||||
|
if not REQUEST["_read_only"]: # portage DTML, à modifier
|
||||||
|
H.append(
|
||||||
|
"""<p class="entreprise_descr"><a class="entreprise_delete" href="entreprise_contact_delete?entreprise_contact_id=%s">Supprimer ce contact</a> </p>"""
|
||||||
|
% entreprise_contact_id
|
||||||
|
)
|
||||||
|
elif tf[0] == -1:
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
else:
|
||||||
|
etudok = self.do_entreprise_check_etudiant(tf[2]["etudiant"])
|
||||||
|
if etudok[0] == 0:
|
||||||
|
H.append("""<p class="entreprise_warning">%s</p>""" % etudok[1])
|
||||||
|
else:
|
||||||
|
tf[2].update({"etudid": etudok[1]})
|
||||||
|
self.do_entreprise_contact_edit(tf[2])
|
||||||
|
REQUEST.RESPONSE.redirect(
|
||||||
|
REQUEST.URL1
|
||||||
|
+ "/entreprise_contact_list?entreprise_id="
|
||||||
|
+ str(c["entreprise_id"])
|
||||||
|
)
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
|
security.declareProtected(ScoEntrepriseView, "entreprise_correspondant_edit")
|
||||||
|
|
||||||
|
def entreprise_correspondant_edit(self, entreprise_corresp_id, REQUEST=None):
|
||||||
|
"""Form édition d'un correspondant"""
|
||||||
|
# F -> c
|
||||||
|
c = self.do_entreprise_correspondant_list(
|
||||||
|
args={"entreprise_corresp_id": entreprise_corresp_id}
|
||||||
|
)[0]
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""<h2 class="entreprise_correspondant">Édition contact entreprise</h2>""",
|
||||||
|
]
|
||||||
|
tf = TrivialFormulator(
|
||||||
|
REQUEST.URL0,
|
||||||
|
REQUEST.form,
|
||||||
|
(
|
||||||
|
(
|
||||||
|
"entreprise_corresp_id",
|
||||||
|
{"default": entreprise_corresp_id, "input_type": "hidden"},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"civilite",
|
||||||
|
{
|
||||||
|
"input_type": "menu",
|
||||||
|
"labels": ["M.", "Mme"],
|
||||||
|
"allowed_values": ["M.", "Mme"],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
("nom", {"size": 25, "title": "Nom", "allow_null": False}),
|
||||||
|
("prenom", {"size": 25, "title": "Prénom"}),
|
||||||
|
(
|
||||||
|
"fonction",
|
||||||
|
{
|
||||||
|
"input_type": "menu",
|
||||||
|
"allowed_values": (
|
||||||
|
"Directeur",
|
||||||
|
"RH",
|
||||||
|
"Resp. Administratif",
|
||||||
|
"Tuteur",
|
||||||
|
"Autre",
|
||||||
|
),
|
||||||
|
"explanation": "fonction via à vis de l'IUT",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"phone1",
|
||||||
|
{
|
||||||
|
"size": 14,
|
||||||
|
"title": "Téléphone 1",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"phone2",
|
||||||
|
{
|
||||||
|
"size": 14,
|
||||||
|
"title": "Téléphone 2",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"mobile",
|
||||||
|
{
|
||||||
|
"size": 14,
|
||||||
|
"title": "Tél. mobile",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"fax",
|
||||||
|
{
|
||||||
|
"size": 14,
|
||||||
|
"title": "Fax",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"mail1",
|
||||||
|
{
|
||||||
|
"size": 25,
|
||||||
|
"title": "e-mail",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"mail2",
|
||||||
|
{
|
||||||
|
"size": 25,
|
||||||
|
"title": "e-mail 2",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"note",
|
||||||
|
{"input_type": "textarea", "rows": 3, "cols": 40, "title": "Note"},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
cancelbutton="Annuler",
|
||||||
|
initvalues=c,
|
||||||
|
submitlabel="Modifier les valeurs",
|
||||||
|
readonly=REQUEST["_read_only"],
|
||||||
|
)
|
||||||
|
if tf[0] == 0:
|
||||||
|
H.append(tf[1])
|
||||||
|
elif tf[0] == -1:
|
||||||
|
REQUEST.RESPONSE.redirect(
|
||||||
|
"%s/entreprise_correspondant_list?entreprise_id=%s"
|
||||||
|
% (REQUEST.URL1, c["entreprise_id"])
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.do_entreprise_correspondant_edit(tf[2])
|
||||||
|
REQUEST.RESPONSE.redirect(
|
||||||
|
"%s/entreprise_correspondant_list?entreprise_id=%s"
|
||||||
|
% (REQUEST.URL1, c["entreprise_id"])
|
||||||
|
)
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
security.declareProtected(ScoEntrepriseChange, "entreprise_contact_create")
|
security.declareProtected(ScoEntrepriseChange, "entreprise_contact_create")
|
||||||
entreprise_contact_create = DTMLFile(
|
|
||||||
"dtml/entreprises/entreprise_contact_create", globals()
|
def entreprise_contact_create(self, entreprise_id, REQUEST=None):
|
||||||
)
|
"""Form création contact"""
|
||||||
|
E = self.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
|
||||||
|
correspondants = self.do_entreprise_correspondant_listnames(
|
||||||
|
args={"entreprise_id": entreprise_id}
|
||||||
|
)
|
||||||
|
if not correspondants:
|
||||||
|
correspondants = [("inconnu", "")]
|
||||||
|
curtime = time.strftime("%d/%m/%Y")
|
||||||
|
link_create_corr = (
|
||||||
|
'<a href="%s/entreprise_correspondant_create?entreprise_id=%s">créer un nouveau correspondant</a>'
|
||||||
|
% (REQUEST.URL1, entreprise_id)
|
||||||
|
)
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""<h2 class="entreprise_contact">Nouveau "contact" avec l'entreprise %(nom)s</h2>"""
|
||||||
|
% E,
|
||||||
|
]
|
||||||
|
tf = TrivialFormulator(
|
||||||
|
REQUEST.URL0,
|
||||||
|
REQUEST.form,
|
||||||
|
(
|
||||||
|
("entreprise_id", {"input_type": "hidden", "default": entreprise_id}),
|
||||||
|
(
|
||||||
|
"type_contact",
|
||||||
|
{
|
||||||
|
"input_type": "menu",
|
||||||
|
"title": "Objet",
|
||||||
|
"allowed_values": (
|
||||||
|
"Prospection",
|
||||||
|
"Stage étudiant",
|
||||||
|
"Contrat Apprentissage DUT GTR1",
|
||||||
|
"Contrat Apprentissage DUT GTR2",
|
||||||
|
"Contrat Apprentissage Licence SQRT",
|
||||||
|
"Projet",
|
||||||
|
"Autre",
|
||||||
|
),
|
||||||
|
"default": "Stage étudiant",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"date",
|
||||||
|
{
|
||||||
|
"size": 12,
|
||||||
|
"title": "Date du contact (j/m/a)",
|
||||||
|
"allow_null": False,
|
||||||
|
"default": curtime,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"entreprise_corresp_id",
|
||||||
|
{
|
||||||
|
"input_type": "menu",
|
||||||
|
"title": "Correspondant entreprise",
|
||||||
|
"explanation": link_create_corr,
|
||||||
|
"allow_null": True,
|
||||||
|
"labels": [x[0] for x in correspondants],
|
||||||
|
"allowed_values": [x[1] for x in correspondants],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"etudiant",
|
||||||
|
{
|
||||||
|
"size": 16,
|
||||||
|
"title": "Etudiant concerné",
|
||||||
|
"allow_null": True,
|
||||||
|
"explanation": "nom (si pas ambigu) ou code",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"enseignant",
|
||||||
|
{"size": 16, "title": "Enseignant (tuteur)", "allow_null": True},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"description",
|
||||||
|
{
|
||||||
|
"input_type": "textarea",
|
||||||
|
"rows": 3,
|
||||||
|
"cols": 40,
|
||||||
|
"title": "Description",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
cancelbutton="Annuler",
|
||||||
|
submitlabel="Ajouter ce contact",
|
||||||
|
readonly=REQUEST["_read_only"],
|
||||||
|
)
|
||||||
|
if tf[0] == 0:
|
||||||
|
H.append(tf[1])
|
||||||
|
elif tf[0] == -1:
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
else:
|
||||||
|
etudok = self.do_entreprise_check_etudiant(tf[2]["etudiant"])
|
||||||
|
if etudok[0] == 0:
|
||||||
|
H.append("""<p class="entreprise_warning">%s</p>""" % etudok[1])
|
||||||
|
else:
|
||||||
|
tf[2].update({"etudid": etudok[1]})
|
||||||
|
self.do_entreprise_contact_create(tf[2])
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
security.declareProtected(ScoEntrepriseChange, "entreprise_contact_delete")
|
security.declareProtected(ScoEntrepriseChange, "entreprise_contact_delete")
|
||||||
entreprise_contact_delete = DTMLFile(
|
|
||||||
"dtml/entreprises/entreprise_contact_delete", globals()
|
def entreprise_contact_delete(self, entreprise_contact_id, REQUEST=None):
|
||||||
)
|
"""Form delete contact"""
|
||||||
|
c = self.do_entreprise_contact_list(
|
||||||
|
args={"entreprise_contact_id": entreprise_contact_id}
|
||||||
|
)[0]
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""<h2>Suppression du contact</h2>""",
|
||||||
|
]
|
||||||
|
tf = TrivialFormulator(
|
||||||
|
REQUEST.URL0,
|
||||||
|
REQUEST.form,
|
||||||
|
(("entreprise_contact_id", {"input_type": "hidden"}),),
|
||||||
|
initvalues=c,
|
||||||
|
submitlabel="Confirmer la suppression",
|
||||||
|
cancelbutton="Annuler",
|
||||||
|
readonly=REQUEST["_read_only"],
|
||||||
|
)
|
||||||
|
if tf[0] == 0:
|
||||||
|
H.append(tf[1])
|
||||||
|
elif tf[0] == -1:
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
else:
|
||||||
|
self.do_entreprise_contact_delete(c["entreprise_contact_id"])
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
security.declareProtected(ScoEntrepriseChange, "entreprise_correspondant_create")
|
security.declareProtected(ScoEntrepriseChange, "entreprise_correspondant_create")
|
||||||
entreprise_correspondant_create = DTMLFile(
|
|
||||||
"dtml/entreprises/entreprise_correspondant_create", globals()
|
def entreprise_correspondant_create(self, entreprise_id, REQUEST=None):
|
||||||
)
|
"""Form création correspondant"""
|
||||||
|
E = self.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""<h2 class="entreprise_contact">Nouveau correspondant l'entreprise %(nom)s</h2>"""
|
||||||
|
% E,
|
||||||
|
]
|
||||||
|
tf = TrivialFormulator(
|
||||||
|
REQUEST.URL0,
|
||||||
|
REQUEST.form,
|
||||||
|
(
|
||||||
|
("entreprise_id", {"input_type": "hidden", "default": entreprise_id}),
|
||||||
|
(
|
||||||
|
"civilite",
|
||||||
|
{
|
||||||
|
"input_type": "menu",
|
||||||
|
"labels": ["M.", "Mme"],
|
||||||
|
"allowed_values": ["M.", "Mme"],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
("nom", {"size": 25, "title": "Nom", "allow_null": False}),
|
||||||
|
("prenom", {"size": 25, "title": "Prénom"}),
|
||||||
|
(
|
||||||
|
"fonction",
|
||||||
|
{
|
||||||
|
"input_type": "menu",
|
||||||
|
"allowed_values": (
|
||||||
|
"Directeur",
|
||||||
|
"RH",
|
||||||
|
"Resp. Administratif",
|
||||||
|
"Tuteur",
|
||||||
|
"Autre",
|
||||||
|
),
|
||||||
|
"default": "Tuteur",
|
||||||
|
"explanation": "fonction via à vis de l'IUT",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"phone1",
|
||||||
|
{
|
||||||
|
"size": 14,
|
||||||
|
"title": "Téléphone 1",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"phone2",
|
||||||
|
{
|
||||||
|
"size": 14,
|
||||||
|
"title": "Téléphone 2",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"mobile",
|
||||||
|
{
|
||||||
|
"size": 14,
|
||||||
|
"title": "Tél. mobile",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"fax",
|
||||||
|
{
|
||||||
|
"size": 14,
|
||||||
|
"title": "Fax",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"mail1",
|
||||||
|
{
|
||||||
|
"size": 25,
|
||||||
|
"title": "e-mail",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"mail2",
|
||||||
|
{
|
||||||
|
"size": 25,
|
||||||
|
"title": "e-mail 2",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"note",
|
||||||
|
{"input_type": "textarea", "rows": 3, "cols": 40, "title": "Note"},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
cancelbutton="Annuler",
|
||||||
|
submitlabel="Ajouter ce correspondant",
|
||||||
|
readonly=REQUEST["_read_only"],
|
||||||
|
)
|
||||||
|
if tf[0] == 0:
|
||||||
|
H.append(tf[1])
|
||||||
|
elif tf[0] == -1:
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
else:
|
||||||
|
self.do_entreprise_correspondant_create(tf[2])
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
security.declareProtected(ScoEntrepriseChange, "entreprise_correspondant_delete")
|
security.declareProtected(ScoEntrepriseChange, "entreprise_correspondant_delete")
|
||||||
entreprise_correspondant_delete = DTMLFile(
|
|
||||||
"dtml/entreprises/entreprise_correspondant_delete", globals()
|
def entreprise_correspondant_delete(self, entreprise_corresp_id, REQUEST=None):
|
||||||
)
|
"""Form delete correspondant"""
|
||||||
|
c = self.do_entreprise_correspondant_list(
|
||||||
|
args={"entreprise_corresp_id": entreprise_corresp_id}
|
||||||
|
)[0]
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""<h2>Suppression du correspondant %(nom)s %(prenom)s</h2>""" % c,
|
||||||
|
]
|
||||||
|
tf = TrivialFormulator(
|
||||||
|
REQUEST.URL0,
|
||||||
|
REQUEST.form,
|
||||||
|
(("entreprise_corresp_id", {"input_type": "hidden"}),),
|
||||||
|
initvalues=c,
|
||||||
|
submitlabel="Confirmer la suppression",
|
||||||
|
cancelbutton="Annuler",
|
||||||
|
readonly=REQUEST["_read_only"],
|
||||||
|
)
|
||||||
|
if tf[0] == 0:
|
||||||
|
H.append(tf[1])
|
||||||
|
elif tf[0] == -1:
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
else:
|
||||||
|
self.do_entreprise_correspondant_delete(c["entreprise_corresp_id"])
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
security.declareProtected(ScoEntrepriseChange, "entreprise_delete")
|
security.declareProtected(ScoEntrepriseChange, "entreprise_delete")
|
||||||
entreprise_delete = DTMLFile("dtml/entreprises/entreprise_delete", globals())
|
|
||||||
|
def entreprise_delete(self, entreprise_id, REQUEST=None):
|
||||||
|
"""Form delete entreprise"""
|
||||||
|
E = self.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
|
||||||
|
H = [
|
||||||
|
self.entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"),
|
||||||
|
"""<h2>Suppression de l'entreprise %(nom)s</h2>
|
||||||
|
<p class="entreprise_warning">Attention: supression définitive de l'entreprise, de ses correspondants et contacts.
|
||||||
|
</p>"""
|
||||||
|
% E,
|
||||||
|
]
|
||||||
|
Cl = self.do_entreprise_correspondant_list(
|
||||||
|
args={"entreprise_id": entreprise_id}
|
||||||
|
)
|
||||||
|
if Cl:
|
||||||
|
H.append(
|
||||||
|
"""<h3>Correspondants dans l'entreprise qui seront <em>supprimés</em>:</h3><ul>"""
|
||||||
|
)
|
||||||
|
for c in Cl:
|
||||||
|
H.append("""<li>%(nom)s %(prenom)s (%(fonction)s)</li>""" % c)
|
||||||
|
H.append("""</ul>""")
|
||||||
|
|
||||||
|
Cts = self.do_entreprise_contact_list(args={"entreprise_id": entreprise_id})
|
||||||
|
if Cts:
|
||||||
|
H.append(
|
||||||
|
"""<h3>Contacts avec l'entreprise qui seront <em>supprimés</em>:</h3><ul>"""
|
||||||
|
)
|
||||||
|
for c in Cts:
|
||||||
|
H.append("""<li>%(date)s %(description)s</li>""" % c)
|
||||||
|
H.append("""</ul>""")
|
||||||
|
tf = self.TrivialFormulator(
|
||||||
|
REQUEST.URL0,
|
||||||
|
REQUEST.form,
|
||||||
|
(("entreprise_id", {"input_type": "hidden"}),),
|
||||||
|
initvalues=E,
|
||||||
|
submitlabel="Confirmer la suppression",
|
||||||
|
cancelbutton="Annuler",
|
||||||
|
readonly=REQUEST["_read_only"],
|
||||||
|
)
|
||||||
|
if tf[0] == 0:
|
||||||
|
H.append(tf[1])
|
||||||
|
elif tf[0] == -1:
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
else:
|
||||||
|
self.do_entreprise_delete(E["entreprise_id"])
|
||||||
|
REQUEST.RESPONSE.redirect(REQUEST.URL1)
|
||||||
|
H.append(self.entreprise_footer(REQUEST))
|
||||||
|
return "\n".join(H)
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Entreprises : Methodes en Python
|
# Entreprises : Actions
|
||||||
#
|
#
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
security.declareProtected(ScoEntrepriseChange, "do_entreprise_create")
|
security.declareProtected(ScoEntrepriseChange, "do_entreprise_create")
|
||||||
@ -521,7 +1320,7 @@ class ZEntreprises(
|
|||||||
for x in r:
|
for x in r:
|
||||||
e.append(
|
e.append(
|
||||||
"<li>%s %s (code %s)</li>"
|
"<li>%s %s (code %s)</li>"
|
||||||
% (strupper(x[1]), x[2] or "", x[0].strip())
|
% (scu.strupper(x[1]), x[2] or "", x[0].strip())
|
||||||
)
|
)
|
||||||
e.append("</ul>")
|
e.append("</ul>")
|
||||||
return (
|
return (
|
||||||
@ -780,7 +1579,7 @@ class ZEntreprises(
|
|||||||
H.append(
|
H.append(
|
||||||
"""<p>%s <a class="entreprise_delete" href="entreprise_delete?entreprise_id=%s">Supprimer cette entreprise</a> </p>"""
|
"""<p>%s <a class="entreprise_delete" href="entreprise_delete?entreprise_id=%s">Supprimer cette entreprise</a> </p>"""
|
||||||
% (
|
% (
|
||||||
icontag("delete_img", title="delete", border="0"),
|
scu.icontag("delete_img", title="delete", border="0"),
|
||||||
F["entreprise_id"],
|
F["entreprise_id"],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -850,42 +1649,6 @@ class ZEntreprises(
|
|||||||
self.do_entreprise_edit(tf[2])
|
self.do_entreprise_edit(tf[2])
|
||||||
return REQUEST.RESPONSE.redirect(REQUEST.URL1 + "?start=" + start)
|
return REQUEST.RESPONSE.redirect(REQUEST.URL1 + "?start=" + start)
|
||||||
|
|
||||||
# --- Misc tools.... ------------------
|
|
||||||
security.declareProtected(ScoEntrepriseView, "str_abbrev")
|
|
||||||
|
|
||||||
def str_abbrev(self, s, maxlen):
|
|
||||||
"abreviation"
|
|
||||||
if s == None:
|
|
||||||
return "?"
|
|
||||||
if len(s) < maxlen:
|
|
||||||
return s
|
|
||||||
return s[: maxlen - 3] + "..."
|
|
||||||
|
|
||||||
security.declareProtected(ScoEntrepriseView, "setPageSizeCookie")
|
|
||||||
|
|
||||||
def setPageSizeCookie(self, REQUEST=None):
|
|
||||||
"set page size cookie"
|
|
||||||
RESPONSE = REQUEST.RESPONSE
|
|
||||||
#
|
|
||||||
if REQUEST.form.has_key("entreprise_page_size"):
|
|
||||||
RESPONSE.setCookie(
|
|
||||||
"entreprise_page_size",
|
|
||||||
REQUEST.form["entreprise_page_size"],
|
|
||||||
path="/",
|
|
||||||
expires="Wed, 31-Dec-2025 23:55:00 GMT",
|
|
||||||
)
|
|
||||||
RESPONSE.redirect(REQUEST.form["target_url"])
|
|
||||||
|
|
||||||
security.declareProtected(ScoEntrepriseView, "make_link_create_corr")
|
|
||||||
|
|
||||||
def make_link_create_corr(self, entreprise_id):
|
|
||||||
"yet another stupid code snippet"
|
|
||||||
return (
|
|
||||||
'<a href="entreprise_correspondant_create?entreprise_id='
|
|
||||||
+ str(entreprise_id)
|
|
||||||
+ '">créer un nouveau correspondant</a>'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
24
notesdb.py
24
notesdb.py
@ -141,6 +141,8 @@ def DBSelectArgs(
|
|||||||
distinct=True,
|
distinct=True,
|
||||||
aux_tables=[],
|
aux_tables=[],
|
||||||
id_name=None,
|
id_name=None,
|
||||||
|
limit="",
|
||||||
|
offset="",
|
||||||
):
|
):
|
||||||
"""Select * from table where values match dict vals.
|
"""Select * from table where values match dict vals.
|
||||||
Returns cnx, columns_names, list of tuples
|
Returns cnx, columns_names, list of tuples
|
||||||
@ -155,6 +157,12 @@ def DBSelectArgs(
|
|||||||
distinct = " distinct "
|
distinct = " distinct "
|
||||||
else:
|
else:
|
||||||
distinct = ""
|
distinct = ""
|
||||||
|
if limit != "":
|
||||||
|
limit = " LIMIT %d" % limit
|
||||||
|
if not offset:
|
||||||
|
offset = ""
|
||||||
|
if offset != "":
|
||||||
|
offset = " OFFSET %d" % offset
|
||||||
operator = " " + operator + " "
|
operator = " " + operator + " "
|
||||||
# liste des tables (apres "from")
|
# liste des tables (apres "from")
|
||||||
tables = [table] + [x[0] for x in aux_tables]
|
tables = [table] + [x[0] for x in aux_tables]
|
||||||
@ -195,7 +203,17 @@ def DBSelectArgs(
|
|||||||
if cond:
|
if cond:
|
||||||
cond = " where " + cond
|
cond = " where " + cond
|
||||||
#
|
#
|
||||||
req = "select " + distinct + ", ".join(what) + " from " + tables + cond + orderby
|
req = (
|
||||||
|
"select "
|
||||||
|
+ distinct
|
||||||
|
+ ", ".join(what)
|
||||||
|
+ " from "
|
||||||
|
+ tables
|
||||||
|
+ cond
|
||||||
|
+ orderby
|
||||||
|
+ limit
|
||||||
|
+ offset
|
||||||
|
)
|
||||||
# open('/tmp/select.log','a').write( req % vals + '\n' )
|
# open('/tmp/select.log','a').write( req % vals + '\n' )
|
||||||
try:
|
try:
|
||||||
cursor.execute(req, vals)
|
cursor.execute(req, vals)
|
||||||
@ -329,6 +347,8 @@ class EditableTable:
|
|||||||
test="=",
|
test="=",
|
||||||
sortkey=None,
|
sortkey=None,
|
||||||
disable_formatting=False,
|
disable_formatting=False,
|
||||||
|
limit="",
|
||||||
|
offset="",
|
||||||
):
|
):
|
||||||
"returns list of dicts"
|
"returns list of dicts"
|
||||||
# REQLOG.write('%s: %s by %s (%s) %d\n'%(self.table_name,args,sys._getframe(1).f_code.co_name, sys._getframe(2).f_code.co_name, REQN))
|
# REQLOG.write('%s: %s by %s (%s) %d\n'%(self.table_name,args,sys._getframe(1).f_code.co_name, sys._getframe(2).f_code.co_name, REQN))
|
||||||
@ -347,6 +367,8 @@ class EditableTable:
|
|||||||
operator=operator,
|
operator=operator,
|
||||||
aux_tables=self.aux_tables,
|
aux_tables=self.aux_tables,
|
||||||
id_name=self.id_name,
|
id_name=self.id_name,
|
||||||
|
limit=limit,
|
||||||
|
offset=offset,
|
||||||
)
|
)
|
||||||
for r in res:
|
for r in res:
|
||||||
self.format_output(r, disable_formatting=disable_formatting)
|
self.format_output(r, disable_formatting=disable_formatting)
|
||||||
|
@ -2039,7 +2039,14 @@ table.entreprise_list, table.corr_list, table.contact_list {
|
|||||||
/* border-style: solid; */
|
/* border-style: solid; */
|
||||||
border-spacing: 0px 0px;
|
border-spacing: 0px 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
|
margin-left: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.entreprise_list td.nbcorr a, table.entreprise_list td.nbcontact a, table.contact_list td.etudnom a, table.contact_list td a {
|
||||||
|
color: navy;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
tr.entreprise_list_even, tr.corr_list_even, tr.contact_list_even {
|
tr.entreprise_list_even, tr.corr_list_even, tr.contact_list_even {
|
||||||
background-color: rgb(85%,85%,95%);
|
background-color: rgb(85%,85%,95%);
|
||||||
}
|
}
|
||||||
@ -2047,6 +2054,19 @@ tr.entreprise_list_odd, tr.corr_list_odd, tr.contact_list_odd {
|
|||||||
background-color: rgb(90%,90%, 90%);
|
background-color: rgb(90%,90%, 90%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.table_nav_mid {
|
||||||
|
flex-grow: 1; /* Set the middle element to grow and stretch */
|
||||||
|
}
|
||||||
|
span.table_nav_prev, span.table_nav_next {
|
||||||
|
width: 11em; /* A fixed width as the default */
|
||||||
|
}
|
||||||
|
|
||||||
|
div.table_nav {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
td.entreprise_descr, td.corr_descr, td.contact_descr {
|
td.entreprise_descr, td.corr_descr, td.contact_descr {
|
||||||
padding-left: 2em;
|
padding-left: 2em;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user