Permalink
Browse files

Add results page

  • Loading branch information...
1 parent 481a686 commit d25e470d8b3544ccc1cbafdeecc43bd8071df452 @xobb1t xobb1t committed Jul 30, 2011
View
@@ -52,6 +52,10 @@ def get_repo_path(self):
return os.path.join(CONFIG['CLONES_ROOT'], self.hash)
return None
+ @models.permalink
+ def get_absolute_url(self):
+ return ('lint_results', (), {'hash': self.hash})
+
class Fix(models.Model):
@@ -62,6 +66,9 @@ class Fix(models.Model):
source = models.TextField()
solution = models.TextField()
+ class Meta:
+ ordering = ['path']
+
@receiver(models.signals.post_save, sender=Report)
def delete_unused_repos(sender=Report, **kwargs):
@@ -1,4 +1,5 @@
from django.template import Library
+from django.utils import simplejson as json
from ..forms import ReportForm
@@ -9,3 +10,17 @@
@register.inclusion_tag('lint/tags/report_create_form.html')
def report_create_form():
return {'form': ReportForm()}
+
+
+@register.inclusion_tag('lint/tags/results_fix.html')
+def results_fix(data):
+ lines = json.loads(data, )
+ result = []
+ for line_info in lines:
+ result.append({
+ 'number': line_info[0],
+ 'is_significant': line_info[1],
+ 'text': line_info[2],
+ })
+ return {'result': result}
+
View
@@ -15,7 +15,7 @@ def create(request):
report = form.save()
request.session['report_pk'] = report.pk
process_report.delay(report)
- result = {'status': 'ok'}
+ result = {'status': 'ok', 'hash': report.hash}
else:
result = {'status': 'error'}
return HttpResponse(json.dumps(result), mimetype='application/json')
@@ -37,3 +37,10 @@ def get_status(request):
data = {'queue': result[0], 'cloning': result[1],
'parsing': result[2], 'analyzing': result[3]}
return HttpResponse(json.dumps(data), mimetype='application/json')
+
+
+def results(request, hash):
+ qs = Report.objects.filter(stage='done')
+ qs = qs.exclude(error='')
+ report = get_object_or_404(qs, hash=hash)
+ return render(request, 'lint/results.html', {'report': report})
@@ -1,62 +1,26 @@
-{% extends "base.html" %}
+{% extends "base.html" %}{% load lint %}
{% block content %}
<h2 class="first">Your project:</h2>
<div class="description">
- <a href="https://github.com/django/django">https://github.com/django/django</a>
+ {{ report.url|urlize }}
</div>
<h2>Results url:</h2>
<div class="description">
- <a href="http://djangolint.com/results/1">http://djangolint.com/results/1</a>
+ <a href="{{ report.get_absolute_url }}">http://djangolint.trilandev.com{{ report.get_absolute_url }}</a>
</div>
-
<h2>Fixes:</h2>
+ {% with report.fixes.all as fixes %}
+ {% for fix in fixes %}
<div class="description">
- <h3 class="first">apps/test/models.py</h3>
- <p>Error message for this fix.</p>
- <ol class="fix" start="20">
- <li><pre><code>class Report(models.Model):</code></pre></li>
- <li><pre><code></code></pre></li>
- <li class="significant"><pre><code>created_on = models.DateTimeField(default=datetime.now)</code></pre></li>
- <li><pre><code></code></pre></li>
- </ol>
- <ol class="fix yes" start="20">
- <li><pre><code>class Report(models.Model):</code></pre></li>
- <li><pre><code></code></pre></li>
- <li class="significant"><pre><code>created_on = models.DateTimeField(default=datetime.now)</code></pre></li>
- <li><pre><code></code></pre></li>
- </ol>
- </div>
- <div class="description">
- <h3>apps/test/test.py</h3>
- <p>Error message for this fix.</p>
- <ol class="fix" start="20">
- <li><pre><code> hash = models.CharField(unique=True, max_length=40)</code></pre></li>
- <li class="significant"><pre><code> end = models.CharField(unique=True, max_length=40, unique=True, max_length=40, unique=True, max_length=40)</code></pre></li>
- <li><pre><code></pre></li>
- </ol>
- <ol class="fix yes" start="20">
- <li><pre><code> hash = models.CharField(unique=True, max_length=40, unique=True, max_length=40)</code></pre></li>
- <li class="significant"><pre><code> end = models.CharField(unique=True, max_length=40)</code></pre></li>
- <li><pre><code></pre></li>
- </ol>
+ <h3{% if forloop.first %} class="first"{% endif %}>{{ fix.path }}</h3>
+ <p>{{ fix.description }}</p>
+ {% results_fix fix.source %}
+ {% if fix.solution %}
+ {% results_fix fix.solution %}
+ {% endif %}
</div>
- <div class="description">
- <h3>utils/test/mytest.py</h3>
- <p>Error message for this fix.</p>
- <ol class="fix" start="20">
- <li><pre><code> def expired(self):</code></pre></li>
- <li><pre><code> expiration_date = timedelta(days=EXPIRATION_DAYS) + self.created_on</code></pre></li>
- <li class="significant"><pre><code> return datetime.now() > expiration_date</code></pre></li>
- <li><pre><code></code></pre></li>
- </ol>
- <ol class="fix yes" start="20">
- <li><pre><code> def expired(self):</code></pre></li>
- <li><pre><code> expiration_date = timedelta(days=EXPIRATION_DAYS) + self.created_on</code></pre></li>
- <li class="significant"><pre><code> return datetime.now() > expiration_date</code></pre></li>
- <li><pre><code></code></pre></li>
- </ol>
- </div>
-
-{% endblock %}
+ {% endfor %}
+ {% endwith %}
+{% endblock %}
@@ -0,0 +1,5 @@
+{% for line in result %}
+{% if forloop.first %}<ol class="fix{% if solution %} yes{% endif %}" start="{{ line.number }}">{% endif %}
+<li{% if line.is_significant %} class="significant"{% endif %}><pre><code>{{ line.text }}</code></pre></li>
+{% if froloop.last %}</ol>{% endif %}
+{% endfor %}
View
@@ -10,7 +10,6 @@
name='lint_report_create'),
url(r'^get_status$', 'lint.views.get_status',
name='lint_report_get_status'),
- url(r'^results$',
- TemplateView.as_view(template_name='lint/results.html'),
+ url(r'^results/(?P<hash>[a-f0-9]{40})$', 'lint.views.results',
name='lint_results'),
)

0 comments on commit d25e470

Please sign in to comment.