Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 1402:27586da5557c
Added users' timezone support
| author | Andrey Lebedev <kedder@users.sourceforge.net> |
|---|---|
| date | Mon, 27 Jan 2003 16:32:50 +0000 |
| parents | d5314bfab0c0 |
| children | 2158bdbcac37 |
comparison
equal
deleted
inserted
replaced
| 1399:8ae55277b22d | 1402:27586da5557c |
|---|---|
| 513 '</tr>'] | 513 '</tr>'] |
| 514 current = {} | 514 current = {} |
| 515 comments = {} | 515 comments = {} |
| 516 history = self._klass.history(self._nodeid) | 516 history = self._klass.history(self._nodeid) |
| 517 history.sort() | 517 history.sort() |
| 518 timezone = self._db.getUserTimezone() | |
| 518 if direction == 'descending': | 519 if direction == 'descending': |
| 519 history.reverse() | 520 history.reverse() |
| 520 for prop_n in self._props.keys(): | 521 for prop_n in self._props.keys(): |
| 521 prop = self[prop_n] | 522 prop = self[prop_n] |
| 522 if isinstance(prop, HTMLProperty): | 523 if isinstance(prop, HTMLProperty): |
| 528 if os.path.exists(os.path.join(self._db.config.TEMPLATES, classname + '.item')): | 529 if os.path.exists(os.path.join(self._db.config.TEMPLATES, classname + '.item')): |
| 529 current[prop_n] = '<a href="%s%s">%s</a>'%(classname, | 530 current[prop_n] = '<a href="%s%s">%s</a>'%(classname, |
| 530 self._klass.get(self._nodeid, prop_n, None), current[prop_n]) | 531 self._klass.get(self._nodeid, prop_n, None), current[prop_n]) |
| 531 | 532 |
| 532 for id, evt_date, user, action, args in history: | 533 for id, evt_date, user, action, args in history: |
| 533 date_s = str(evt_date).replace("."," ") | 534 date_s = str(evt_date.local(timezone)).replace("."," ") |
| 534 arg_s = '' | 535 arg_s = '' |
| 535 if action == 'link' and type(args) == type(()): | 536 if action == 'link' and type(args) == type(()): |
| 536 if len(args) == 3: | 537 if len(args) == 3: |
| 537 linkcl, linkid, key = args | 538 linkcl, linkid, key = args |
| 538 arg_s += '<a href="%s%s">%s%s %s</a>'%(linkcl, linkid, | 539 arg_s += '<a href="%s%s">%s%s %s</a>'%(linkcl, linkid, |
| 630 if current.has_key(k): | 631 if current.has_key(k): |
| 631 cell[-1] += ' -> %s'%current[k] | 632 cell[-1] += ' -> %s'%current[k] |
| 632 current[k] = old | 633 current[k] = old |
| 633 | 634 |
| 634 elif isinstance(prop, hyperdb.Date) and args[k]: | 635 elif isinstance(prop, hyperdb.Date) and args[k]: |
| 635 d = date.Date(args[k]) | 636 d = date.Date(args[k]).local(timezone) |
| 636 cell.append('%s: %s'%(k, str(d))) | 637 cell.append('%s: %s'%(k, str(d))) |
| 637 if current.has_key(k): | 638 if current.has_key(k): |
| 638 cell[-1] += ' -> %s'%current[k] | 639 cell[-1] += ' -> %s' % date.Date(current[k]).local(timezone) |
| 639 current[k] = str(d) | 640 current[k] = str(d) |
| 640 | 641 |
| 641 elif isinstance(prop, hyperdb.Interval) and args[k]: | 642 elif isinstance(prop, hyperdb.Interval) and args[k]: |
| 642 d = date.Interval(args[k]) | 643 d = date.Interval(args[k]) |
| 643 cell.append('%s: %s'%(k, str(d))) | 644 cell.append('%s: %s'%(k, str(d))) |
| 916 def plain(self): | 917 def plain(self): |
| 917 ''' Render a "plain" representation of the property | 918 ''' Render a "plain" representation of the property |
| 918 ''' | 919 ''' |
| 919 if self._value is None: | 920 if self._value is None: |
| 920 return '' | 921 return '' |
| 921 return str(self._value) | 922 return str(self._value.local(self._db.getUserTimezone())) |
| 922 | 923 |
| 923 def field(self, size = 30): | 924 def field(self, size = 30): |
| 924 ''' Render a form edit field for the property | 925 ''' Render a form edit field for the property |
| 925 ''' | 926 ''' |
| 926 if self._value is None: | 927 if self._value is None: |
| 927 value = '' | 928 value = '' |
| 928 else: | 929 else: |
| 929 value = cgi.escape(str(self._value)) | 930 value = cgi.escape(str(self._value.local(self._db.getUserTimezone()))) |
| 930 value = '"'.join(value.split('"')) | 931 value = '"'.join(value.split('"')) |
| 931 return '<input name="%s" value="%s" size="%s">'%(self._name, value, size) | 932 return '<input name="%s" value="%s" size="%s">'%(self._name, value, size) |
| 932 | 933 |
| 933 def reldate(self, pretty=1): | 934 def reldate(self, pretty=1): |
| 934 ''' Render the interval between the date and now. | 935 ''' Render the interval between the date and now. |
