Skip to content

Instantly share code, notes, and snippets.

@cbare
Last active October 6, 2015 22:58
Show Gist options
  • Select an option

  • Save cbare/7c73f7009bbc3309f498 to your computer and use it in GitHub Desktop.

Select an option

Save cbare/7c73f7009bbc3309f498 to your computer and use it in GitHub Desktop.
Let's say you want to create a REGISTER button for a challenge. In order to join the challenge, participants have to agree to a terms of use document. Here's how to do it.
import json
## First we'll create a terms-of-use object that refers to the participant
## team for the challenge, which in this case has ID 3328713. The termsOfUse
## contains the HTML that will be displayed in a panel of the registration
## wizard.
## http://rest.synapse.org/org/sagebionetworks/repo/model/AccessRequirement.html
tou = {
'accessType': 'PARTICIPATE',
'concreteType': 'org.sagebionetworks.repo.model.TermsOfUseAccessRequirement',
'subjectIds': [{u'id': u'3328713', u'type': u'TEAM'}],
'termsOfUse': '<div class="markdown" style="margin-left:20px; margin-right:20px;">\t\t<h3>Please read the full <a href="https://www.synapse.org/#!Synapse:syn4294018/wiki/" class="link" target="_blank">DREAM 10 Challenge Rules</a>.</h3>\t\t<h3 style="margin-bottom:10px">These rules cover:</h3>\t\t<div class="row" style="height: 90px;">\t\t\t<div class="col-xs-6">\t\t\t\t<img class="left" src="https://s3.amazonaws.com/static.synapse.org/images/person.png" /><h5 style="padding-top: 25px; text-align:left;">Who can participate</h5>\t\t\t</div>\t\t\t<div class="col-xs-6">\t\t\t\t<img class="left" src="https://s3.amazonaws.com/static.synapse.org/images/certificate.png" /><h5 style="padding-top: 5px; text-align:left;">What you need to submit to be evaluated as a best performer</h5>\t\t\t</div>\t\t</div>\t\t<div class="row" style="height: 110px;">\t\t\t<div class="col-xs-6">\t\t\t\t<img class="left" src="https://s3.amazonaws.com/static.synapse.org/images/people.png" /><h5 style="padding-top: 5px; text-align:left;">How to participate as an individual and on teams</h5>\t\t\t</div>\t\t\t<div class="col-xs-6">\t\t\t\t<img class="left" src="https://s3.amazonaws.com/static.synapse.org/images/anonymous-person.png" style="margin-bottom: 20px;" /><h5 style="text-align:left;">Your right to participate anonymously <small>To participate anonymously, you must update your Synapse username to a pseudonym.</small></h5>\t\t\t</div>\t\t</div>\t\t<div class="row" style="height: 80px;">\t\t\t<div class="col-xs-6">\t\t\t\t<img class="left" src="https://s3.amazonaws.com/static.synapse.org/images/unlock.png" /><h5 style="text-align:left;">That DREAM Challenges are IP-free and open source</h5>\t\t\t</div>\t\t\t<div class="col-xs-6">\t\t\t\t<img class="left" src="https://s3.amazonaws.com/static.synapse.org/images/handshake.png" style="margin-bottom: 20px;" /><h5 style="text-align:left;">How we will resolve disagreements with participants</h5>\t\t\t</div>\t\t</div>\t\t<h5>By clicking "Accept" you confirm that you have read and accept the DREAM 10 Challenge Rules</h5></div>'
}
## Next we store the TOU object in Synapse. see:
## http://rest.synapse.org/POST/accessRequirement.html
syn.restPOST('/accessRequirement', json.dumps(tou))
## Store a second terms-of-use on the same team. Each new terms-of-use
## results in an additional panel in the wizard.
tou = {
'accessType': 'PARTICIPATE',
'concreteType': 'org.sagebionetworks.repo.model.TermsOfUseAccessRequirement',
'subjectIds': [{u'id': u'3328713', u'type': u'TEAM'}],
'termsOfUse': '<div class="markdown" style="margin:20px"><h3>SMC-Het Data Access Conditions</h3><p>Access to these data requires agreement to the following terms:</p><ul><li>The use of Challenge data or results in a publication is under embargo and requires written consent from data producers and Sage-DREAM Challenge organizers.</li></ul><p>By clicking below, you agree to these terms.<p></div>'
}
syn.restPOST('/accessRequirement', json.dumps(tou))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment