Skip to content
Snippets Groups Projects
Commit c2184458 authored by Andrey's avatar Andrey
Browse files

added report list

parent 8d26a8a8
No related merge requests found
from fp_method_builder import FingerprintMethodBuilder
from method_configurator import MethodConfigurator
from .fp_method_builder import FingerprintMethodBuilder
from .method_configurator import MethodConfigurator
def main():
filenames = ['./clonus/Tests/Python/test6.py', './clonus/Tests/Python/test7.py']
filenames = ['./clonus/Tests/Python/test1.py', './clonus/Tests/Python/test2.py']
fp_builder = FingerprintMethodBuilder(filenames)
config = MethodConfigurator(fp_builder)
res = config.make_method()
......
# Generated by Django 4.2.1 on 2023-05-22 16:11
# Generated by Django 4.2.1 on 2023-05-23 15:46
from django.db import migrations, models
......@@ -23,6 +23,7 @@ class Migration(migrations.Migration):
('window_size', models.PositiveSmallIntegerField(default=3)),
('processed', models.BooleanField(default=False)),
('coeff', models.FloatField(default=0.0)),
('date', models.DateTimeField(auto_now_add=True)),
],
),
]
......@@ -18,6 +18,7 @@ class Package(models.Model):
window_size = models.PositiveSmallIntegerField(default=3)
processed = models.BooleanField(default=False)
coeff = models.FloatField(default=0.0)
date = models.DateTimeField(auto_now_add=True)
def gen_hash(self, chunk_size: int = 4096):
hasher = md5(str(self.path).encode("utf-8"))
......
......@@ -10,12 +10,12 @@ clonus
<div class="h-100 d-flex align-items-center justify-content-center">
<div class="container text-center">
<div class="landing text-danger">
<p class="title">Clonus</p>
<p class="title text-pimped">Clonus</p>
</div>
<p class="text-white h4 landing">
<p class="text-white h4 landing text-pimped">
Веб-сервис для поиска заимствований в решениях задач по программированию
</p>
<a role="button" class="btn btn-success btn-xl" href={% url 'compare' %}>Сравнить два файла</a>
<a role="button" class="btn btn-success btn-xl" href={% url 'compare' %}>Сравнить файлы</a>
<a role="button" class="btn btn-success btn-xl" href={% url 'list' %}>Список отчетов</a>
</div>
</div>
......
{% extends "base.html" %}
{% load static %}
{% block title %}
Список отчетов
{% endblock title %}
{% block style %}
<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}" />
{% endblock style %}
{% block content %}
<div class="mt-5 nav">
<a role="button" class="btn btn-success btn-lg" href={% url 'index' %}>На главную</a>
</div>
<div class="h-80 d-flex align-items-center justify-content-center">
<div class="container text-white mt-5">
<span>
{% for pack, f1, f2 in packages %}
<a role="button"
class="btn btn-warning btn-lg m-2 d-block text-start"
href="{% url 'summary' h=pack.hash %}">{{ pack.hash }}: {{ f1 }} и {{ f2 }}</a>
{% endfor %}
</span>
</div>
</div>
{% endblock content %}
\ No newline at end of file
......@@ -2,7 +2,7 @@
{% load crispy_forms_tags %}
{% load static %}
{% block title %}
Сравнение двух файлов
Сравнение файлов
{% endblock title %}
{% block style %}
<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}" />
......
......@@ -8,26 +8,36 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js"
integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{% comment %}
<script
src="//cdn.jsdelivr.net/gh/TRSasasusu/highlightjs-highlight-lines.js@1.2.0/highlightjs-highlight-lines.min.js"></script>
{% endcomment %}
{% endblock style %}
{% block content %}
<script>hljs.highlightAll();</script>
<div class="mt-5 nav">
<a role="button" class="btn btn-success btn-lg" href="{% url 'index' %}">На главную</a>
<a role="button" class="btn btn-success btn-lg" onclick="history.back()">Назад</a>
</div>
<div class="d-flex align-items-center justify-content-center">
<div class="container text-white">
<div class="text-center">
<h2 class="lab"> Отчет {{ hash }} </h2>
<h4> Процент оригинальности {{ coeff }}% </h4>
<h2 class="lab text-pimped"> Отчет {{ hash }} </h2>
<h4 class="text-pimped"> Процент заимствования: {{ coeff|floatformat:0 }}% </h4>
</div>
<div class="d-flex justify-content-between">
<div class="language-python">
<div class="d-flex justify-content-between mt-5">
<div class="language-python" id="file1">
<h5 class="text-center bg-success">{{ f1 }}</h5>
<pre><code>{{ file1 }}</code></pre>
</div>
<div>
<div class="language-python" id="file2">
<h5 class="text-center bg-success">{{ f2 }}</h5>
<pre><code>{{ file2 }}</code></pre>
</div>
</div>
</div>
</div>
{% endblock content %}
\ No newline at end of file
{% endblock content %}
\ No newline at end of file
from django.shortcuts import render, redirect
from django.http import HttpRequest
from pathlib import Path
from clonus.forms import FileToFileForm
from clonus.models import Package
......@@ -51,14 +52,10 @@ def summary(request: HttpRequest, h: str):
config = MethodConfigurator(fp_builder)
method_res = config.make_method()
# method_res.print()
p.coeff = round(method_res.clone_pct * 100,2)
# p.coeff = round(method_res.clone_pct * 100,2)
p.coeff = method_res.clone_pct
p.processed = True
p.save()
# TODO:
# 1). save shit to db
# 2). interpolate files with html tags
# 3). write view for summary
# 4). think of a way to implement f2db
with open(p.file1, 'r', encoding='utf-8') as f:
file1 = f.read()
......@@ -68,12 +65,18 @@ def summary(request: HttpRequest, h: str):
context = {
"hash": p.hash,
"coeff": p.coeff,
"coeff": p.coeff*100,
"file1": file1,
"file2": file2
"file2": file2,
"f1": Path(p.file1).name,
"f2": Path(p.file2).name
}
return render(request, "summary.html", context)
def list(request: HttpRequest):
pass
q = Package.objects.all().order_by("-date")
context = {
"packages": ((i, Path(i.file1).name, Path(i.file2).name) for i in q)
}
return render(request, "list.html", context)
......@@ -52,4 +52,8 @@ body {
background-color: rgba(0, 0, 0, 0.3);
border-radius: 2%;
padding: 2%;
}
.text-pimped {
text-shadow: 1px 1px 2px black;
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment