Get time zone stuff working (wow, sqlalchemy makes this so simple!)
This commit is contained in:
parent
7ba2cf704e
commit
16b80d3257
3 changed files with 19 additions and 20 deletions
|
@ -22,6 +22,7 @@
|
||||||
Model for the Fedora Account System
|
Model for the Fedora Account System
|
||||||
'''
|
'''
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import pytz
|
||||||
from turbogears.database import metadata, mapper, get_engine
|
from turbogears.database import metadata, mapper, get_engine
|
||||||
# import some basic SQLAlchemy classes for declaring the data model
|
# import some basic SQLAlchemy classes for declaring the data model
|
||||||
# (see http://www.sqlalchemy.org/docs/04/ormtutorial.html)
|
# (see http://www.sqlalchemy.org/docs/04/ormtutorial.html)
|
||||||
|
@ -80,7 +81,7 @@ UnApprovedRolesSelect = PersonRolesTable.select(and_(
|
||||||
|
|
||||||
visits_table = Table('visit', metadata,
|
visits_table = Table('visit', metadata,
|
||||||
Column('visit_key', String(40), primary_key=True),
|
Column('visit_key', String(40), primary_key=True),
|
||||||
Column('created', DateTime, nullable=False, default=datetime.now),
|
Column('created', DateTime, nullable=False, default=datetime.now(pytz.utc)),
|
||||||
Column('expiry', DateTime)
|
Column('expiry', DateTime)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ class People(SABase):
|
||||||
role = PersonRoles.query.filter_by(member=cls, group=group).one()
|
role = PersonRoles.query.filter_by(member=cls, group=group).one()
|
||||||
role.role_status = 'approved'
|
role.role_status = 'approved'
|
||||||
role.sponsor_id = requester.id
|
role.sponsor_id = requester.id
|
||||||
role.approval = datetime.now()
|
role.approval = datetime.now(pytz.utc)
|
||||||
|
|
||||||
def remove(cls, group, requester):
|
def remove(cls, group, requester):
|
||||||
role = PersonRoles.query.filter_by(member=cls, group=group).one()
|
role = PersonRoles.query.filter_by(member=cls, group=group).one()
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
<?python
|
<?python
|
||||||
from fas import auth
|
from fas import auth
|
||||||
from fas.model import People
|
from fas.model import People
|
||||||
|
import pytz
|
||||||
person = People.by_username(tg.identity.user.username)
|
person = People.by_username(tg.identity.user.username)
|
||||||
|
timezone = pytz.timezone(person.timezone)
|
||||||
?>
|
?>
|
||||||
<h2>${group.display_name} (${group.name})</h2>
|
<h2>${group.display_name} (${group.name})</h2>
|
||||||
<h3>
|
<h3>
|
||||||
|
@ -70,12 +72,8 @@
|
||||||
<td><a href="${tg.url('/user/view/%s' % role.member.username)}">${role.member.username}</a></td>
|
<td><a href="${tg.url('/user/view/%s' % role.member.username)}">${role.member.username}</a></td>
|
||||||
<td py:if='not(role.member.username == "None")'><a href="${tg.url('/user/view/%s' % role.member.username)}">${role.member.username}</a></td>
|
<td py:if='not(role.member.username == "None")'><a href="${tg.url('/user/view/%s' % role.member.username)}">${role.member.username}</a></td>
|
||||||
<td py:if='role.member.username == "None"'>${_('None')}</td>
|
<td py:if='role.member.username == "None"'>${_('None')}</td>
|
||||||
<?python
|
<td>${role.creation.astimezone(timezone).strftime('%Y-%m-%d %H:%M:%S %Z')}</td>
|
||||||
from datetime import datetime
|
<td>${role.approval.astimezone(timezone).strftime('%Y-%m-%d %H:%M:%S %Z')}</td>
|
||||||
from pytz import timezone
|
|
||||||
?>
|
|
||||||
<td>${role.creation}</td>
|
|
||||||
<td>${role.approval}</td>
|
|
||||||
<td>${role.role_status}</td>
|
<td>${role.role_status}</td>
|
||||||
<td>${role.role_type}</td>
|
<td>${role.role_type}</td>
|
||||||
<!-- This section includes all action items -->
|
<!-- This section includes all action items -->
|
||||||
|
|
24
fas/fas2.sql
24
fas/fas2.sql
|
@ -51,13 +51,13 @@ CREATE TABLE people (
|
||||||
affiliation TEXT,
|
affiliation TEXT,
|
||||||
certificate_serial INTEGER DEFAULT 1,
|
certificate_serial INTEGER DEFAULT 1,
|
||||||
-- tg_user::created
|
-- tg_user::created
|
||||||
creation TIMESTAMP DEFAULT NOW(),
|
creation TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||||
--approval_status TEXT DEFAULT 'unapproved',
|
--approval_status TEXT DEFAULT 'unapproved',
|
||||||
internal_comments TEXT,
|
internal_comments TEXT,
|
||||||
ircnick TEXT,
|
ircnick TEXT,
|
||||||
last_seen TIMESTAMP DEFAULT NOW(),
|
last_seen TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||||
status TEXT,
|
status TEXT,
|
||||||
status_change TIMESTAMP DEFAULT NOW(),
|
status_change TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||||
locale TEXT not null DEFAULT 'C',
|
locale TEXT not null DEFAULT 'C',
|
||||||
timezone TEXT null DEFAULT 'UTC',
|
timezone TEXT null DEFAULT 'UTC',
|
||||||
latitude numeric,
|
latitude numeric,
|
||||||
|
@ -123,7 +123,7 @@ CREATE TABLE groups (
|
||||||
prerequisite_id INTEGER REFERENCES groups(id),
|
prerequisite_id INTEGER REFERENCES groups(id),
|
||||||
joinmsg TEXT NULL DEFAULT '',
|
joinmsg TEXT NULL DEFAULT '',
|
||||||
-- tg_group::created
|
-- tg_group::created
|
||||||
creation TIMESTAMP DEFAULT NOW(),
|
creation TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||||
check (group_type in ('bugzilla','cvs', 'bzr', 'git', 'hg', 'mtn',
|
check (group_type in ('bugzilla','cvs', 'bzr', 'git', 'hg', 'mtn',
|
||||||
'svn', 'shell', 'torrent', 'tracker', 'tracking', 'user'))
|
'svn', 'shell', 'torrent', 'tracker', 'tracking', 'user'))
|
||||||
);
|
);
|
||||||
|
@ -159,8 +159,8 @@ CREATE TABLE person_roles (
|
||||||
role_status text DEFAULT 'unapproved',
|
role_status text DEFAULT 'unapproved',
|
||||||
internal_comments text,
|
internal_comments text,
|
||||||
sponsor_id INTEGER REFERENCES people(id),
|
sponsor_id INTEGER REFERENCES people(id),
|
||||||
creation TIMESTAMP DEFAULT NOW(),
|
creation TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||||
approval TIMESTAMP DEFAULT NULL,
|
approval TIMESTAMP WITH TIME ZONE DEFAULT NULL,
|
||||||
primary key (person_id, group_id),
|
primary key (person_id, group_id),
|
||||||
check (role_status in ('approved', 'unapproved')),
|
check (role_status in ('approved', 'unapproved')),
|
||||||
check (role_type in ('user', 'administrator', 'sponsor'))
|
check (role_type in ('user', 'administrator', 'sponsor'))
|
||||||
|
@ -180,8 +180,8 @@ CREATE TABLE group_roles (
|
||||||
role_status text DEFAULT 'unapproved',
|
role_status text DEFAULT 'unapproved',
|
||||||
internal_comments text,
|
internal_comments text,
|
||||||
sponsor_id INTEGER REFERENCES people(id),
|
sponsor_id INTEGER REFERENCES people(id),
|
||||||
creation TIMESTAMP DEFAULT NOW(),
|
creation TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||||
approval TIMESTAMP DEFAULT NOW(),
|
approval TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||||
primary key (member_id, group_id),
|
primary key (member_id, group_id),
|
||||||
check (role_status in ('approved', 'unapproved')),
|
check (role_status in ('approved', 'unapproved')),
|
||||||
check (role_type in ('user', 'administrator', 'sponsor'))
|
check (role_type in ('user', 'administrator', 'sponsor'))
|
||||||
|
@ -209,7 +209,7 @@ create table bugzilla_queue (
|
||||||
create table log (
|
create table log (
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
author_id INTEGER references people(id) not null,
|
author_id INTEGER references people(id) not null,
|
||||||
changetime TIMESTAMP default NOW(),
|
changetime TIMESTAMP WITH TIME ZONE default NOW(),
|
||||||
description TEXT
|
description TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ create table requests (
|
||||||
hostname TEXT not null,
|
hostname TEXT not null,
|
||||||
ip TEXT not null,
|
ip TEXT not null,
|
||||||
action TEXT not null default 'trust_all',
|
action TEXT not null default 'trust_all',
|
||||||
last_request TIMESTAMP default now() not null,
|
last_request TIMESTAMP WITH TIME ZONE default now() not null,
|
||||||
approved boolean,
|
approved boolean,
|
||||||
unique (person_id, hostname, ip, action)
|
unique (person_id, hostname, ip, action)
|
||||||
);
|
);
|
||||||
|
@ -249,8 +249,8 @@ cluster requests_last_request_idx on requests;
|
||||||
--
|
--
|
||||||
create table visit (
|
create table visit (
|
||||||
visit_key CHAR(40) primary key,
|
visit_key CHAR(40) primary key,
|
||||||
created TIMESTAMP not null default now(),
|
created TIMESTAMP WITH TIME ZONE not null default now(),
|
||||||
expiry TIMESTAMP
|
expiry TIMESTAMP WITH TIME ZONE
|
||||||
);
|
);
|
||||||
|
|
||||||
create index visit_expiry_idx on visit(expiry);
|
create index visit_expiry_idx on visit(expiry);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue