示例#1
0
文件: views.py 项目: sbesson/registry
def upload(request, **kwargs):
    # temp
    return HttpResponseRedirect("http://validator.openmicroscopy.org.uk/")
    
    error = check_if_error(request)
    
    template = "validator/upload.html"
    login_form = LoginForm() 
    
    file_format = "*.ome;*.tif;*.tiff;*.xml"
    file_format_name = "OME, TIFF, XML files only"
    
    current_files = 0
    try:
        c = FileValidation(request.session.session_key)
        c.count_files()
        current_files = c.counter
    except:
        logger.error(traceback.format_exc())
        
    context = {'login_form':login_form, 'file_format':file_format, 'file_format_name':file_format_name, "current_files":current_files}
    t = get_template(template)
    c = Context(request, context)
    rsp = t.render(c)
    return HttpResponse(rsp)
示例#2
0
文件: views.py 项目: sbesson/registry
def demo_account(request, action=None, **kwargs):
    error = check_if_error(request)
    template = "registry/enquiry.html"
    
    thanks = None
    demo_form = None
    if action == "enquiry":
        logger.info("Demo account data sent:")
        logger.info(request.POST)
        demo_form = DemoAccountForm(data=request.REQUEST.copy())
        if demo_form.is_valid():
            demo_form.save()
            title = 'OMERO.qa - Demo account'            
            text_content = " \n".join([("%s: '%s'" % (key.replace("_", " "),val)) for key,val in request.POST.iteritems()])
            html_content = "<br/>".join([("%s: '%s'" % (key.replace("_", " "),val)) for key,val in request.POST.iteritems()])
            recipients = ["*****@*****.**"]
            try:
                msg = EmailMultiAlternatives(title, text_content, settings.SERVER_EMAIL, recipients)
                msg.attach_alternative(html_content, "text/html")
                msg.send()
                logger.info('Email was sent.')
            except:
                logger.error(traceback.format_exc())
            error = "Thank you for your interest in an OMERO Demo Account - one of our consultants will be in contact with you shortly. Please be patient as it may take a few days to process your application after we receive it."
            request.session['error'] = error
            logger.error(error)
            # TODO might be request.path
            return HttpResponseRedirect(reverse(viewname="registry_demoaccount", args=['thanks']))
    elif action == "thanks":
        if error:
            thanks = error
        else:
            demo_form = DemoAccountForm()
    else:
        demo_form = DemoAccountForm()
    
    login_form = LoginForm()
    context = {"login_form":login_form, 'demo_form':demo_form, 'thanks':thanks}
    t = get_template(template)
    c = Context(request, context)
    rsp = t.render(c)
    return HttpResponse(rsp)
示例#3
0
文件: views.py 项目: sbesson/registry
def file_list(request, **kwargs):
    # temp
    return HttpResponseRedirect("http://validator.openmicroscopy.org.uk/")
    
    error = check_if_error(request)
    
    template = "validator/file_list.html"
    login_form = LoginForm()    
    
    controller = FileValidation(request.session.session_key)
    controller.read_files()
    file_name = request.REQUEST.get("file")
    if file_name is not None:
        try:
            logger.debug("File: %s" % file_name)
            controller.validate(file_name)            
            logger.debug(controller.schema)
            logger.debug(controller.result)
        except Exception, x:
            error = x
            logger.error(traceback.format_exc())