Exemple #1
0
 def get_context(self, **kwargs):
     username = kwargs['username']
     user = Researcher.objects(username=username).first()
     ea_name = kwargs['ea_name']
     ea = ExpApp.objects(ea_name=ea_name).first()
     context = {'username': username, 'user': user, 'ea_name': ea_name,
                'ea': ea}
     return context
Exemple #2
0
 def get_context(self, **kwargs):
     username = kwargs['username']
     user = Researcher.objects(username=username).first()
     ea_name = kwargs['ea_name']
     ea = ExpApp.objects(ea_name=ea_name).first()
     form = self.form(request.form)
     fdata = form.source.data
     form.source.data = fdata if fdata else ea.previzpjs
     context = {'form': form, 'username': username, 'user': user,
                'ea_name': ea_name, 'ea': ea}
     return context
Exemple #3
0
def ea_data(mai_id, name):
    """Process data uploaded by a MetaAppInstance for an ExpApp."""
    # pversion = request.args.get('pversion')
    datafile = request.files["datafile"]
    sigfile = request.files["sigfile"]

    if not datafile:
        return "No datafile uploaded -> no data uploaded.\n"

    if not file_allowed(us_eadata, datafile):
        return "Filetype not allowed -> no data uploaded.\n"

    if not sigfile:
        return "No sigfile uploaded -> no data uploaded.\n"

    if not file_allowed(us_maisignatures, sigfile):
        return "Filetype not allowed -> no data uploaded.\n"

    mai = MetaAppInstance.objects(mai_id=mai_id).first()
    if not mai:
        return ("Unknown MetaAppInstance (id=%s) -> no data " "uploaded.\n") % mai_id

    ecv = crypto.ECVerifier(mai)
    datastring = datafile.read()

    if not ecv.verify(datastring, sigfile):
        return "Signature invalid -> no data uploaded.\n"

    ea = ExpApp.objects(name=name).first()
    if not ea:
        return ("Unknown ExpApp (name=%s) -> no data " "uploaded.\n") % name

    r = Result(data=json.loads(datastring))
    r.metaappinstance = mai
    ea.results.append(r)
    ea.save()

    return "Data uploaded.\n"
Exemple #4
0
 def __call__(self, form, field):
     if ExpApp.objects(name=field.data).count() != 0:
         raise validators.ValidationError(('You are already using this '
                                           'name'))
Exemple #5
0
 def create_expapp(self, form):
     """Create the Experiment App in database."""
     ea = ExpApp(ea_name=form.ea_name.data,
                 description=form.description.data)
     ea.owners.append(g.user)
     ea.save()