112 Commits

Author SHA1 Message Date
Sebastian Spaeth
20be9bb77d Remove custom GMQuery class
We provided a custom GMQuery class that offered a .sort() method for
compatibility with the Mongo syntax. Now that we have settled for sqlalchemy
which uses the order_by() method, we can safely remove this custom class
and move a little closer to "pure" and native sqlalchemy usage.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-07 13:52:37 +01:00
Sebastian Spaeth
b0c8328e54 Move db.sql.models* to db.models* 2013-01-07 11:44:29 +01:00
Sebastian Spaeth
0efe9e2796 Remove mediagoblin.db.sql.fake.DESCENDING
This is the last remnant that requires us to keep db.sql.fake.py. Use
ModelName.desc() or sqlalchemy.sql.expression.desc(column) to achieve
descending sorts.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-07 11:15:04 +01:00
Sebastian Spaeth
71717fd531 Remove ObjectId from the tree
This was one of the last remaining Mongo holdouts and has been removed from
the tree herewith. Good bye, ObjectId.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-25 20:52:25 +01:00
Elrond
b39d1f2351 Mongo removal: Remove the validate=True arg to obj.save()
all callers were forced to use validate=True anyway. So
remove this useless stuff.
2012-12-24 00:07:24 +01:00
Sebastian Spaeth
dfc23dd1e1 Compare user by id not object equality
Elrond correctly remarked that we should be comparing user by id
and not by comparing User objects (as I mistakenly did). He is
right, of course!

Also removing the 2 stray debug prints that were left over.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-23 12:12:11 +01:00
Sebastian Spaeth
2fb36dac31 Improve sqlalchemy filter rules
Thanks to Elrond's review. 1) Use filter_by more consistently
rather than mixing filter and filter_by. 2) Add multiple AND
conditions in the same filter rule rather than using separate
ones. 3) The atom feeds used filter_by(Modelname.attr == ...)
which was the wrong pattern, of course.

Thanks for repairing my junk Elrond!

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-23 12:08:51 +01:00
Sebastian Spaeth
af008743ca Remove mongolisms from user_pages.view #451 2012-12-21 11:30:29 +01:00
Sebastian Spaeth
f6bc033603 Refactor media_collect
Remove lots of MOngolisms. Refactor this to remove some indentation
levels. Don't do:
 if success:
   ...
   if success:
     ....
     if success:
     ...
2012-12-21 11:29:39 +01:00
Sebastian Spaeth
950124e640 webob.HTTPFound --> MG.tools.redirect
Transition away from webob.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:11:40 +01:00
Sebastian Spaeth
5c2b84869f Move DBModel._id -> DBModel.id
We were refering to model._id in most of the code base as this is
what Mongo uses. However, each use of _id required a) fixup of queries:
e.g. what we did in our find() and find_one() functions moving all
'_id' to 'id'. It also required using AliasFields to make the ._id
attribute available. This all means lots of superfluous fixing and
transitioning in a SQL world.

It will also not work in the long run. Much newer code already refers
to the objects by model.id (e.g. in the oauth plugin), which will break
with Mongo. So let's be honest, rip out the _id mongoism and live with
.id as the one canonical way to address objects.

This commit modifies all users and providers of model._id to use
model.id instead. This patch works with or without Mongo removed first,
but will break Mongo usage (even more than before)

I have not bothered to fixup db.mongo.* and db.sql.convert
(which converts from Mongo to SQL)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 00:30:48 +01:00
Sebastian Spaeth
e2ae0f5920 Fix user collection gallery
We were fetching the user collection gallery by slug only, so if two users
had the same collection slug, we would not have been sure which one we'd get.

Fix this by explicitly only fetching the specific user's collections. Also
switch over the view function to make use of the new active_user_from_url
decorator that fetches the User() object for us.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-05 13:55:31 +01:00
Sebastian Spaeth
64c2a4002c Switch over the user gallery to the active_user_from_url decorator
This switches the user gallery page over to use the new decorator, and
cleans up the queries to be in proper sqlalchemy format rather than the
old mongo format.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-05 13:55:30 +01:00
Sebastian Spaeth
5f8b4ae895 make media_manager a property of MediaEntry in mixin.py
In all cases where get_media_manager(_media_type_as_string) was called in
our code base we ultimately passed in a "MediaEntry().media_type" to get
the matching MEDIA_MANAGER. It so makes sense to make this a function of
the MediaEntry rather than a global function in mediagoblin.media_types and
passing around media_entry.media_type as arguments all the time.

It saves a few import statements and arguments. I also made it so the
Media_manager property is cached for subsequent calls, although I am not too
sure that this is needed (there are other cases for which this would make
more sense)

Also add a get_media_manager test to the media submission tests. It submits
an image and checks that both media.media_type and media.media_manager
return the right thing. Not sure if these tests could not be merged with an
existing submission test, but it can't hurt to have things explicit.

TODO: Right now we iterate through all existing media_managers to find the
right one based on the string of its module name. This should be made a simple
dict lookup to avoid all the extra work.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-04 15:15:41 +01:00
Joar Wandborg
111a609df5 Replaced all request.POST with request.form, ...
- Fixed error handling in OAuth plugin
- Changed request.POST file fields to request.files
2012-09-29 21:08:20 +02:00
Joar Wandborg
6d1e55b262 Style fixes 2012-09-18 18:19:26 +02:00
Aaron Williamson
c9ac6841c4 Fixed post-collect redirect to always take user to image collected. 2012-09-18 18:10:36 +02:00
Aaron Williamson
cdb35b9717 Reference collection creator through already-existing collection_item's foreign key 2012-09-18 18:10:36 +02:00
Aaron Williamson
be5be1154f Added basic collection functionality 2012-09-18 18:10:36 +02:00
Joar Wandborg
6471291575 Panel improvements
- Added progress meter for video and audio media types.
- Changed the __repr__ method of a MediaEntry to display a bit more
  useful explanation.
