--- a/OSSEval/analysis/views.py
+++ b/OSSEval/analysis/views.py
@@ -1,3 +1,18 @@
+# This Source Code Form of OSSEval is subject to the terms of the GNU AFFERO
+# GENERAL PUBLIC LICENSE, v. 3.0. If a copy of the AGPL was not
+# distributed with this file, You can obtain one at http://www.gnu.org/licenses/agpl.txt
+#
+# OSSeval is powered by the SOS Open Source AGPL edition.
+# The AGPL requires that you do not remove the SOS Open Source attribution and copyright
+# notices from the user interface (see section 5.d below).
+# Commercial licenses are available and do not require any SOS Open Source attributions
+# or visible copyright notices but they are not permitted under this license.
+
+# OSSEval Copyright 2014 Bitergium SLL
+# SOS Open Source Copyright 2012 Roberto Galoppini
+# Author: Davide Galletti
+
+
from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
@@ -18,7 +33,7 @@
if form.is_valid():
model_instance = form.save()
model_instance.visible = True
- weight_scenarios = model_instance.methodology_version.weight_scenario_set.filter(active=True)
+ weight_scenarios = model_instance.methodology_version.weightscenario_set.filter(active=True)
if len(weight_scenarios) == 1:
model_instance.weight_scenario = weight_scenarios[0]
else:
@@ -55,14 +70,14 @@
def analysis_questions(request, analysis_id):
analysis = get_object_or_404(Analysis, pk=analysis_id)
-
+ weight_scenarios = analysis.methodology_version.weightscenario_set.all()
entity = analysis.methodology_version.methodology.entity
exec("from " + entity.actual_entity_app + ".views import search_html_form, instance_list_html")
#"Content-Type: text/html; charset=utf-8" has to be removed as these methods return just a partial
analysis_detail = str(instance_list_html(request, analysis_id))[len("Content-Type: text/html; charset=utf-8"):]
- return render(request, 'analysis/analysis_questions.html', {'analysis': analysis, 'analysis_detail': analysis_detail, 'methodology_version': analysis.methodology_version})
+ return render(request, 'analysis/analysis_questions.html', {'analysis': analysis, 'analysis_detail': analysis_detail, 'methodology_version': analysis.methodology_version, 'weight_scenarios': weight_scenarios})
def analysis_report(request, analysis_id, weight_scenario_id = 0):
analysis = get_object_or_404(Analysis, pk=analysis_id)
@@ -171,15 +186,20 @@
analysis_on_file = Analysis()
analysis_xml = xmldoc.getElementsByTagName('Analysis')
- analysis_on_file.id = int(analysis_xml[0].attributes["Id"].firstChild.data)
- analysis_on_file.name = analysis_xml[0].attributes["Name"].firstChild.data
- analysis_on_file.created = analysis_xml[0].attributes["Created"].firstChild.data
- analysis_on_file.user_login = analysis_xml[0].attributes["UserLogin"].firstChild.data
+ try:
+ analysis_on_file.id = int(analysis_xml[0].attributes["Id"].firstChild.data)
+ analysis_on_file.name = analysis_xml[0].attributes["Name"].firstChild.data
+ analysis_on_file.created = analysis_xml[0].attributes["Created"].firstChild.data
+ analysis_on_file.user_login = analysis_xml[0].attributes["UserLogin"].firstChild.data
+ except:
+ # no analysis in the import file
+ pass
analysis_on_db = Analysis()
- try:
- analysis_on_db = Analysis.objects.get(pk=analysis_on_file.id)
- except:
- pass
+ if analysis_on_file.id:
+ try:
+ analysis_on_db = Analysis.objects.get(pk=analysis_on_file.id)
+ except:
+ pass
methodology_on_file = Methodology()
methodology_version_on_file = MethodologyVersion()
@@ -219,12 +239,11 @@
mv.id = methodology_version_xml.attributes["Id"].firstChild.data
a = Analysis()
a.methodology_version = mv
- analysis_xml = xmldoc.getElementsByTagName('Analysis')[0]
if import_analysis:
+ analysis_xml = xmldoc.getElementsByTagName('Analysis')[0]
a.from_xml(analysis_xml, always_insert)
return HttpResponseRedirect(reverse('analysis_detail', args=(a.id,)))
else:
- a.id = analysis_xml.attributes["Id"].firstChild.data
return HttpResponseRedirect(reverse('analysis_list'))