test plan:
0. render API documentation
1. note the new Copy Folder and Copy File endpoints
in the Files API documentation
2. exercise these endpoints to copy folders and files
(a) inside a course
(b) from user files into course files
(c) from course files into user files
3. confirm that, when copying a folder to a destination
that already includes a folder with the same name,
the new folder is renamed
4. confirm that, when copying a file to a destination
that already includes a file with the same name,
and on_duplicate is not specified, the call returns
an "already exists" error
5. confirm that, when copying a file to a destination
that already includes a file with the same name,
and on_dupliate _is_ specified, the parameter is
honored (to either overwrite or rename)
fixes CNVS-17812
Change-Id: Ibf32f9b568bfe8e239403f9064ae3a9d69806aa4
Reviewed-on: https://gerrit.instructure.com/48185
Reviewed-by: Dan Minkevitch <dan@instructure.com>
Tested-by: Jenkins
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
fixes CNVS-18146
Test Plan:
* Enable "Better File Browsing" feature flag
* Go to any course's Files page as an admin
or teacher
* Click the "+ Folder" button, then press enter
on the input (leaving the folder's name blank)
* Repeat the above step 10 or more times
* The folders created should be named "New Folder",
"New Folder 2", "New Folder 3", etc, and should
continue past "New Folder 10", "New Folder 11",
"New Folder 12", up to however many you created
Change-Id: I151c9baa8b6fd6176c434144f10165f23a600a22
Reviewed-on: https://gerrit.instructure.com/47709
Tested-by: Jenkins
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
When a file is uploaded via the WikiSidebar,
it can be uploaded multiple times with the same
name. This commit adds an iterator to uploaded
files so that if the file has already been uploaded
or a file with the same name already exists,
an iterator is added to the newly uploaded file
to prevent duplicates (e.g. file.jpg, file-1.jpg, file-2.jpg).
fixes CNVS-17361
Test Plan:
* Enable "Better File Browsing" feature flag
* Go to any course's Pages section (as admin/teacher)
* Create a new page or edit an existing one
* On the create/edit page, select the "Files"
tab from the WikiSidebar on the right
* Click "+ Upload a new file"
* Select some file, then upload it
* Upload the same file again, multiple times
* Go to that course's Files page
* In the course files (or wherever you chose to
upload the file), the file you uploaded should be
there, along with additional files with the same name
followed by an iterator (e.g. yourfile.png, yourfile-1.png,
yourfile-2.png, etc)
Change-Id: Iaa1307305659bf3b1b38991f0981ac6e48423209
Reviewed-on: https://gerrit.instructure.com/45550
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
For New Files. Any new, unnamed folder
will now be named 'New Folder' instead
of just 'folder'.
closes CNVS-17122
Test Plan:
* Enable "Better File Browsing" feature flag
* Go to any course's Files page as a teacher
* Click the "+ Folder" button
* Press enter on the text input that becomes
focused, leaving it blank.
* The folder created should be called "New Folder"
* Create another new folder
* That folder should be named "New Folder 2"
Change-Id: If58d0979731a82852b39cf5c443fd29aa5e277be
Reviewed-on: https://gerrit.instructure.com/45155
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
Blank folder names are now named "folder" by default.
A folder created with the same name as one that already
exists now attaches an iterator (e.g. "folder 2")
A folder cannot be expanded if the name hasn't been set yet.
fixes CNVS-16842, CNVS-16910
Test Plan:
1. Enable "Better File Browsing"
2. Go to any course's Files page
3. Click the "+ Folder" button to add a new folder
4. Leave the name text field blank
5. Press Enter
6. A folder should be created with the name "folder"
7. Repeat Steps 3-5
8. A new folder should be created with the name "folder 2"
9. Repeat Steps 3-5 but instead give this folder a name
10. Repeat Step 9 (with the same name you used before)
11. Two folders should exist, one with whatever name
you gave it, and one with that same name, but with "2"
added to it.
Change-Id: I23ea30eb0474494a6b9bc3cbcf60f560d3735d18
Reviewed-on: https://gerrit.instructure.com/44490
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Anna Koalenz <akoalenz@instructure.com>
Reviewed-by: James Williams <jamesw@instructure.com>
Product-Review: Cosme Salazar <cosme@instructure.com>
test plan:
* try to update the name for a root folder of a course
* should give an error, instead of catastrophically
freezing your server
fixes #CNVS-14868
Change-Id: If0a1c305f3103f3bb7e17ff6ceead7db2e2173de
Reviewed-on: https://gerrit.instructure.com/39512
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
fixes CNVS-13260
test plan:
- in course, group, and user context:
- ensure /api/v1/{context}/folders/by_path alone returns
an array containing only the context's root directory
(usually named "course files" or "my files", etc.)
- ensure /api/v1/{context}/folders/by_path/{path} returns
an array containing the context's root directory
followed by the folders in the path
Change-Id: Iecf6de0aed301041f8aa55b3d13123e0c503844e
Reviewed-on: https://gerrit.instructure.com/35352
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
instead of passing an :exportable option to
ActiveRecord::Associations, simply define a constant
on the class containing exportable associations and
attributes. This is due to :exportable breaking
ActiveRecord, and we can't simply monkey-patch in
config/initializers because models are included in
migrations before the initializers are run
Change-Id: I11f1a6b4570c397d8e01010c517bc6efdac7afca
Reviewed-on: https://gerrit.instructure.com/33235
Reviewed-by: Braden Anderson <banderson@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
QA-Review: Anthus Williams <awilliams@instructure.com>
fixes CNVS-11494
test plan:
0. on both rails2 and rails3...
1. find the "Resolve path" endpoint in the API docs
2. in Course, Group, and User contexts:
a. create some folders and subfolders
b. use the new endpoint and confirm that
(1) a full path such as "course files/folder/subfolder"
returns an array containing each Folder in order;
(2) status 404 is returned if the path doesn't exist
(even if a partial match exists);
(3) status 404 is returned if the requested folder or
a parent folder is locked, the caller is a student,
in Course context
(4) users not authorized to access files receive a 401
Change-Id: I6438317fc8c847fa0a5c140bc9e91890d727514c
Reviewed-on: https://gerrit.instructure.com/33447
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
so that they don't try to connect to the db during initialization
Change-Id: I91616c73b0881ffa0782a7d39be47abd51436d86
Reviewed-on: https://gerrit.instructure.com/29289
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Anthus Williams <awilliams@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
fixes CNVS-9331
instead, as appropriate, use one of (or a combination of, if necessary):
* instance variable caching
* Rails.cache
* query caching (implicit)
also:
* remove the buggy cc.active_pseudonyms (didn't account for
sharding) in favor of cc.user.all_active_pseudonyms
* streamline assignments in the menu to not need to construct method
names
test-plan: N/A
Change-Id: Id0dec60464a283985e39493b90711b32cb5cca82
Reviewed-on: https://gerrit.instructure.com/26936
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
also force deleted_at to be utc
test plan
- delete a user
- the user should have deleted_at populated
- delete a quiz
- the quiz should have deleted_at populated
Change-Id: Ibf3442b832f648d754ac9959f053570bc8c06a19
Reviewed-on: https://gerrit.instructure.com/25585
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
rather than rails2.3 style validate_on_* and before_validation_on_*
fixes CNVS-8752
test-plan: (in script/console)
- initialize a discussion entry (not yet saved)
- set entry.depth to DiscussionEntry.max_depth + 1
- try to save it; should raise an error about the maximum depth
- set entry.depth to nil
- save it; should not encounter an error
- check entry.depth; should be 1
[this next part seems weird to me, but follows the letter of the code]
- with the same, no-longer-new entry, set entry.depth to nil
- try to save it; should not encounter an error
- check entry.depth; should still be nil
Change-Id: Ia56a7ab17d36698e59fda4b520b07352d61ce02e
Reviewed-on: https://gerrit.instructure.com/24997
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
fixes CNVS-8069
test plan:
* have a user on one shard. use the API to upload a file to
a specific folder for that user
* arrange to have a user on another shard with the same local
id (either by creating the user in script/console and assigning
the id before saving, or just creating both users on a fresh
shard each, so they both end up as id 1)
* use the API to upload a file to the second user *with the same
path*
* it should not error out due to foreign key constraints
Change-Id: I06724e148df82d15629b4133a0a5c75bdf32caf7
Reviewed-on: https://gerrit.instructure.com/23991
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
change the way we create the default course root folder
("course files") to use a atomic sql statement
this should prevent suspected race conditions from creating
multiple root folders for a course, as this causes the
files page to become unusable
test plan:
* Unfortunately there seems to be no consistent way to
reproduce the errors, and thus no consistent way to
test that this fixes the error
Change-Id: I223a2b230921752ef1175c82adfdd854e1331668
Reviewed-on: https://gerrit.instructure.com/17014
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Bracken Mosbacker <bracken@instructure.com>
checks for locked/hidden status for the files and images tabs
on the wiki sidebar and doesn't show them to students
test plan:
* create a folder
* lock it
* or hide it
* or disable the files navigation tab
* should not see the folder on sidebar as a student
* create a text file
* lock it
* or hide it
* should not see the file on sidebar as a student
* create an image file
* lock it
* or hide it
* or disable the files navigation tab
* should not see the file in the images tab as a student
fixes #CNVS-2
Change-Id: I8d17a3c9b19d275a242c74a593736b17905e5ba9
Reviewed-on: https://gerrit.instructure.com/16511
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
test plan:
1. login as a teacher
2. go to a course
3. click on files on the left nav
4. click 'Add Folder'
5. try to give it a name over 255 characters
6. text stops at 255 characters, press enter to add
the folder
7. folder is saved with no DB error
Change-Id: I1da8595350b3d0c6f23e3052e514bcb55446f141
Reviewed-on: https://gerrit.instructure.com/13982
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
Test plan:
(We need two users here because Canvas doesn't notify you about
files you upload yourself. We'll call them Student and Teacher
here, but they don't actually have to be these things.)
* As Student, enable notifications for new files in Profile.
* As Teacher, upload a file.
* Within an hour or so (everything about notifications occurs
in low-priority background tasks), Student should receive
a notification for the file.
* As Teacher, upload multiple files.
* Student should eventually receive a notification that
X number of files were added.
Note that files are batched over a five-minute period; that is,
if a file is added to a course within five minutes of a previous
file, it will be counted in the same batch.
Change-Id: I09b5f497cae1d726b7aaf85824e98e69e45b0c1b
Reviewed-on: https://gerrit.instructure.com/12346
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
A complete api for folder and file management
Also updates the alphabetical sorting features to escape
a backslash caused errors when casting a string to a
bytea in postgres
Test Plan:
* CRUD yourself some files
* CRUD yourself some folder
closes#9163
Change-Id: I0b937f9273077b66ab9d6c37171bec1fcc5380dd
Reviewed-on: https://gerrit.instructure.com/12085
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
test plan: in the file browser, try to move a folder into its own child
folder. you should get an error message, rather than a loading progress
indicator that never goes away.
Change-Id: I0e0ed12c07781b92c371068d6e47423b77f15cc2
Reviewed-on: https://gerrit.instructure.com/10952
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
rather than proxy attachments through the conversations controller and
cause a long-running db transaction, we now just send them to the right
place (files controller, s3, whatever), and then create the message. we
now store the attachment in a special folder on the user so that they
can more easily be tracked in the future for quota management.
because we now just store one instance of each attachment, sending a
bulk private message w/ attachments should be a bit less painful.
known regression:
if a user deletes a conversation attachment from their files area, it
deletes if for all recipients. this is essentially the same problem as
tickets #6732 and #7481 where we don't let a "deleted" attachment to
still be viewed via associations with other objects.
test plan:
1. send an attachment on a new conversation and confirm that was sent
correctly and can be viewed by recipients
2. send an attachment on an existing conversation and confirm that was
sent correctly and can be viewed by recipients
3. send an attachment on a bulk private conversation and
1. confirm that was sent correctly and can be viewed by recipients
2. confirm that only one attachment was actually created, but each
message in each conversation is linked to it
4. send multiple attachments and confirm that they were sent correctly
and can be viewed by recipients
5. perform steps 1-4 for both local and s3 uploads
Change-Id: I7cb21c635f98e47163ef81f0c4050346c64faa91
Reviewed-on: https://gerrit.instructure.com/9046
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
also move notifications in "new email messages" to "administrative alerts",
because that's a much better description of them
test plan:
* go to communication preferences
* the last one should be "administrative alerts"
* "Files", "Private message from student", "New email messages",
and "Context Message" should be nowhere to be found
Change-Id: I8b30d53b8137ab4b17cb436920d87331327e01f9
Reviewed-on: https://gerrit.instructure.com/8996
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
also switched to storing profile pictures in a new folder ("profile pictures")
so that users will not see a ton of unrelated pictures.
Change-Id: Ia2fd55e1c090db886349319613a7d5ecb33805ac
Reviewed-on: https://gerrit.instructure.com/4950
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Basically, don't call a bazillion procs everytime you check_policy;
just the "given" statement. Everything else is evaluated just once,
and cached on the class. This does lose functionality (the ability
to access the instance inside of set_policy, and set methods), but
none of it was currently in use.
Change-Id: I736879d98beb4115a2e8c492931c755076291d08
Reviewed-on: https://gerrit.instructure.com/4665
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: JT Olds <jt@instructure.com>
Previously we were just checking every single attachment in the course, which
could take forever in the case of a course with many files. Now we walk the
file heirarchy, which should be much more efficient.
Change-Id: Iab131c7a41c78deff09a9b848eb5a59554f08ba3
Reviewed-on: https://gerrit.instructure.com/3808
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>