aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/sql
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/db/sql')
-rw-r--r--mediagoblin/db/sql/migrations.py8
-rw-r--r--mediagoblin/db/sql/models.py12
2 files changed, 13 insertions, 7 deletions
diff --git a/mediagoblin/db/sql/migrations.py b/mediagoblin/db/sql/migrations.py
index fb178285..e86109e9 100644
--- a/mediagoblin/db/sql/migrations.py
+++ b/mediagoblin/db/sql/migrations.py
@@ -16,15 +16,12 @@
import datetime
-from sqlalchemy import (MetaData, Table, Column, Boolean, SmallInteger,
+from sqlalchemy import (MetaData, Table, Column, Boolean, SmallInteger,
Integer, Unicode, UnicodeText, DateTime, ForeignKey)
-
-
from mediagoblin.db.sql.util import RegisterMigration
from mediagoblin.db.sql.models import MediaEntry, Collection, User
-
MIGRATIONS = {}
@@ -66,6 +63,7 @@ def add_transcoding_progress(db_conn):
col.create(media_entry)
db_conn.commit()
+
@RegisterMigration(4, MIGRATIONS)
def add_collection_tables(db_conn):
metadata = MetaData(bind=db_conn.bind)
@@ -92,6 +90,7 @@ def add_collection_tables(db_conn):
db_conn.commit()
+
@RegisterMigration(5, MIGRATIONS)
def add_mediaentry_collected(db_conn):
metadata = MetaData(bind=db_conn.bind)
@@ -102,4 +101,3 @@ def add_mediaentry_collected(db_conn):
col = Column('collected', Integer, default=0)
col.create(media_entry)
db_conn.commit()
-
diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py
index 5862f722..ccf03f32 100644
--- a/mediagoblin/db/sql/models.py
+++ b/mediagoblin/db/sql/models.py
@@ -85,6 +85,14 @@ class User(Base, UserMixin):
_id = SimpleFieldAlias("id")
+ def __repr__(self):
+ return '<{0} #{1} {2} {3} "{4}">'.format(
+ self.__class__.__name__,
+ self.id,
+ 'verified' if self.email_verified else 'non-verified',
+ 'admin' if self.is_admin else 'user',
+ self.username)
+
class MediaEntry(Base, MediaEntryMixin):
"""
@@ -362,12 +370,12 @@ class Collection(Base, CollectionMixin):
slug = Column(Unicode)
created = Column(DateTime, nullable=False, default=datetime.datetime.now,
index=True)
- description = Column(UnicodeText)
+ description = Column(UnicodeText)
creator = Column(Integer, ForeignKey(User.id), nullable=False)
items = Column(Integer, default=0)
get_creator = relationship(User)
-
+
def get_collection_items(self, ascending=False):
order_col = CollectionItem.position
if not ascending: