Stripped personal data from development repository
Samo Penic
2019-02-20 83c3f647c35477564b77cbc5b36d37d793d5442a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
wrq[2ã@sÃddlmZddlmZmZddlmZddlmZm    Z    ddl
m Z ddl m Z ddlmZmZdd    lmZdd
lmZdd lmZdd lmZdd lmZddlmZddlZGdd„dee jƒZGdd„dee j ƒZ!Gdd„dee j"e j#ƒZ$eeedd„ƒƒƒZ%Gdd„dƒZ&dd„Z'dd„Z(dd„Z)Gd d!„d!ee j*e j#ƒZ+dS)"é)Úreverse)ÚrenderÚget_object_or_404é)ÚExam)Ú HttpResponseÚHttpResponseRedirect)Úloader)Úgeneric)ÚExamFormÚ
UploadForm)Úlogin_required)ÚLoginRequiredMixin)Úajax)Ú csrf_exempt)Úsettings)ÚProblemNc@s(eZdZeZdZdd„ZdS)Ú ExamListViewzexam/index.htmlcCs tjjƒS)N)rÚobjectsÚall)Úself©rú;/home/samo/programiranje/django/sizif-web/aoi/exam/views.pyÚ get_querysetszExamListView.get_querysetN)Ú__name__Ú
__module__Ú __qualname__rÚmodelÚ template_namerrrrrrs rc@s(eZdZeZdZdd„ZdS)Ú ExamNewViewzexam/exam_new.htmlcCstddfƒS)NÚexamlistÚargs)r)rrrrÚget_success_urlszExamNewView.get_success_urlN)rrrr Ú
form_classrr"rrrrrs rcs@eZdZeZeZdZdd„Z‡fdd†Z    ‡S)ÚExamDetailViewzexam/exam_detail.htmlcCstdd|jjfƒS)NÚ
examdetailr!)rÚobjectÚpk)rrrrr"#szExamDetailView.get_success_urlc s&tt|ƒj|}d|d<|S)NzThis is just some dataZ    some_data)Úsuperr$Úget_context_data)rÚkwargsÚcontext)Ú    __class__rrr)&s
zExamDetailView.get_context_data)
rrrrrr r#rr"r)rr)r,rr$s
 r$cCs<ddl}dd|ii}t|j|jdƒƒ|S)Nrzinner-fragmentsz#testÚdata)ÚjsonÚprintÚloadsÚPOST)Úrequestr'r.r-rrrÚ saveGrouping/s r3c@speZdZdZdddd„Zdd„Zdd    „Zd
d „Zd d „Zdd„Z    dd„Z
dS)Ú    DirectoryzN
    Class deals with the paths where the simulation is run and data is stored.
    Ú.ÚcCs||_||_dS)z«Initialization Directory() takes two optional parameters, namely maindir and simdir. Defaults to current directory. It sets local variables maindir and simdir accordingly.N)ÚmaindirÚsimdir)rr7r8rrrÚ__init__Ds        zDirectory.__init__cCstjj|j|jƒS)z
        Method returns string of path where the data is stored. It combines values of maindir and simdir as maindir/simdir on Unix.
        )ÚosÚpathÚjoinr7r8)rrrrÚfullpathJszDirectory.fullpathcCs*|jƒ}tjj|ƒr"dSdSdS)zi Method checks whether the directory  specified by fullpath() exists. It return True/False on completion.TFN)r=r:r;Úexists)rr;rrrr>Ps zDirectory.existsc    CsHytj|jƒƒWn*td|jƒdƒtdƒYnXdS)zV Method make() creates directory. If it fails it exits the program with error message.zCannot make directory Ú
rN)r:Úmakedirsr=r/Úexit)rrrrÚmakeXs zDirectory.makecCs(|jƒdkr |jƒdSdSdS)z?Method makeifnotexist() creates directory if it does not exist.rTFN)r>rB)rrrrÚmakeifnotexistas
zDirectory.makeifnotexistc    CsT|jƒrPytj|jƒƒWn*td|jƒdƒtdƒYnXdS)zKMethod remove() removes directory recursively. WARNING! No questions asked.zCannot remove directory r?rN)r>r:Úrmdirr=r/rA)rrrrÚremoveis zDirectory.removec    Cs>ytj|jƒƒWn td|jƒdƒYnXdS)z¡
        Method goto() moves current directory to the one specified by fullpath(). WARNING: when using the relative paths, do not call this function multiple times.
        zCannot go to directory r?N)r:Úchdirr=r/)rrrrÚgotoss
zDirectory.gotoN) rrrÚ__doc__r9r=r>rBrCrErGrrrrr4@s         
r4c
Csmttjjtjdƒt|jƒƒ}|jƒt|ƒ}|j    dƒd    }t
tjj|j ƒ|ƒdƒ+}x!|j ƒD]}|j |ƒq‡WWdQRX|dkrid}t
tjj|j ƒ|ƒdƒ}|jƒ}WdQRXytjjd|ƒ}    Wntd|ƒ}    YnXt|ƒ||    _|    jƒ|    |jjƒkrYn|jj|    ƒdS)
NZexamsr5rzwb+Ztxtr6ÚrÚtitleéÿÿÿÿ)r4r:r;r<rÚBASE_DIRÚstrr'rCÚsplitÚopenr=ÚchunksÚwriteÚreadrrÚgetr/ÚcontentÚsaveÚproblemrÚadd)
ÚfÚexamr;ÚfilenameÚ    extensionZ destinationÚchunkrTÚfdÚprrrÚhandle_uploaded_file€s**
 ' '
    
r_cCs°ttd|ƒ}|jdkr…t|j|jƒ}|jƒrlx'|jjdƒD]}t||ƒqUWt    t
dd|fƒƒStƒ}d|d|i}t |d|ƒS)    Nr'r1Ú
file_fieldr%r!ÚformrYzexam/exam_upload.html) rrÚmethodr r1ÚFILESÚis_validÚgetlistr_rrr)r2r'rYrarXr+rrrÚ upload_fileœs     rfcCs@tjdƒ}tjjƒ}d|i}t|j||ƒƒS)Nzexam/index.htmlÚ    exam_list)r    Ú get_templaterrrrr)r2Útemplatergr+rrrÚindex®s rjc@s:eZdZeZeZdZdd„Zdd„Z    dS)Ú
UploadViewzexam/exam_upload.htmlcCstdd|jjfƒS)Nr%r!)rr&r')rrrrr"¿szUploadView.get_success_urlcOsr|jƒ}|j|ƒ}|jjdƒ}|jƒrax|D]}t|ƒq@W|j|ƒS|j|ƒSdS)Nr`)Úget_form_classÚget_formrcrerdr/Ú
form_validÚ form_invalid)rr2r!r*r#raÚfilesrXrrrÚpostÉs   
 zUploadView.postN)
rrrrrr r#rr"rqrrrrrk»s
 
rk),Ú django.urlsrÚdjango.shortcutsrrÚmodelsrÚ django.httprrÚdjango.templater    Ú django.viewsr
Úformsr r Údjango.contrib.auth.decoratorsr Zdjango.contrib.auth.mixinsrZdjango_ajax.decoratorsrÚdjango.views.decorators.csrfrÚ django.confrZproblem.modelsrr:ÚListViewrÚ
CreateViewrÚ
UpdateViewÚ
DetailViewr$r3r4r_rfrjÚFormViewrkrrrrÚ<module>s0 "@