from sqlalchemy.sql import and_
from migrate.changeset.constraint import UniqueConstraint
+
+from mediagoblin.db.extratypes import JSONEncoded
from mediagoblin.db.migration_tools import RegisterMigration, inspect_table
from mediagoblin.db.models import MediaEntry, Collection, User, MediaComment
# oauth1 migrations
-class Client_v0(Base):
+class Client_v0(declarative_base()):
"""
Model representing a client - Used for API Auth
"""
else:
return "<Client {0}>".format(self.id)
-class RequestToken_v0(Base):
+class RequestToken_v0(declarative_base()):
"""
Model for representing the request tokens
"""
token = Column(Unicode, primary_key=True)
secret = Column(Unicode, nullable=False)
- client = Column(Unicode, ForeignKey(Client.id))
+ client = Column(Unicode, ForeignKey(Client_v0.id))
user = Column(Integer, ForeignKey(User.id), nullable=True)
used = Column(Boolean, default=False)
authenticated = Column(Boolean, default=False)
created = Column(DateTime, nullable=False, default=datetime.datetime.now)
updated = Column(DateTime, nullable=False, default=datetime.datetime.now)
-class AccessToken_v0(Base):
+class AccessToken_v0(declarative_base()):
"""
Model for representing the access tokens
"""
token = Column(Unicode, nullable=False, primary_key=True)
secret = Column(Unicode, nullable=False)
user = Column(Integer, ForeignKey(User.id))
- request_token = Column(Unicode, ForeignKey(RequestToken.token))
+ request_token = Column(Unicode, ForeignKey(RequestToken_v0.token))
created = Column(DateTime, nullable=False, default=datetime.datetime.now)
updated = Column(DateTime, nullable=False, default=datetime.datetime.now)
-class NonceTimestamp_v0(Base):
+class NonceTimestamp_v0(declarative_base()):
"""
A place the timestamp and nonce can be stored - this is for OAuth1
"""
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from oauthlib.common import Request
-from oauthlib.oauth1 import (AuthorizationEndpoint, RequestValidator,
- RequestTokenEndpoint, AccessTokenEndpoint)
+from oauthlib.oauth1 import RequestValidator
from mediagoblin.db.models import NonceTimestamp, Client, RequestToken, AccessToken
return client.secret
def get_access_token_secret(self, client_key, token, request):
- client = Client.query.filter_by(id=client_key).first()
access_token = AccessToken.query.filter_by(token=token).first()
return access_token.secret