131 Commits

Author SHA1 Message Date
Christopher Allan Webber
c802c41af4 Pass in request.urlgen to submit_media so it can update the feed_url stuff
This commit sponsored by Jesus Alberto Rodriguez Chavez.  Thank you!
2013-11-14 13:53:07 -06:00
Christopher Allan Webber
70b2f1ec0c Switching use of submit_media to be keyword arguments in views.py.
This should make things a bit easier for me to fiddle with argument
ordering.

This commit sponsored by Maira Sutton.  Thanks!
2013-11-14 13:41:09 -06:00
Christopher Allan Webber
5d754da741 Breaking out get_upload_file_limits into its own utility.
This commit sponsored by Mikael Nordfeldth.  Thank you!
2013-11-14 11:06:10 -06:00
Christopher Allan Webber
9e15c674ce Refactoring submission utility to make it more generic! Reusable!
This commit sponsored by Joar Wandborg.  Joar, thanks for the many
things you've done for MediaGoblin!
2013-11-13 10:22:46 -06:00
Christopher Allan Webber
56c4ad89eb Merge remote-tracking branch 'refs/remotes/tilly-q/OPW-Moderation-Update'
Conflicts:
	mediagoblin/templates/mediagoblin/user_pages/user.html
	mediagoblin/tests/test_auth.py
	mediagoblin/tests/test_submission.py
2013-10-07 15:48:33 -05:00
tilly-Q
8e91df8734 I did some more code-keeping in this commit. I added a lot of documentation, so
that most of my functions do indeed have effective docstrings. I also changed
the decorators so that they imply eachother in a logical way. I also modified
the one decorator get_media_comment_by_id to be more usable with the variable
urls of mediagoblin.user_pages.views:file_a_report. I also noticed a few tests
had broken, so I went through them and fixed them up, finding that mostly there
were problems in my actual writing of the tests. I also did a few other small
tasks such as creating a new User method to check whether or not a User is ban-
-ned.

===============================================================================
    Added in documentation
===============================================================================
--\  mediagoblin/db/models.py
--\  mediagoblin/decorators.py
--\  mediagoblin/moderation/forms.py
--\  mediagoblin/moderation/tools.py
--\  mediagoblin/moderation/views.py
--\  mediagoblin/user_pages/lib.py

===============================================================================
    Rearranged decorators to be more efficient
===============================================================================
--\  mediagoblin/decorators.py
--| Made it so that user_not_banned is encapsulated in require_active_login
--| Made it so that require_active_login is encapsulated in user_has_privilege
--| Changed get_media_comment_by_id into get_optional_media_comment_by_id. It
  | now returns valid code if the MediaComment id is absent. This makes it pos-
  | -sible to use this decorator for the function:
  |         mediagoblin.user_pages.views:file_a_report

--\  mediagoblin/user_pages/views.py
--| Replaced the mediagoblin.user_pages.views:file_a_comment_report with the
  | decorator mentioned above

--\  mediagoblin/user_pages/routing.py

        -----------------------------------------------------------
        |     took out unnecessary @user_not_banned decorators    |
        -----------------------------------------------------------
--\  mediagoblin/submit/views.py
--\  mediagoblin/user_pages/views.py

===============================================================================
    Fixed broken tests
===============================================================================
--\  mediagoblin/tests/test_auth.py
--\  mediagoblin/tests/test_privileges.py
--\  mediagoblin/tests/test_submission.py

===============================================================================
    Fixed broken code
===============================================================================
--\  mediagoblin/tools/response.py

===============================================================================
    Other Tasks
===============================================================================
--\  mediagoblin/db/models.py
--| Added in User.is_banned() method
--\  mediagoblin/decorators.py
--| Utitilized User.is_banned() method in the user_not_banned decorator

--\  mediagoblin/moderation/views.py
--| Made it impossible for an admin to ban themself.
--| Got rid of a vestigial print statement

--\  mediagoblin/templates/mediagoblin/base.html
--| Made it so the top panel does not show up for users that are banned.

--\  mediagoblin/templates/mediagoblin/moderation/user.html
--| Rearranged the javascript slightly

