-
Notifications
You must be signed in to change notification settings - Fork 47
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
Remove target input from form if its fixed, add ability to share targ… #1142
Open
jnation3406
wants to merge
4
commits into
dev
Choose a base branch
from
feature/exclude_download_from_ps
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from rest_framework import serializers | ||
from tom_dataproducts.sharing import get_sharing_destination_options | ||
from tom_targets.sharing import share_target_and_all_data | ||
from tom_targets.fields import TargetFilteredPrimaryKeyRelatedField | ||
from tom_targets.models import PersistentShare, Target | ||
|
||
|
||
class PersistentShareSerializer(serializers.ModelSerializer): | ||
destination = serializers.ChoiceField( | ||
choices=get_sharing_destination_options(include_download=False), required=True | ||
) | ||
target = TargetFilteredPrimaryKeyRelatedField(queryset=Target.objects.all(), required=True) | ||
share_existing_data = serializers.BooleanField(default=False, required=False, write_only=True) | ||
|
||
class Meta: | ||
model = PersistentShare | ||
fields = ('id', 'target', 'destination', 'user', 'created', 'share_existing_data') | ||
|
||
def create(self, validated_data): | ||
shared_existing_data = validated_data.pop('share_existing_data', None) | ||
if shared_existing_data: | ||
share_target_and_all_data(validated_data['destination'], validated_data['target']) | ||
return super().create(validated_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is silently breaking for me.
I'm getting back
b'{"message_text":["This field may not be null."],"submitter":["This field may not be blank."]}'
Obviously these things need to be autofilled or use the other form.
It would also be nice if these made the same user facing alerts that normal sharing does (for success as well as failure.)
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.
Thanks for checking that - I had thought submitter would be autoset by Hermes but it actually doesn't do that for outgoing messages, only incoming. So I've set the submitter to be the
TOM_NAME
which seems appropriate to me, and set the message text to be empty string instead of 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.
Also, the error should be mapped through now so it should stop the creation of a persistent share and show the error on screen if you have a problem when sharing all existing data. If it succeeds, nothing is shown but the persistent share is created and will show up, so that is the signal that it succeeded in sharing existing data too.
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.
I'm still getting a silent failure for
HTTPError('400 Client Error: Bad Request for url: https://hermes-dev.lco.global/api/v0/submit_message/') b'{"topic":["Hermes Dev can only submit to the hermes.test topic."]}'
as well as missing telescope/instrument
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.
Hmm I'll look into the error not making it through... What do you mean by missing telescope/instrument though? Is it stored in your datums value dict as 'telescope' and 'instrument'?
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.
yeah, not having the telescope/instrument in my data is just another way my hermes message can be rejected. The issue isn't that, it's just one of the two ways I tried to get errors back from hermes.
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.
Ah okay I understand what were saying now
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.
I've updated it again, and the errors are definitely coming through now! Sorry the error feedback handler stuff had me confused a bit.