mirror of
https://github.com/kennethreitz-archive/www.gittip.com.git
synced 2026-06-20 15:20:56 +00:00
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from sqlalchemy.dialects.postgresql.hstore import HSTORE
|
|
from sqlalchemy.schema import Column, UniqueConstraint, ForeignKey
|
|
from sqlalchemy.types import Integer, Text, Boolean
|
|
|
|
from gittip.orm import db
|
|
|
|
class Elsewhere(db.Model):
|
|
__tablename__ = 'elsewhere'
|
|
__table_args__ = (
|
|
UniqueConstraint('platform', 'participant',
|
|
name='elsewhere_platform_participant_key'),
|
|
UniqueConstraint('platform', 'user_id',
|
|
name='elsewhere_platform_user_id_key')
|
|
)
|
|
|
|
id = Column(Integer, nullable=False, primary_key=True)
|
|
platform = Column(Text, nullable=False)
|
|
user_id = Column(Text, nullable=False)
|
|
user_info = Column(HSTORE)
|
|
is_locked = Column(Boolean, default=False, nullable=False)
|
|
participant = Column(Text, ForeignKey("participants.username"), \
|
|
nullable=False)
|
|
|
|
def resolve_unclaimed(self):
|
|
if self.platform == 'github':
|
|
out = '/on/github/%s/' % self.user_info['login']
|
|
elif self.platform == 'twitter':
|
|
out = '/on/twitter/%s/' % self.user_info['screen_name']
|
|
else:
|
|
out = None
|
|
return out
|