Commit 6f398c60 authored by Jomaro Rodrigues's avatar Jomaro Rodrigues
Browse files

fix-conflicts

parents 084acdc4 75e06a8e
......@@ -7,6 +7,8 @@
src/cache
*.json
src/.coverage
# lixo
......
before_script:
- make install
- pipenv shell
- python --version
django-tests:
script:
- cd src
- python manage.py test
......@@ -27,7 +27,9 @@ $ git clone git@gitlab.c3sl.ufpr.br:pet/A.D.E.G.A.git
```bash
sudo make install-dev
sudo make install
make install-user
pipenv install --dev
```
se você possui o arquivo do banco de dados compartilhado internamente pelos
......
......@@ -11,9 +11,8 @@ clean-deploy: clean
@rm -rf static db.sqlite3
coverage:
coverage run --source='.' manage.py test
coverage html
xdg-open htmlcov/index.html
(cd src; coverage run --source='.' manage.py test; coverage html)
mv src/htmlcov .
docs:
......@@ -34,9 +33,9 @@ install:
apt-get install -y python3-pip
apt-get install -y libpq-dev
apt-get install -y postgresql postgresql-contrib
pip3 install --user -U pip setuptools pipenv
install-user:
pip3 install --user -U pip setuptools pipenv==9.0.3
pipenv install
install-dev: install
pipenv install --dev
......@@ -38,7 +38,6 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'widget_tweaks',
......
......@@ -27,9 +27,6 @@ def load_dataframes(cwd='.'):
dataframe = fix_dataframes(dataframes)
dh = DataframeHolder(dataframe)
# ~ dh.students.aggregate(teste)
# print(dh.students['MEDIA_FINAL'].aggregate(teste))
return dataframe
......
......@@ -3,25 +3,38 @@ import time
from datetime import timedelta
from script.base.dataframe_base import load_dataframes
from script.build_cache import build_cache
from script.analysis.degree_analysis import *
def analyze(submission):
start_time = time.clock()
start_time_exec = time.time()
dataframe = load_dataframes(submission.path())
build_cache(dataframe)
cpu_time = timedelta(seconds=round(time.clock() - start_time))
run_time = timedelta(seconds=round(time.time() - start_time_exec))
print("--- Tempo de CPU: {} ---".format(cpu_time))
print("--- Tempo total: {} ---".format(run_time))
def main():
start_time = time.clock()
start_time_exec = time.time()
start_time = time.clock()
start_time_exec = time.time()
dataframe = load_dataframes(os.getcwd() + '/script/' + 'base')
# ~ for i, line in enumerate(dataframe):
# ~ print(type(dataframe["MEDIA_FINAL"][i]))
# ~ print(dataframe["MEDIA_FINAL"][i])
# ~ print(dataframe)
build_cache(dataframe)
dataframe = load_dataframes(os.getcwd() + '/script/' + 'base')
#~ for i, line in enumerate(dataframe):
#~ print(type(dataframe["MEDIA_FINAL"][i]))
#~ print(dataframe["MEDIA_FINAL"][i])
#~ print(dataframe)
build_cache(dataframe)
cpu_time = timedelta(seconds=round(time.clock() - start_time))
run_time = timedelta(seconds=round(time.time() - start_time_exec))
print("--- Tempo de CPU: {} ---".format(cpu_time))
print("--- Tempo total: {} ---".format(run_time))
cpu_time = timedelta(seconds=round(time.clock() - start_time))
run_time = timedelta(seconds=round(time.time() - start_time_exec))
print("--- Tempo de CPU: {} ---".format(cpu_time))
print("--- Tempo total: {} ---".format(run_time))
if __name__ == "__main__":
main()
main()
from django.contrib import admin
from .models import Submission
from script.main import analyze
from traceback import print_exc
def make_analysis(modeladmin, request, queryset):
for submission in queryset:
try:
print('analisando: '+str(submission))
analyze(submission)
submission.processed = True
print('salvando')
submission.save()
print('OK')
except:
print('Análise falhou')
print_exc()
class SubmissionAdmin(admin.ModelAdmin):
date_hierarchy = 'timestamp'
list_display = ('author', 'course', 'processed', 'last', 'timestamp')
actions = [make_analysis]
# Register your models here.
admin.site.register(Submission, SubmissionAdmin)
\ No newline at end of file
from django import forms
from uploads.models import Document
class DocumentForm(forms.ModelForm):
class Meta:
model = Document
fields = ('description', 'document', )
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone
from os import path
from django.conf import settings
def get_path(instance, filename):
return '{}/{}/{}'.format(instance.course, instance.id, filename)
class Submission(models.Model):
author = models.ForeignKey(User)
historico = models.FileField(upload_to=get_path)
matricula = models.FileField(upload_to=get_path)
course = models.CharField(max_length=10, default='21A')
timestamp = models.DateTimeField(default=timezone.now)
last = models.BooleanField(default=True)
processed = models.BooleanField(default=False)
def path(self):
return path.join(settings.MEDIA_ROOT, self.course, str(self.id))
class Document(models.Model):
description = models.CharField(max_length=255, blank=True)
document = models.FileField(upload_to='documents/')
uploaded_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return 'Submission (from: {}, to: {}, on: {})'.format(self.author.first_name,
self.course,
self.timestamp)
\ No newline at end of file
from django.shortcuts import render, redirect
from django.core.files.storage import FileSystemStorage
from uploads.models import Document
from uploads.forms import DocumentForm
from script.main import main as analysis
import os
from uploads.models import Submission
from uploads.core.models import Document
from uploads.core.forms import DocumentForm
def home(request):
......@@ -12,24 +13,24 @@ def home(request):
return render(request, 'uploads/home.html', {'documents': documents})
def simple_upload(request):
if request.method == 'POST' and request.FILES['historico'] and request.FILES['matricula']:
myfile = request.FILES['historico']
fs = FileSystemStorage()
filename = fs.save(myfile.name, myfile)
uploaded_file_url = fs.url(filename)
myfile = request.FILES['matricula']
fs = FileSystemStorage()
filename = fs.save(myfile.name, myfile)
uploaded_file_url = fs.url(filename)
analysis()
os.system("rm script/base/*.csv; rm script/base/*.xls;")
return render(request, 'uploads/simple_upload.html', {
'uploaded_file_url': uploaded_file_url
})
return render(request, 'uploads/simple_upload.html')
submission = Submission.objects.create(author=request.user)
submission.course = '21A'
fs = FileSystemStorage(location=submission.path())
fs.save('historico.xls', request.FILES['historico'])
fs.save('matricula.xls', request.FILES['matricula'])
submission.historico.name = submission.path() + '/historico.xls'
submission.matricula.name = submission.path() + '/matricula.xls'
submission.save()
return render(request, 'core/simple_upload.html')
def model_form_upload(request):
......
Markdown is supported
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