-
Notifications
You must be signed in to change notification settings - Fork 79
Share analyses #1758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Share analyses #1758
Changes from all commits
7df98ca
997274b
5fe04bc
01ac908
1a3414a
9d7524b
63d0a7a
5fb1147
2314e24
b40bb8b
32f052b
3f60461
5ad25f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,3 +89,32 @@ def to_int(value): | |
| except ValueError: | ||
| raise HTTPError(400, "%s cannot be converted to an integer" % value) | ||
| return res | ||
|
|
||
|
|
||
| @execute_as_transaction | ||
| def get_shared_links(obj): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why rewrite this one vs. using the one for studies? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the one from studies. listing_handlers.py has it removed and moved here, since this function is now used in more than just that file. |
||
| """Creates email links for the users obj is shared with | ||
|
|
||
| Parameters | ||
| ---------- | ||
| obj : QiitaObject | ||
| A qiita object with a 'shared_with' property that returns a list of | ||
| User objects | ||
|
|
||
| Returns | ||
| ------- | ||
| str | ||
| Email links for each person obj is shared with | ||
| """ | ||
| shared = [] | ||
| for person in obj.shared_with: | ||
| name = person.info['name'] | ||
| email = person.email | ||
| # Name is optional, so default to email if non existant | ||
| if name: | ||
| shared.append(study_person_linkifier( | ||
| (email, name))) | ||
| else: | ||
| shared.append(study_person_linkifier( | ||
| (email, email))) | ||
| return ", ".join(shared) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| var current_study = null; | ||
|
|
||
| $(document).ready(function () { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I just saw this - this is a library, why does it has a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because you can have as many document.ready calls in a single page as needed, and this also standardizes naming and initialization of the sharing dropdown for use in the other helper functions. |
||
| $('#shares-select').select2({ | ||
| ajax: { | ||
|
|
@@ -18,18 +16,18 @@ $(document).ready(function () { | |
| }); | ||
|
|
||
| $('#shares-select').on("select2:select", function (e) { | ||
| update_share({selected: e.params.data.text}); | ||
| update_share(e.target.classList[0], {selected: e.params.data.text}); | ||
| }); | ||
|
|
||
| $('#shares-select').on("select2:unselect", function (e) { | ||
| update_share({deselected: e.params.data.text}); | ||
| update_share(e.target.classList[0], {deselected: e.params.data.text}); | ||
| }); | ||
| }); | ||
|
|
||
| function modify_sharing(study_id) { | ||
| var shared_list; | ||
| current_study = study_id; | ||
| $.get('/study/sharing/', {study_id: study_id}) | ||
| function modify_sharing(share_type, id) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the indentation in this function is messed up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| var shared_list; | ||
| $('#shares-select').attr('data-current-id', id); | ||
| $.get('/' + share_type + '/sharing/', {id: id}) | ||
| .done(function(data) { | ||
| var users_links = JSON.parse(data); | ||
| var users = users_links.users; | ||
|
|
@@ -43,13 +41,14 @@ $.get('/study/sharing/', {study_id: study_id}) | |
| }); | ||
| } | ||
|
|
||
| function update_share(params) { | ||
| function update_share(share_type, params) { | ||
| share_id = $('#shares-select').attr('data-current-id'); | ||
| data = params || {}; | ||
| data.study_id = current_study; | ||
| $.get('/study/sharing/', data) | ||
| data.id = share_id; | ||
| $.get('/' + share_type + '/sharing/', data) | ||
| .done(function(data) { | ||
| users_links = JSON.parse(data); | ||
| links = users_links.links; | ||
| $("#shared_html_"+current_study).html(links); | ||
| $("#shared_html_"+share_id).html(links); | ||
| }); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if both are
None?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No share or unshare actions, but the user email links and user list is still returned. This is leveraged for initial population of the shared list in the page.