25 Commits

Author SHA1 Message Date
Elrond
cf27accc9e SQL: fail_metadata as JSON encoded field
fail_metadata used to be a dict in mongo. So a json encoded
field should be okay too.

We could use a pickled field instead, which would be more
flexible.
2012-02-18 19:29:01 +01:00
Elrond
feba5c5287 Drop pre-rendered html: MediaComment.content_html
After a bit of discussion, we decided to drop the
pre-rendered html from the database and render it on
the fly.

In another step, we will use some proper caching method to
cache this stuff.

This commit affects the MediaComment.content_html part.
2012-02-18 12:50:30 +01:00
Elrond
1e72e075f8 Drop pre-rendered html: MediaEntry.description_html
After a bit of discussion, we decided to drop the
pre-rendered html from the database and render it on
the fly.

In another step, we will use some proper caching method to
cache this stuff.

This commit affects the MediaEntry.description_html part.
2012-02-18 12:41:25 +01:00
Elrond
e61ab0998b Drop pre-rendered html: User.bio_html
After a bit of discussion, we decided to drop the
pre-rendered html from the database and render it on
the fly.

In another step, we will use some proper caching method to
cache this stuff.

This commit affects the User.bio_html part.
2012-02-18 12:35:30 +01:00
Elrond
eea6d276bc sql db design suggestions by Svavar Kjarrval
Many thanks go to Svavar Kjarrval who has taken a deeper
look at our current sql db design and made a bunch of
suggestions.  The suggestions are currently put as TODO
items in the docstrings.  This way we can keep track of
them directly where we need it.
2012-02-11 12:11:51 +01:00
Will Kahn-Greene
7f4ebeed76 Fix copyright statements; add LICENSE for EXIF.py 2012-02-08 10:47:08 -05:00
Elrond
51fba99125 Some small SQL model improvements
- Add default for User.email_verified
- Add default for MediaEntry.state
- Let PathTupleWithSlashes store [] as "NULL",
  but not handling the reverse properly yet!
- Add _id alias field to MediaEntry and MediaComment
2012-01-29 23:02:40 +01:00
Elrond
de91730336 Nearly complete support for Tags
These changes allow all of the rest of the code to use tags
in sql as they were used on mongo. It's not efficient at
all, as changing tags usually means to remove all old tags
and adding all new.

The only problem here is: Old slugs for tags are not
removed, because they're shared across all MediaTags and
dropping orphans is not always easy.
2012-01-28 19:32:43 +01:00
Elrond
3e907d5516 Let some code support "media without slug"
The upcoming SQL database will allow having media without a
slug again. This might especially be useful for API
support, where the uploaded image (media) does not have
*any* information to generate a slug from.

This code change mostly allows the sql backend to have no
slug in its model and improves some parts to properly
handle that.

It specifically does not have any web frontend support to
edit/create MediaEntries with no slug.
2012-01-28 13:53:55 +01:00
Elrond
3c43cfc9f9 Move declarative_base Base into base.py
The base class of all models "Base" should be in base.py.
2012-01-26 23:07:39 +01:00
Elrond
c47a03b909 Proper url_to_{prev,next} for SQL
Uses complete sqlalchemy syntax now.
2012-01-22 18:41:06 +01:00
Elrond
02ede85826 Create a fully functional get_comments for SQL
Using proper sqlalchemy syntax instead of the emulated
mongo one.
2012-01-22 18:40:42 +01:00
Christopher Allan Webber
2788e6a164 License "all rights reserved" default should be None/NULL, not empty string 2012-01-21 16:40:39 -06:00
Aaron Williamson
c8035da197 Added migration for license field, resolved conflict in db/sql/models.py 2012-01-19 22:00:08 -05:00
Elrond
fbad3a9fb9 Add copyright header and a bit of pep8ification
Nearly all the sql files missed a copyright header.
So added it!
And while there fixed a few pep8 things.
2012-01-20 00:17:05 +01:00
Aaron Williamson
17c23e15e4 Moved get_license_data to mixin.py, added license to sql media model, added translation tags to license template. 2012-01-18 21:07:55 -05:00
Elrond
02db7e0a83 Add MediaFile table and related infrastructure.
- This adds a new SQL table field type for path tuples.
  They're stored as '/' separated unicode strings.

- Uses it to implement a MediaFile table.

- Add relationship and proxy fields on MediaEntry to give a
  nice media_files "view" there.

- Let the converter fill the MediaFile.
2012-01-11 12:19:03 +01:00
Elrond
f42e49c3ad Add DB Mixin classes and use them
A bunch of functions on the db objects are really more like
"utility functions": They could live outside the classes
and be called "by hand" passing the appropiate reference.
They usually only use the public API of the object and
rarely use database related stuff.

Goals:
- First, simple: Share the code with the SQL objects, so
  that the code doesn't need to be duplicated.
- Second, it might unclutter the db models and make them
  more into "model only" stuff.
- Doesn't really hurt.
2012-01-08 21:55:46 +01:00
Elrond
88e90f41eb SQL Model: Add relationship properties
MediaEntry now has a get_uploader (property) loading the
appropiate User object for the MediaEntry (and caches it).
MediaComment has the same for author as get_author.
2011-12-28 22:58:44 +01:00
Elrond
c6263400cf SQL Model: Forgot MediaEntry.state field
While creating the new SQL model, the "state" field of
MediaEntry was left out. Currently using a plain unicode
string for it.

Maybe should use sqlalchemy.types.Enum?
2011-12-28 22:58:32 +01:00
Elrond
19ed039ba6 Implement _id proxy on sql objects (on User for now)
So that the old code can access the primary key still as
"._id".

Quite simple Python Descriptor thing.
Very generic.
2011-12-28 22:26:00 +01:00
Elrond
7b194a79f0 SQL: mongokit like interface
In trying to ease the migration to SQL, created an
interface to sqlalchemy that looks a lot like the interface
that is currently in use.

*WARNING* Work in progress
2011-12-18 17:07:15 +01:00
Elrond
7c2c56a5ff Little sql model update
- Add title to the MediaEntry
- Rename fp_verification_expire to fp_token_expire to
  follow the mongo model.
2011-12-17 17:34:55 +01:00
Elrond
e365f980ac SQL: Some toys and little fix
Run bin/python mediagoblin/db/sql/models.py and watch the
create tables on a memory sqlite db.

Also unicode strings need unicode defauls. Warning by
sqlalchemy.
2011-12-15 22:11:49 +01:00
Elrond
a8ae9a29c1 Move sql models into db/sql/
So we can play with the sql models, let's put them in a
proper place.
2011-12-15 21:15:21 +01:00