2550 Commits

Author SHA1 Message Date
Christopher Allan Webber
79f7cfd900 Merge remote-tracking branch 'refs/remotes/spaetz/521_license_preference' into mergetest 2013-01-22 13:43:02 -06:00
Joar Wandborg
55a04f01b8 Moved MediaComment form descriptions to apt. place 2013-01-22 14:38:53 +01:00
Sebastian Spaeth
69b5623552 Also set login_failed in case of form errors
If we send a POST request to the login page which contained form errors
(e.g. a too short password), the variable "login_failed" was not set to
true. This condition was tested by the test suite however, so we should
make sure that login_failed is set even if the form failed to validate.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-21 17:15:39 +01:00
Sebastian Spaeth
a89df96132 Restructure ForgotPassword view
1) Remove mongo limitations (no 'or' when querying for either username
or email).

2) Lost password function revealed if an user name or email address
   is registered, which can be considered a data leak.
   Leaking user names is OK, they are public anyway, but don't reveal
   lookup success in case the lookup happened by email address.
   Simply respond: "If you have an account here, we have send you
                    your email"?

3) username and email search was case sensitive. Made username search
   case insensitive (they are always stored lowercase in the db).
   Keep email-address search case sensitive for now. This might need
   further discussion

4) Remove a whole bunch of indention in the style of:
   if no error:
        ...
        if no error:
            ...
            if no error:
                actually do something in the regular case

   by restructuring the function.

5) Outsource the sanity checking for username and email fields into the
   validator function. This way, we get automatic case sanity checking
   and sanitizing for all required fields.

6) Require 5-char password and fix tests

   Originally, the Change password form required a password between 6-30
   chars while the registration and login form did not require anything
   special. This commit introduces a common minimum limit for all forms
   which breaks the test suite which uses a 5 char password by
   default. :-).  As 5 chars seem sensible enough to enforce (people
   should be picking much longer ones anyway), just reduce the limit to
   5 chars, thereby making all tests pass.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-21 17:14:59 +01:00
Sebastian Spaeth
0f9cf6ef32 Normalize the email address in the same way in all places
We were case normalizing the email address for registration, but not at
all for the forgotten password retrieval. Make a
tools.mail.normalize_email helper that can be used to normalize the
email in the same way in all places.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-21 15:38:57 +01:00
Christopher Allan Webber
0c97a82556 Merge remote-tracking branch 'refs/remotes/spaetz/436_celery_push' 2013-01-20 13:13:39 -06:00
Sebastian Spaeth
9e9d908325 Sanitize slug input on media edit
Previously we allowed EVERYTHING, even slashes as slug when editing the media.
Make sure we slugify the input to sanitize it.

(+ string formdata is unicode, so there is no need to convert it)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-18 21:24:19 +01:00
Elrond
d92fbdc4ea Add (failing) test for editing the slug.
This test fails, because it tries to set a slug with an "="
in it. And tests that the "=" gets replaced by "-".

Well, it currently is not being replaced.

The next (cherry picked) commit by Sebastian Spaeth fixes
this test!
2013-01-18 21:21:42 +01:00
Elrond
afbfd40578 Enable foreign key checking on sqlite.
sqlite normally does not check foreign key referential
integrity. But it can do so.
So let's use it. Better safe than sorry.
2013-01-18 18:42:52 +01:00
Elrond
5bae4af14e Turn comment list into a real <ul>.
Well, I like semantic html. And the list of comments, well,
is now a list: <ul>.
Using list-style:none it looks nearly the same as before.
2013-01-18 13:05:57 +01:00
Elrond
cd75b2280f Add some simple collection test. 2013-01-18 11:42:56 +01:00
Elrond
1be247b36e Rename get_test_app to get_app.
nosetests runs everything that even vaguely looks like a
test case... even our get_test_app. And as it is imported
everywhere... it is run everywhere as a test case. Renaming
it saves us about 10+ tests and a few seconds of time.
2013-01-18 11:40:40 +01:00
Elrond
4637d50cfc Remove useless spaces in comment stuff.
When rendering a comment, we had a lot of whitespace. And
some of it made it into the rendered page:
"""<a href=...>abc </a>""" the trailing space gets
rendered and looks ugly.
2013-01-17 23:57:41 +01:00
Elrond
7341cc8e34 Translate account deletion.
Mark all the strings in the new account deletion stuff for
translation.
2013-01-17 23:57:40 +01:00
Elrond
7d16a01bae Fix linking to comments.
when linking to a comment in a MediaEntry, the page did not
contain a <a name="comment"> because, well:

