1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 from mediagoblin
.db
.base
import Base
20 from mediagoblin
.db
.models
import Collection
, User
22 from sqlalchemy
import (
23 Column
, Integer
, ForeignKey
, Unicode
, UnicodeText
, DateTime
)
24 from sqlalchemy
.orm
import relationship
, backref
27 __tablename__
= "core__blogs"
28 id = Column(Integer
, primary_key
=True)
29 title
= Column(Unicode
)
30 description
= Column(UnicodeText
)
31 author
= Column(Integer
, ForeignKey(User
.id), nullable
=False, index
=True)
32 created
= Column(DateTime
, nullable
=False, default
=datetime
.datetime
.now
,
36 BACKREF_NAME
= "blogpost__media_data"
39 class BlogpostData(Base
):
40 __tablename__
= "blogpost__mediadata"
42 # The primary key *and* reference to the main media_entry
43 media_entry
= Column(Integer
, ForeignKey('core__media_entries.id'),
45 get_media_entry
= relationship("MediaEntry",
46 backref
=backref(BACKREF_NAME
, uselist
=False,
47 cascade
="all, delete-orphan"))
50 DATA_MODEL
= BlogpostData
51 MODELS
= [BlogpostData
]