wcs.cron-ok.diff
wcs/admin/settings.ptl (copie de travail) | ||
---|---|---|
289 | 289 | |
290 | 290 |
'<dl>' |
291 | 291 |
'<dt><a href="sitename">%s</a></dt> <dd>%s</dd>' % ( |
292 |
_('Site Name'), _('Configure site name'))
|
|
292 |
_('Site Name and Addresses'), _('Configure site name and addresses'))
|
|
293 | 293 |
'<dt><a href="language">%s</a></dt> <dd>%s</dd>' % ( |
294 | 294 |
_('Language'), _('Configure site language')) |
295 | 295 |
'<dt><a href="themes">%s</a></dt> <dd>%s</dd>' % ( |
... | ... | |
646 | 646 |
misc_cfg = get_cfg('misc', {}) |
647 | 647 |
form.add(StringWidget, 'sitename', title = _('Site Name'), |
648 | 648 |
value = misc_cfg.get('sitename', '')) |
649 |
form.add(StringWidget, 'frontoffice-url', size=32, |
|
650 |
title = _('Frontoffice base URL'), |
|
651 |
value = misc_cfg.get('frontoffice-url', '')) |
|
652 |
form.add(StringWidget, 'backoffice-url', size=32, |
|
653 |
title = _('Backoffice base URL'), |
|
654 |
value = misc_cfg.get('backoffice-url', '')) |
|
649 | 655 | |
650 | 656 |
form.add_submit('submit', _('Submit')) |
651 | 657 |
form.add_submit('cancel', _('Cancel')) |
... | ... | |
653 | 659 |
return redirect('.') |
654 | 660 | |
655 | 661 |
if not form.is_submitted() or form.has_errors(): |
656 |
get_response().breadcrumb.append(('sitename', _('Site Name'))) |
|
657 |
html_top('settings', title = _('Site Name')) |
|
658 |
'<h2>%s</h2>' % _('Site Name') |
|
662 |
get_response().breadcrumb.append(('sitename', _('Site Name and Addresses')))
|
|
663 |
html_top('settings', title = _('Site Name and Addresses'))
|
|
664 |
'<h2>%s</h2>' % _('Site Name and Addresses')
|
|
659 | 665 |
form.render() |
660 | 666 |
else: |
661 |
cfg_submit(form, 'misc', ['sitename']) |
|
667 |
cfg_submit(form, 'misc', ['sitename', 'frontoffice-url', 'backoffice-url'])
|
|
662 | 668 |
redirect('.') |
663 | 669 | |
664 | 670 |
def sms [html] (self): |
wcs/qommon/publisher.py (copie de travail) | ||
---|---|---|
61 | 61 |
import logger |
62 | 62 |
import storage |
63 | 63 |
import strftime |
64 |
import urllib |
|
64 | 65 | |
65 | 66 |
class ImmediateRedirectException(Exception): |
66 | 67 |
def __init__(self, location): |
... | ... | |
97 | 98 |
app_translations = dict() |
98 | 99 | |
99 | 100 |
def get_root_url(self): |
100 |
return self.get_request().environ['SCRIPT_NAME'] + '/' |
|
101 |
if self.get_request(): |
|
102 |
return self.get_request().environ['SCRIPT_NAME'] + '/' |
|
103 |
else: |
|
104 |
return '/' |
|
101 | 105 | |
102 | 106 |
def get_application_static_files_root_url(self): |
103 | 107 |
# Typical applications will have their static files under the same root |
... | ... | |
105 | 109 |
# some other path, or even on some totally different hostname. |
106 | 110 |
return self.get_root_url() |
107 | 111 | |
112 |
def get_frontoffice_url(self): |
|
113 |
frontoffice_url = get_cfg('misc', {}).get('frontoffice-url', None) |
|
114 |
if frontoffice_url: |
|
115 |
return frontoffice_url |
|
116 |
req = self.get_request() |
|
117 |
if req: |
|
118 |
return '%s://%s%s' % (req.get_scheme(), req.get_server(), |
|
119 |
urllib.quote(req.environ.get('SCRIPT_NAME'))) |
|
120 |
return 'http://%s' % os.path.basename(get_publisher().app_dir) |
|
121 | ||
122 |
def get_backoffice_url(self): |
|
123 |
backoffice_url = get_cfg('misc', {}).get('backoffice-url', None) |
|
124 |
if backoffice_url: |
|
125 |
return backoffice_url |
|
126 |
req = self.get_request() |
|
127 |
if req: |
|
128 |
return '%s://%s%s/backoffice' % (req.get_scheme(), req.get_server(), |
|
129 |
urllib.quote(req.environ.get('SCRIPT_NAME'))) |
|
130 |
return 'http://%s/backoffice' % os.path.basename(self.app_dir) |
|
131 | ||
108 | 132 |
def format_publish_error(self, exc): |
109 | 133 |
get_response().filter = {} |
110 | 134 |
if isinstance(exc, errors.AccessError) and hasattr(exc, 'render'): |
... | ... | |
387 | 411 |
lang = self.cfg.get('language', {}).get('language', None) |
388 | 412 |
if lang == 'HTTP': |
389 | 413 |
request = self.get_request() |
414 |
if not request: |
|
415 |
return None |
|
390 | 416 |
lang = None |
391 | 417 |
accepted_languages = request.get_header('Accept-Language') |
392 | 418 |
if accepted_languages: |
... | ... | |
396 | 422 |
for l in accepted_languages: |
397 | 423 |
if l in self.translations.keys(): |
398 | 424 |
return l |
399 |
else: |
|
400 |
return lang |
|
425 |
return lang |
|
401 | 426 | |
402 | 427 |
def get_admin_module(cls): |
403 | 428 |
return None |
... | ... | |
714 | 739 |
return { |
715 | 740 |
'site_name': get_cfg('misc', {}).get('sitename', None), |
716 | 741 |
'site_theme': get_cfg('branding', {}).get('theme', self.default_theme), |
742 |
'site_url': self.get_frontoffice_url(), |
|
743 |
'site_url_backoffice': self.get_backoffice_url(), |
|
717 | 744 |
'today': strftime.strftime(misc.date_format(), time.localtime()), |
718 | 745 |
'now': misc.localstrftime(time.localtime()), |
719 | 746 |
} |
... | ... | |
747 | 774 | |
748 | 775 |
Substitutions.register('site_name', category=N_('General'), comment=N_('Site Name')) |
749 | 776 |
Substitutions.register('site_theme', category=N_('General'), comment=N_('Current Theme Name')) |
777 |
Substitutions.register('site_url', category=N_('General'), comment=N_('Site URL')) |
|
778 |
Substitutions.register('site_url_backoffice', category=N_('General'), comment=N_('Site URL (backoffice)')) |
|
750 | 779 |
Substitutions.register('today', category=N_('General'), comment=N_('Current Date')) |
751 | 780 |
Substitutions.register('now', category=N_('General'), comment=N_('Current Date & Time')) |
wcs/formdef.py (copie de travail) | ||
---|---|---|
232 | 232 |
get_by_urlname = classmethod(get_by_urlname) |
233 | 233 | |
234 | 234 |
def get_url(self, backoffice = False): |
235 |
req = get_request() |
|
236 |
base_url = '%s://%s%s' % (req.get_scheme(), req.get_server(), |
|
237 |
urllib.quote(req.environ.get('SCRIPT_NAME'))) |
|
238 | 235 |
if backoffice: |
239 |
base_url += '/backoffice' |
|
236 |
base_url = get_publisher().get_backoffice_url() |
|
237 |
else: |
|
238 |
base_url = get_publisher().get_frontoffice_url() |
|
240 | 239 |
return '%s/%s/' % (base_url, self.url_name) |
241 | 240 | |
242 | 241 |
wcs/formdata.py (copie de travail) | ||
---|---|---|
199 | 199 |
return wf_status.handle_form(form, self, user) |
200 | 200 | |
201 | 201 |
def get_url(self, backoffice = False): |
202 |
req = get_request() |
|
203 |
base_url = '%s://%s%s' % (req.get_scheme(), req.get_server(), |
|
204 |
urllib.quote(req.environ.get('SCRIPT_NAME'))) |
|
205 | 202 |
if backoffice: |
206 |
base_url += '/backoffice' |
|
203 |
base_url = get_publisher().get_backoffice_url() |
|
204 |
else: |
|
205 |
base_url = get_publisher().get_frontoffice_url() |
|
207 | 206 |
return '%s/%s/%s/' % (base_url, self.formdef.url_name, self.id) |
208 | 207 | |
209 | 208 |
def get_workflow_status(self): |
... | ... | |
229 | 228 |
'form_receipt_time': qommon.strftime.strftime('%H:%M', self.receipt_time), |
230 | 229 |
'form_number': str(self.id), |
231 | 230 |
'form_url': self.get_url(), |
231 |
'form_url_backoffice': self.get_url(backoffice=True), |
|
232 | 232 |
'form_uri': '%s/%s/' % (self.formdef.url_name, self.id), |
233 | 233 |
'form_status_url': '%sstatus' % self.get_url(), |
234 | 234 |
'form_details': self.formdef.get_detailed_email_form(self, self.get_url()), |
... | ... | |
307 | 307 |
Substitutions.register('form_number', category=N_('Form'), comment=N_('Form Number')) |
308 | 308 |
Substitutions.register('form_details', category=N_('Form'), comment=N_('Form Details')) |
309 | 309 |
Substitutions.register('form_url', category=N_('Form'), comment=N_('Form URL')) |
310 |
Substitutions.register('form_url_backoffice', category=N_('Form'), comment=N_('Form URL (backoffice)')) |
|
310 | 311 |
Substitutions.register('form_uri', category=N_('Form'), comment=N_('Form URI')) |
311 | 312 |
Substitutions.register('form_status_url', category=N_('Form'), comment=N_('Form Status URL')) |
312 | 313 |
Substitutions.register('form_user', category=N_('Form'), comment=N_('Form Submitter')) |
wcs/qommon/cron.py (copie de travail) | ||
---|---|---|
62 | 62 |
publisher.app_dir = os.path.join(app_dir, hostname) |
63 | 63 |
if not os.path.isdir(publisher.app_dir): |
64 | 64 |
continue |
65 |
# create a fake publisher |
|
65 | 66 |
try: |
66 | 67 |
publisher.set_config() |
67 | 68 |
except: |
68 | 69 |
continue |
70 |
publisher.install_lang(publisher.get_site_language()) |
|
69 | 71 |
for job in publisher.cronjobs: |
70 | 72 |
if job.days and now[2] not in job.days: |
71 | 73 |
continue |
... | ... | |
75 | 77 |
continue |
76 | 78 |
if job.minutes and not now[4] in job.minutes: |
77 | 79 |
continue |
80 |
publisher.substitutions.reset() |
|
81 |
publisher.substitutions.feed(publisher) |
|
78 | 82 |
try: |
79 | 83 |
job.function(publisher) |
80 | 84 |
except: |