Пример #1
0
def grading_cancel(request, pluginId, fitsId):
    """
    Cancels a grade.
    """
    plugin = manager.getPluginByName(pluginId)

    # TODO: handle cases other than qfits-in
    # Looks for existing grade
    f = Plugin_fitsin.objects.filter(id = int(fitsId))[0]
    m = FirstQEval.objects.filter(user = request.user, fitsin = f)
    evals = FirstQEval.objects.filter(fitsin = f).order_by('-date')
    comments = FirstQComment.objects.all()
    prev_releaseinfo =  Plugin_fitsin.objects.filter(id = int(fitsId))

    if m:
        m.delete()
    
    return render_to_response('grading_panel.html', {   
        'pluginId'  : pluginId,
        'fitsId'    : fitsId,
        'comments'  : comments,
        'evals'     : evals,
        'prev_releaseinfo'  : prev_releaseinfo,
    }, 
    context_instance = RequestContext(request))
Пример #2
0
def home(request):
	"""
	Renders processing cart view.
	"""
	cartHasData = False
	if 'cart' not in request.session:
		request.session['cart'] = {'plugins' : {}}

	# Current items for user session
	cart_items = []
	for plugin, dataList in request.session['cart']['plugins'].iteritems():
		plugObj = manager.getPluginByName(plugin)
		if len(dataList):
			plugObj.setData(dataList)
			cartHasData = True
			cart_items.append(plugObj)
		else:
			plugObj.removeData()

	policies = CondorNodeSel.objects.filter(is_policy = True).order_by('label')
	selections = CondorNodeSel.objects.filter(is_policy = False).order_by('label')

	menu_id = 'processingcart'
	return render_to_response('processingcart.html', {	
        'cart_plugins' 		: cart_items, 
        'plugins' 			: manager.plugins, 
        'cartHasData' 		: cartHasData, 
        # Cluster node available policies + selections
        'policies'			: policies,
        'selections'		: selections,
        'selected_entry_id'	: menu_id, 
        'misc' 				: manager,
        'title' 			: get_title_from_menu_id(menu_id),
    },
    context_instance = RequestContext(request))
Пример #3
0
def image_grading(request, pluginName, fitsId):
    """
    Image grading template.
    """
    plugin = manager.getPluginByName(pluginName)
    if plugin:
        try:
            path = plugin.getUrlToGradingData(request, fitsId)
        except IndexError:
            return HttpResponseRedirect(settings.AUP + '/results/')
    else:
        return HttpResponseRedirect(settings.AUP + '/results/')
    return render_to_response('grading.html', {'www' : path, 'pluginName' : pluginName, 'fitsId' : fitsId}, context_instance = RequestContext(request))
Пример #4
0
def get_report(request, pluginId, reportId, format):
	"""
	Generate a report
	@param pluginId plugin's id or global
	@param reportId report's unique id
	@param format report's output format
	"""
	if not request.user.has_perm('youpi.can_use_reporting'):
		return HttpResponseForbidden("Sorry, you don't have permission to generate reports")
	try:
		plugObj = manager.getPluginByName(pluginId)
	except ApplicationManagerError:
		# May be a global report (not plugin related)
		if pluginId == 'global':
			return get_global_report(request, reportId, format)
		else:
			# Not found
			return HttpResponseNotFound()

	return plugObj.getReport(request, reportId, format)
Пример #5
0
def single_result(request, pluginId, taskId):
    """
    Same content as the page displayed by related plugin.
    """
    plugin = manager.getPluginByName(pluginId)
    if not plugin:
        return HttpResponseNotFound("""<h1><span style="color: red;">Invalid URL. Result not found.</h1></span>""")

    try:
        task = Processing_task.objects.filter(id = int(taskId))[0]
    except IndexError:
        # TODO: set a better page for that
        return HttpResponseNotFound("""<h1><span style="color: red;">Result not found.</h1></span>""")

    menu_id = 'results'
    return render_to_response( 'single_result.html', {  
        'pid'               : pluginId, 
        'tid'               : taskId,
        'selected_entry_id' : menu_id, 
        'plugin'            : plugin,
        'title'             : get_title_from_menu_id(menu_id),
    }, 
    context_instance = RequestContext(request))
