view website/issues/extensions/timestamp.py @ 5277:b580f61929e2

Removing richard from notification list. Verified that he doesn't want to be on it anymore. Date: Sun, 24 Sep 2017 14:58:24 +1000 To: rouiljsomewhere From: Richard Jones <r1chardj0n3s at gmail.com> Subject: Re: Do you still want new issues to roundup tracker sent to you? --94eb2c0da3aac771bb0559e84afb Content-Type: text/plain; charset="UTF-8" Thanks John, yes please do remove me. Richard On 24 September 2017 at 14:13, John P. Rouillard <rouilj at cs.umb.edu> wrote: > Hi Richard: > > I am working on updating the roundup tracker to > get it ready for the current development code. > > As I was testing I noticed you are still in the > list of email addresses getting new issue emails. > > Do you want to continue to receive these since > you aren't actively developing roundup?
author John Rouillard <rouilj@ieee.org>
date Sun, 24 Sep 2017 18:44:48 -0400
parents c2d0d3e9099d
children 35ea9b1efc14
line wrap: on
line source

import time, struct, base64
from roundup.cgi.actions import RegisterAction
from roundup.cgi.exceptions import *

def timestamp():
    return base64.encodestring(struct.pack("i", time.time())).strip()

def unpack_timestamp(s):
    return struct.unpack("i",base64.decodestring(s))[0]

class Timestamped:
    def check(self):
        try:
            created = unpack_timestamp(self.form['opaque'].value)
        except KeyError:
            raise FormError, "somebody tampered with the form"
        if time.time() - created < 4:
            raise FormError, "responding to the form too quickly"
        return True

class TimestampedRegister(Timestamped, RegisterAction):
    def permission(self):
        self.check()
        RegisterAction.permission(self)

def init(instance):
    instance.registerUtil('timestamp', timestamp)
    instance.registerAction('register', TimestampedRegister)

Roundup Issue Tracker: http://roundup-tracker.org/