We fetched a string comment-id from the routing. And the
pagination code tried to compare that to the int id on the
comment.

Fix is to let routing fetch an int from the url. Easy.

Relatedly remove duplicated comment_id fetching from the
URL in the view.
2013-01-17 23:57:40 +01:00
Christopher Allan Webber
00cf28da21 Merge branch 'master' of gitorious.org:mediagoblin/mediagoblin 2013-01-17 15:51:30 -06:00
Sebastian Spaeth
ba5ea989a5 Return to media collection page if no collection selected
schendje rightly pointed out that we should not return to the media
homepage if we did not select a collection on the "collect" page, but
should actually return to the collect page.

This is an improvement of the user experience ;-)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 22:39:22 +01:00
Elrond
626a093ccc Move workbench into tools directory. 2013-01-17 22:15:57 +01:00
Elrond
9d8285864a Remove DEFAULT_WORKBENCH_DIR.
We never used this.
Removed, as okayed by cwebber.
2013-01-17 22:11:05 +01:00
Christopher Allan Webber
c813f0bd57 Merge remote-tracking branch 'refs/remotes/spaetz/565_workbench_cleanup' 2013-01-17 15:02:52 -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
Jef van Schendel
49745d5138 Add "Browse collections" link to profile pages 2013-01-17 20:04:22 +01:00
Christopher Allan Webber
3c912132d6 adding back dropdown.js now that we have, well, a dropdown again :) 2013-01-17 11:53:32 -06:00
Christopher Allan Webber
d1d535602c Merge remote-tracking branch 'refs/remotes/origin/533-new-dropdown'
Conflicts:
	mediagoblin/templates/mediagoblin/base.html
	mediagoblin/templates/mediagoblin/root.html