===============================================================================
2013-09-03 16:19:07 -04:00
tilly-Q
1bb367f613 This is a quick commit. I gave admins the ability to ban or unban users
straight from the moderation.users_detail page. I also changed the
UserBan.expiration_date type from DateTime into Date. I also began work on the
Terms of Service, pulled from another website (which will be cited clearly
before I'm done). I added new tests as well for the ban/unbanning. Lastly,
I added a few `user_not_banned` decorators to relevant views, so banned users
cannot access any pages.
2013-08-29 17:31:19 -04:00
Rodney Ewing
0b95003cd4 use media.get_uploader and fix typo 2013-08-26 06:33:30 -07:00
Rodney Ewing
2188925bab javascript limit validation 2013-08-26 06:33:30 -07:00
Rodney Ewing
a80ea74702 fix after rebase 2013-08-26 06:33:30 -07:00
Rodney Ewing
ecb4512822 max file size 2013-08-26 06:33:30 -07:00
Rodney Ewing
001a50a850 fixed tests and defaults 2013-08-26 06:33:29 -07:00
Rodney Ewing
91a52878cf made no upload limit the default 2013-08-26 06:33:29 -07:00
Rodney Ewing
150bee3f8f typos 2013-08-26 06:33:28 -07:00
Rodney Ewing
c3cce7564a added tests 2013-08-26 06:33:28 -07:00
Rodney Ewing
bdd2242155 added user upload limits 2013-08-26 06:33:28 -07:00
tilly-Q
9e204e49c9 Merge branch 'master' into OPW-Moderation-Update
Conflicts:
	mediagoblin/db/models.py
	mediagoblin/decorators.py
	mediagoblin/routing.py
	mediagoblin/user_pages/views.py
2013-08-20 12:21:13 -04:00
Sebastian Spaeth
bf2dafd1a0 Tweak Celery Task
- Make sure Exceptions are pickleable (not sure if this was not the
  case but this is the pattern as documented in the celery docs.
- Don't create a task_id in the GMG code, but save the one
  implicitely created by celery.
- Don't create a task-id directory per upload. Just store queued uploads
  in a single directory (this is the most controversial change and might
  need discussion!!!)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-08-19 14:42:13 -07:00
Rodney Ewing
b26edfb944 Revert "Leave slug empty until we are sure media processing was successful."
This reverts commit f67611fb485b5a84cedc62b73beb1e551e8cb934.

For some reason, generating a slug here throws an integrity error during
a query when there is a duplicate slug.
2013-08-08 15:49:33 -07:00
Rodney Ewing
f67611fb48 Leave slug empty until we are sure media processing was successful.
Patch submitted by LotusEcho
2013-08-07 16:15:27 -07:00
tilly-Q
52a355b275 Merge branch 'ticket-679' into OPW-Moderation-Update
Conflicts:
	mediagoblin/auth/tools.py
	mediagoblin/auth/views.py
	mediagoblin/db/migration_tools.py
	mediagoblin/db/migrations.py
	mediagoblin/db/models.py
	mediagoblin/decorators.py
	mediagoblin/user_pages/views.py
2013-07-29 18:40:19 -04:00
Rodney Ewing
44082b12d8 Patch by Strum. Ticket #451 - Convert all mongokit style .find, .find_one, .one calls over to SQLAlchemy queries 2013-07-11 14:17:50 -07:00
dunkyp
3aeca53c85 fixes the inability to upload non ascii filenames, werkzeug strips all non ascii chars and returns an empty string. This checks if the filename contains non asciis and if it does generates a uuid for filename. Also the request version of filename is used for generating alternative title for upload
cherry-picked from dunkyp. fixed conflicts and missing import.
2013-07-11 12:52:05 -07:00
tilly-Q
3fb96fc978 This was a simple commit. I changed all references to Groups into Privileges so
as to not conflict with the new federated groups which are also being written.
I also fixed up some of the code in the user_in_group/user_has_privilege decor-
ator. Users are now assigned the default privileges when they sign up, and ass-
iged active once they are activated. I updated the gmg command makeadmin to use
my groups as well. Lastly, I added the decorator to various views, requiring th-
at users belong to appropriate groups to access pages.

--\ mediagoblin/auth/tools.py
--| Added code to assign new users to default privileges

--\ mediagoblin/auth/views.py
--| Added code to assign users to u'active' privilege once the email
  | verification is complete

--\ mediagoblin/db/migrations.py
--| Renamed Group class to Privilege class

--\ mediagoblin/db/models.py
--| Renamed Group class to Privilege class

--\ mediagoblin/decorators.py
--| Renamed function based on the Group->Privilege change
--| Rewrote the function to be, ya know, functional

--\ mediagoblin/gmg_commands/users.py
--| Changed the 'makeadmin' command to add the target user to the admin
  | privilege group as well as affecting 'is_admin' column

--\ mediagoblin/submit/views.py
--| Added the requirement that a user has the 'uploader' privilege in order
  | to submit new media.

--\ mediagoblin/user_pages/views.py
--| Added the requirement that a user has the 'commenter' privilege in order
  | to make a comment.
--| Added the requirement that a user has the 'reporter' privilege in order
  | to submit new reports.
--| Got rid of some vestigial code in the file_a_report function.
2013-07-03 14:46:21 -04:00
Joar Wandborg
2d7b6bdef9 New notifications
- Added request.notifications
- Email configuration fixes
  - Set config_spec default SMTP port to `0` and switch to SSL/non-SSL
    default if `port == 0`
  - Added email_smtp_use_ssl configuration setting
- Added migrations for notification tables
- Added __repr__ to MediaComment(Mixin)
- Added MediaComment.get_entry => MediaEntry
- Added CommentSubscription, CommentNotification, Notification,
  ProcessingNotification tables
- Added notifications.task to celery init
- Fixed a bug in the video transcoder where pygst would hijack the
  --help argument.
- Added notifications
  - views
    - silence
    - subscribe
  - routes
  - utility methods
  - celery task
- Added half-hearted .active comment CSS style
- Added quick JS to show header_dropdown
- Added fragment template to show notifications in header_dropdown
- Added fragment template to show subscribe/unsubscribe buttons on
  media/comment pages
- Updated celery setup tests with notifications.task
- Tried to fix test_misc tests that I broke
- Added notification tests
- Added and extended tests.tools fixtures
- Integrated new notifications into media_home, media_post_comment views
- Bumped SQLAlchemy dependency to >= 0.8.0 since we need polymorphic for
  the notifications to work
2013-06-09 21:18:37 +02:00
Elrond
6c1467d570 Refactor submit util new_upload_entry
This tool creates an initial media entry for a given user.
No magic. It just prefills the license with the user's
default license and adds the user as uploader.
2013-05-21 00:28:37 +02:00
Elrond
adf53036a5 Remove extra indentation left over from previous commit.
This only removes an unneeded extra indentation, left over
from the previous removal of code around.

Extra commit so it is easy to check that it only changes
indentation.
2013-04-27 15:08:42 +02:00
Elrond
2041ceae1f Fix translations for collections and drop useless try.
Don't do:  _("With some value: %s" % value)
Please do: _("WIth some value: %s") % value

Fixed for collection messages.

Also removed a
  try:
    some_code.
  except Exception as e:
    raise

No point in doing that.

Fixing the indentation of some_code comes in an extra
commit, because changing indentation is annoying enough
alone, so don't mix it with other changes.
2013-04-27 15:08:07 +02:00
Christopher Allan Webber
a789b713f5 Switching non-forms back to using normal pass_to_ugettext 2013-04-24 16:40:30 -05:00
Aditi Mittal
665b9c420a Fix-bug-667-Use-lazy_pass_to_ugettext-for-forms. 2013-04-24 16:40:29 -05:00
Elrond
4924b93bac Merge remote-tracking branch 'JDShu/649_use_form_data_field'
* JDShu/649_use_form_data_field:
  Use WTForms data field in user_pages/views.py
  Use WTForms data field in auth/views.py
  auth: whitespace cleanup in views.py
  Use WTForms data field in plugins/oauth/views.py
  Use WTForms data field in submit/views.py
  Use WTForms data field in edit/views.py
2013-03-30 14:42:45 +01:00
Elrond
2ef2f46e73 Refactor file field checking.
When uploading, the file field needs some checks, it seems.
So refactor them into check_file_field and use around.
2013-03-29 12:01:23 +01:00
Hans Lo
c5673a1300 Use WTForms data field in submit/views.py 2013-03-27 23:56:33 -04:00
Sebastian Spaeth
066d49b2c1 user.get('moo') -> user.moo
User fields are always existent, so there is no need to .get() them,
just use them directly.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-22 22:18:08 +01:00
Christopher Allan Webber
79f7cfd900 Merge remote-tracking branch 'refs/remotes/spaetz/521_license_preference' into mergetest 2013-01-22 13:43:02 -06:00
Mark Holmquist
dc4dfbde35 Add a license preference field
This feature is absolutely necessary. Now a user can simply define
their default license and quickly go through a form, as opposed to
stopping to click on the select and choosing the same option over
and over again.

Also added DB migration for the field, so that's working now, too.

Rebased by Sebastian and made the default value to be unicode.

Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 21:34:04 +01:00
Sebastian Spaeth
c7b3d070b6 Don't pass request into run_process_media
People(tm) want to start run_process_media from the CLI and might not
have a request object handy. So pass in the feed_url into
run_process_media rather than the request object and allow the feed url
to be empty (resulting in no PuSH notification at all then).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-15 15:03:00 +01:00
Sebastian Spaeth
2cfffd5ed8 Make PuSHing the Pubhubsubbub server an async task (#436, #585)
Notifying the PuSH servers had 3 problems. 

1) it was done immediately after sending of the processing task to celery. So if celery was run in a separate
process we would notify the PuSH servers before the new media was processed/
visible. (#436)

2) Notification code was called in submit/views.py, so submitting via the
   API never resulted in notifications. (#585)

3) If Notifying the PuSH server failed, we would never retry.

The solution was to make the PuSH notification an asynchronous subtask. This
way: 1) it will only be called once async processing has finished, 2) it
is in the main processing code path, so even API calls will result in
notifications, and 3) We retry 3 times in case of failure before giving up.
If the server is in a separate process, we will wait 3x 2 minutes before
retrying the notification.