Пример #6
0
def grading_panel(request, pluginId, fitsId):
    """
    Image grading panel.
    """
    plugin = manager.getPluginByName(pluginId)
    path = plugin.getUrlToGradingData(request, fitsId)

    # TODO: handle cases other than qfits-in
    # Looks for existing grade
    f = Plugin_fitsin.objects.filter(id = int(fitsId))[0]
    m = FirstQEval.objects.filter(user = request.user, fitsin = f)
    evals = FirstQEval.objects.filter(fitsin = f).order_by('-date')
    comments = FirstQComment.objects.all()
    prev_releaseinfo =  Plugin_fitsin.objects.filter(id = int(fitsId))

    if m:
        grade = m[0].grade
        userPCommentId = m[0].comment.id
        customComment = m[0].custom_comment
    else:
        grade = None
        userPCommentId = None
        customComment = None
    
    return render_to_response('grading_panel.html', {   
        'www'       : path, 
        'pluginId'  : pluginId,
        'fitsId'    : fitsId,
        'userGrade' : grade,
        'comments'  : comments,
        'userPCommentId' : userPCommentId,
        'customComment' : customComment,
        'evals'     : evals,
        'prev_releaseinfo'  : prev_releaseinfo,
    }, 
    context_instance = RequestContext(request))
Пример #7
0
def render_plugin(request, pluginId):
    try:
        plugin = manager.getPluginByName(pluginId)
    except ApplicationManagerError, msg:
        return HttpResponseNotFound("Error: %s" % msg)
Пример #8
0
        pluginName = request.POST["Plugin"]
        method = request.POST["Method"]
    except Exception, e:
        raise PostDataError, e

    if method == "getTaskInfo":
        if not request.user.has_perm("youpi.can_view_results"):
            return HttpResponseForbidden("Sorry, you don't have permission to view processing results")
    elif method == "process":
        if not request.user.has_perm("youpi.can_submit_jobs"):
            return HttpResponse(
                str({"result": {"Error": "Sorry, you don't have permission to submit jobs on the cluster"}}),
                mimetype="text/plain",
            )

    plugin = manager.getPluginByName(pluginName)
    try:
        res = eval("plugin." + method + "(request)")
    except Exception, e:
        import traceback

        if settings.DEBUG:
            print "-" * 60
            print "-- Processing plugin exception occured! Traceback follows"
            print "-" * 60
            traceback.print_exc(file=sys.stdout)
            print "-" * 60
        raise PluginEvalError, e

        # Response must be a JSON-like object
    return HttpResponse(json.encode({"result": res}), mimetype="text/plain")
Пример #9
0
    if owner == 'my':
        owner = request.user.username
    elif owner == 'all':
        owner = None

    # Tasks ids for the page
    order = ('title', 'end_date', '-end_date')
    if not sort in range(len(order)):
        sort = 0

    # Get tasks
    tasks = find_tasks(tags, task_id=None, kind=kindid, user=owner, success=success, failure=failure, sort_by=order[sort])
    tasksIds = [int(t.id) for t in tasks]
    filtered = False

    plugin = manager.getPluginByName(kindid)

    # Plugins can optionally filter/alter the result set
    try:
        tasksIds = plugin.filterProcessingHistoryTasks(request, tasksIds)
    except AttributeError:
        # Not implemented
        pass

    lenAllTasks = len(tasksIds)

    if len(tasksIds) > maxPerPage:
        pageCount = len(tasksIds)/maxPerPage
        if len(tasksIds) % maxPerPage > 0:
            pageCount += 1
    else:
Пример #10
0
				ioutdir = item['userData'][kw]
				del item['userData'][kw]
			if item['userData'] == userData:
				# Restore item's path
				if ioutdir:
					item['userData'][kw] = ioutdir
				return HttpResponse(json.encode({'warning': 'Item already existing in the processing cart.'}))
			else:
				# Restore item's path
				if ioutdir:
					item['userData'][kw] = ioutdir
		# New item: restore output directory
		if outdir:
			userData[kw] = outdir

	plugObj = manager.getPluginByName(plugin)
	# Useful to get a rather unique item ID in the processing cart
	plugObj.itemCounter += 1

	request.session['cart']['plugins'][plugin].append({ 'date' 			: time.asctime(), 
														'userData' 		: userData,
														'itemCounter' 	: plugObj.itemCounter})

def cart_add_item(request):
	try:
		plugin = request.POST['plugin']
		userData = request.POST['userData']
	except Exception, e:
		return HttpResponseServerError('Incorrect POST data.')

	_cart_add_item(request)