- Added a new MediaEntry.state, 'processing', which means that the task
  is running the processor on the item currently.
- Fixed some PEP8 issues in user_pages/views.py
- Fixed the ATOM TAG URI to show the correct year.
2012-07-11 00:36:42 +02:00
Brett Smith
81d3c4cf1c Merge branch 'master' into 201207-testfixes 2012-07-08 11:07:02 -04:00
Brett Smith
5bd0adebd0 Prevent non-Unicode SQLAlchemy warnings in most submission tests.
This commit  makes test_submission mostly warning-clean.
2012-07-08 10:04:06 -04:00
Jorge Araya Navarro
fb2fbe2c0a fixing bug #255 as Joar and CWebber ask me to do :) 2012-06-28 22:13:26 -06:00
Joar Wandborg
00722c9908 Fixed some comment notification code for compliance with SQL
* Pulled instance name in notification email from config
2012-06-10 18:18:26 +02:00
Joar Wandborg
879ff4bde6 Merge remote-tracking branch 'is_derek/bug405_email_notifications_for_comments' into notifications-merge
Conflicts:
	mediagoblin/db/mongo/migrations.py
2012-06-10 15:53:46 +02:00
Elrond
32adc9b2a7 Panel: Find "unprocessed" not "processing" entries.
Our entries in the queue are marked as "unprocessed" and
not as "processing" as the panel code wanted it to be. So
search for the correct string.
2012-03-21 12:17:57 +01:00
Christopher Allan Webber
94e6052375 Merge branch 'master' into derek-moore-bug405_email_notifications_for_comments
Conflicts:
	mediagoblin/db/mongo/migrations.py
2012-03-18 12:12:41 -05:00
Brett Smith
a0a7f87f62 When media is deleted, delete associated comments too.
The actual code is just a simple for loop; there might be a better
implementation but this is a fine start.  I also extended test_delete to
check this too.
2012-03-17 17:53:00 -04:00
Derek Moore
252eaf21d5 These are changes for issue #405, add email comment notification. 2012-03-15 16:38:56 -07:00
Elrond
8efcd40558 Dot-Notation: MediaComment and some random places 2012-02-26 19:19:48 +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
Will Kahn-Greene
7f4ebeed76 Fix copyright statements; add LICENSE for EXIF.py 2012-02-08 10:47:08 -05:00
Christopher Allan Webber
cf29e8a824 It's 2012 all up in here 2012-02-02 09:44:13 -06:00
Michele Azzolari
bb025ebda1 As per spec, we permit to have more then 1 hub 2012-01-12 11:05:05 +01:00
Michele Azzolari
7f251b037b As suggested by Elrond, we use only one setting 2012-01-12 00:00:28 +01:00
Michele Azzolari
5b1a7bae3c Added PuSH capability 2012-01-11 15:48:37 +01:00
Michele Azzolari
1df68a3524 Fixed #724 and added extra infos to the atom feed (author uri and links to the html version of each entry) 2012-01-10 08:10:53 -06:00
Elrond
0575175846 Turn media.get_uploader into a property
sqlalchemy gives autoloading (hopefully caching) link to
other objects as properties. So turn get_uploader on the
current mongo based stuff into a property to ease
transition.
2011-12-27 20:41:31 +01:00
Elrond
4deda94a38 Replace media.get_uploader()._id by media.uploader
media.get_uploader()._id loads a complete user object
without actually needing it, because media.uploader already
has the id!
2011-12-24 19:27:29 +01:00
Elrond
f4ee839939 Dot-Notation for MediaEntry.media_type 2011-12-05 21:08:58 +01:00
Elrond
bec591d85b Dot-Notation for Users.is_admin 2011-12-05 21:08:57 +01:00
Elrond
7a3d00ec21 Dot-Notation for Users.status 2011-12-05 21:08:57 +01:00
Elrond
5a4e3ff1e2 Dot-Notation for Users.username 2011-12-05 21:08:57 +01:00
Jef van Schendel
eae7d0585f Changed comment error message wording slightly. Btw, should we translate these things? 2011-12-03 01:19:15 +01:00
Christopher Allan Webber
99d2ac1d83 Merge remote-tracking branch 'remotes/jwandborg/master' 2011-11-24 15:24:58 -06:00
Elrond
3018832153 Rename MediaEntry.uploader() to .get_uploader()
The .uploader() method conflicts with the uploader database
field. As we're moving to .FIELD for db field access, this
is a relevant conflict.

So renaming .uploader() to .get_uploader()
2011-11-22 22:29:37 +01:00
Elrond
ea33f63635 Wrap long line.
Nothing else.
2011-11-22 21:48:56 +01:00
Pablo J. Urbano Santos
56bfd91ab4 Added a message noticing the user the image has been successfully
deleted.
2011-11-22 21:07:09 +01:00
Pablo J. Urbano Santos
d0ba62e2e7 Fixes #597. Add a visible error when user tries to delete an image
without cheking the "I'm sure" checkbox.
2011-11-22 20:29:33 +01:00