The only downside is that the celery server needs to have access to the internet
to ping the PuSH server. If that is a problem, we need to make the task belong
to a special group of celery servers that has access to the internet.

As a side effect, I believe I removed the limitation that prevented us from
upgrading celery.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-15 14:53:08 +01:00
Elrond
b228d89715 prepare_queue_task: Take app not request.
First rename prepare_entry to prepare_queue_task, because
this is really more like what this thing does.

Thanks to Velmont for noting that we do not need a request
in here, but an "app" is good enough. Which means, that
this stuff can be called from tool scripts too.
2012-12-26 23:42:26 +01:00
Elrond
8eb47d02d9 Processing: Factor out prepare_entry.
prepare_entry handles the task_id setup and generating a
queue filename and file. it returns the queue file.
2012-12-26 23:42:26 +01:00
Elrond
86bb44ef12 Factor out the actual calling of the processing.
Calling the processing task and handling the exceptions is
easy, but has a bunch of caveats, so factor it out into an
easy callable function.
2012-12-26 23:42:26 +01:00
Elrond
be1f0f7d33 upload refactor: push url handling
Start to refactor our upload handling in main submit and
the api. Start factoring out the handling of PuSH url
handling.
2012-12-26 23:42:26 +01:00
Elrond
ac8212fe65 Remove mongo style .id = ObjectId()
On SQL we can't generate the primary key on our own. So
just remove this stuff.
2012-12-24 00:07:24 +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
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
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
f1d06e1d6c Switch from webob.Request to werkzeug.wrappers.Request 2012-09-29 21:08:20 +02:00
Aaron Williamson
be5be1154f Added basic collection functionality 2012-09-18 18:10:36 +02:00
Brett Smith
7a258b1408 Fix docstring typo. 2012-07-08 10:04:58 -04:00
Joar Wandborg
deea3f6661 Merge remote-tracking branch 'joar/audio+sniffing'
Conflicts:
	mediagoblin/media_types/image/processing.py
	mediagoblin/media_types/video/__init__.py
	mediagoblin/media_types/video/processing.py
	mediagoblin/tests/test_submission.py
2012-03-27 12:05:09 +02:00