2013-01-17 11:47:29 -06:00
Christopher Allan Webber
30af7ce6ad Merge commit '9408938' from 565_workbench_cleanup (spaetz) 2013-01-17 11:12:13 -06:00
Jef van Schendel
10d2419764 CSS edits to dropdown menu; added log out button for unverified users 2013-01-17 16:15:03 +01:00
Jef van Schendel
7d996a269c Change position of "Delete account" link, put it below the form 2013-01-17 13:35:45 +01:00
Sebastian Spaeth
2e7dda8167 Better "delete my account" placement
Improve the "delete my account" link location by not placing it outside the
main content bar. It still might require more tweaks.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 12:47:38 +01:00
Sebastian Spaeth
6deb589d0b Introduce user_deletion test.
Delete a user via web interface and see if it works. TODO: this does not test
that related entries are also cleaned up and we should extend the test to
do so.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 12:19:52 +01:00
Sebastian Spaeth
380f22b859 Allowing to delete a user account (#302)
Add a "Delete user account" template and link to it from the user
account settings page.

Create a delete_account function and fill in most blanks. We can now
successfully delete our own account.

Thanks to Elrond for catching a stray csrf_exempt in a previous iteration
of this patch.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 12:19:52 +01:00
Sebastian Spaeth
3809a8b8e2 import db.sql.util -> db.util
Merging an old branch, I reintroduced an import of db.sql.util rather than
db.util. Fixing the glitch.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 12:19:33 +01:00
Sebastian Spaeth
8c33fc7505 Merge branch '540_User_delete_deletes_related_entries' 2013-01-17 11:52:22 +01:00
Sebastian Spaeth
03b4fc500c Implement User.delete() (#540)
Set User.collections to her Collections using the backref feature.
This way we can iterate a user's collections and delete them all.

Delete all MediaEntries/Files/attachments/comments/collections etc
before finally deleting the User object. This is the backend work for
issue 302 (allow a user to delete ones own account)
2013-01-17 11:48:49 +01:00
Sebastian Spaeth
242776e363 Implement Collection.delete()
Deleting a Collection should automatically delete all containing items.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 11:48:49 +01:00
Sebastian Spaeth
fdc34b8ba7 Implement MediaEntry().delete() (#540)
Deleting a MediaEntry instance will automatically
delete all related comments and files/attachments. This moves
implementation logic out of views.py and allows to make use of this
functionality when e.g. deleting a User() account.

Whenever a MediaEntry entry is deleted, this will also sql-delete
the corresponding MediaFile entry.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 11:48:07 +01:00
Sebastian Spaeth
c00e18fe49 Do not read complete videos in RAM (#419)
We were reading the complete "medium" "thumbnail" and "original"
in RAM via dst.write(src.read()). Just call the appropriate storage
methods copy_local_to_storage which are responsible for streaming
local files efficiently.

The efficiency of this patch depends on the separate branch that
actually implements chunked copying for Storage().copy_local_to_storage()
2013-01-16 20:19:26 +01:00
Sebastian Spaeth
9408938bcc Add @get_workbench test
Test the decorator function and proper cleanup after it's usage.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-16 20:19:26 +01:00
Sebastian Spaeth
bd6fe97746 Shorten Workbench(Manager) method names
1) destroy_self() is a horrible function name, make it "destroy".
workbench.destroy() is descriptive enough.

2) WorkbenchManager.create_workbench() -> WorkbenchManager.create()
  We use the pattern "with workbench_manager.create() as workbench:"
  No need to mention workbenches three times in a row...

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-16 20:19:25 +01:00
Sebastian Spaeth
45ab3e07ef Switch over media processor to use the get_workbench decorator (#565)
This makes workbench getting more convenient by eliminating some
boilerplate and more robust by cleaning the workbench up even if processing
ends with an Exception.

Finally, this fixes the bugs in the ascii and video backends to never call
workbench.destroy, so those workbenches were never cleaned up.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-16 20:19:23 +01:00
Sebastian Spaeth
f91dcc9d96 Implement @get_workbench decorator
This passes in a Workbench() via the 'workbench' keyword argument, and
conveniently cleans it up after the function has finished. 2 out of our 5
backends forgot to clean up their workbench, so this is clearly needed :-).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-16 20:14:55 +01:00
Sebastian Spaeth
c11c1994e6 Make Workbench() a context manager
This allows us to use "with Workbench() as foo: do_stuff..."
No consumers have been switched yet though.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-16 20:14:55 +01:00
Christopher Allan Webber
f26c097d3e Make the workbench destroy itself for video processing also. 2013-01-16 12:12:57 -06:00
Christopher Allan Webber
3c5f583707 Merge remote-tracking branch 'refs/remotes/spaetz/561_use_workbench_not_tempfiles' 2013-01-16 11:23:38 -06:00
Christopher Allan Webber
27aebe05a6 Merge remote-tracking branch 'refs/remotes/elrond/misc/use_media_id' 2013-01-16 11:06:22 -06:00
Stefano Zacchiroli
4f8f0353b1 collection browsing: rename view/template user_collections -> collection_list
Rationale, avoid confusion between views user_collection and user_collections
(note trailing "s"). Ditto for the collection(s).html templates.
2013-01-15 23:28:10 +01:00
Stefano Zacchiroli
947f38c0b9 collection browsing: remove pagination support
rationale: we do not expect hundreds of collection (and it was likely broken
anyhow)

thanks to Elrond der Elbenfuerst for pointing this out
2013-01-15 23:04:37 +01:00
Stefano Zacchiroli
413fc1c266 collection browsing: drop atom feed from page template
rationale: it refers to something else than a "collection feed"

thanks to Elrond der Elbenfuerst for pointing this out
2013-01-15 21:43:12 +01:00
Stefano Zacchiroli
b0cc1ade40 collections: add support to browse existing collections
- add a route at /u/<user>/collections/ (note trailing 's') that lists
  all existing collections
- move there the "Create new collection" link, if the user is logged in
- add a new link "Browse collections" from root.html
2013-01-15 21:40:05 +01:00
Tiberiu C. Turbureanu
cf764377df #571: Fixed. Display collection description with Markdown formatting. 2013-01-15 18:03:06 +02:00
Sebastian Spaeth
fd61aac7c7 Unbreak 301 responses
The move to werkzeug routing went pretty smooth, but one thing was
broken by accident: URLs without final slash result in a 301
werkzeug.routing.RequestRedirect response. We displayed it as a generic
error page rather than actually sending the redirect. Do that. One thing
it does though is to skip all meddlewares, which should be OK for a 301
response, but might need rework if we decide otherwise. With this, 301
responses with lacking final slash are unbroken again.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-15 16:52:22 +01:00