diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | certificate/drupal_template/Makefile | 40 | ||||
-rwxr-xr-x | certificate/drupal_template/bashful.sty | 544 | ||||
-rw-r--r-- | certificate/drupal_template/drupalcamplogo.png | bin | 0 -> 464478 bytes | |||
-rwxr-xr-x | certificate/drupal_template/fossee-logo.png | bin | 0 -> 79661 bytes | |||
-rw-r--r-- | certificate/drupal_template/iitb-logo.png | bin | 0 -> 50099 bytes | |||
-rwxr-xr-x | certificate/drupal_template/template_DCM2015Pcertificate | 21 | ||||
-rw-r--r-- | certificate/drupal_template/text.png | bin | 0 -> 25608 bytes | |||
-rw-r--r-- | certificate/models.py | 12 | ||||
-rw-r--r-- | certificate/templates/drupal_download.html | 66 | ||||
-rw-r--r-- | certificate/templates/drupal_feedback.html | 32 | ||||
-rw-r--r-- | certificate/templates/index.html | 1 | ||||
-rw-r--r-- | certificate/templates/verify.html | 19 | ||||
-rw-r--r-- | certificate/urls.py | 17 | ||||
-rw-r--r-- | certificate/views.py | 244 | ||||
-rw-r--r-- | fossee_project/settings.py | 2 |
16 files changed, 977 insertions, 22 deletions
@@ -3,3 +3,4 @@ *.pyc *.swo *.swp +local.py diff --git a/certificate/drupal_template/Makefile b/certificate/drupal_template/Makefile new file mode 100644 index 0000000..525ec41 --- /dev/null +++ b/certificate/drupal_template/Makefile @@ -0,0 +1,40 @@ +# Makefile for Certificate + +# bashful package available @ +# http://www.ctan.org/tex-archive/macros/latex/contrib/bashful + +# pst-barcode package available @ +# http://www.ctan.org/tex-archive/graphics/pstricks/contrib/pst-barcode + +# target is not a real file +.PHONY: help certificate clean + +# following line is because on server texlive is not installed system-wide +#export PATH := /usr/local/texlive/2014/bin/x86_64-linux:$(PATH) + +# default help +help: + @echo "current make version is: "$(MAKE_VERSION) + @echo "Please use \`make <target>' where <target> is one of" + @echo "" + @echo "certificate Generate certificate." + @echo "clean clean all tmp and pdf files." + @echo "help Show this help." + @echo "" + +name = $(file_name) + +# certificate +participant_cert: $(name).tex fossee-logo.png bashful.sty + pdflatex -shell-escape $(name).tex + +paper_cert: $(name).tex fossee-logo.png bashful.sty + pdflatex -shell-escape $(name).tex + +workshop_cert: $(name).tex fossee-logo.png bashful.sty + pdflatex -shell-escape $(name).tex + +clean: + @echo "removing all tmp+pdf files" + -rm -rvf $(name)*.pdf *~ $(name).aux $(name).log $(name).tex *.vrb *.out *.toc *.nav *.snm + -rm -rvf *.std* *.sh diff --git a/certificate/drupal_template/bashful.sty b/certificate/drupal_template/bashful.sty new file mode 100755 index 0000000..21b6f43 --- /dev/null +++ b/certificate/drupal_template/bashful.sty @@ -0,0 +1,544 @@ +% Copyright (C) 2011,2012 by Yossi Gil yogi@cs.technion.ac.il +% --------------------------------------------------------------------------- +% This work may be distributed and/or modified under the conditions of the +% LaTeX Project Public License (LPPL), either version 1.3 of this license or +% (at your option) any later version. The latest version of this license is in +% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all +% distributions of LaTeX version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Yossi Gil. +% +% This work consists of the files bashful.tex and bashful.sty and the derived +% bashful.pdf + +\NeedsTeXFormat{LaTeX2e}% + +% Auxiliary identification information +\newcommand\date@bashful{2012/03/08}% +\newcommand\version@bashful{V 0.93}% +\newcommand\author@bashful{Yossi Gil}% +\newcommand\mail@bashful{yogi@cs.technion.ac.il}% +\newcommand\signature@bashful{% + bashful \version@bashful{} by + \author@bashful{} \mail@bashful +}% + +% Identify this package +\ProvidesPackage{bashful}[\date@bashful{} \signature@bashful: + Write and execute a bash script within LaTeX, with, or + without displaying the script and/or its output. +] +\PackageInfo{bashful}{This is bashful, \signature@bashful}% + +\RequirePackage{xcolor} +\RequirePackage{catchfile} +\RequirePackage{xkeyval} % Use xkeyval for retrieving parameters +\RequirePackage{textcomp} % For upquote + +% If true, all activities take place in a designated directory. +\newif\if@hide@BL@\@hide@BL@false + +% \if@unique@BL@ is a Boolean flag, telling us whether unique names should be +% generated for the auxiliary files (XX.sh, XX.stdout, XX.stderr and +% XX.exitCode) in each invocation of the \bash command. +\newif\if@unique@BL@\@unique@BL@false +\def\unique@BL{\if@unique@BL@ @\the\inputlineno\fi} + +% This is the default name for a directory in which processing should +% take place if \@hide@BL@true. +\def\directory@BL{_00} + +% Use listing to display bash scripts. +\RequirePackage{listings}% + + % listings style for the script, can be redefined by client + \lstdefinestyle{bashfulScript}{ + basicstyle=\ttfamily, + keywords={}, + upquote=true, + showstringspaces=false}% + % listings style for the standard output file, can be redefined by client + \lstdefinestyle{bashfulStdout}{ + basicstyle=\sl\ttfamily, + keywords={}, + upquote=true, + showstringspaces=false + }% + % listings style for the standard error file, can be redefined by client + \lstdefinestyle{bashfulStderr}{ + basicstyle=\sl\ttfamily\color{red}, + keywords={}, + upquote=true, + showstringspaces=false + }% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Keys generating file names in alphabetical order: +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% dir: String = \directory@BL: Name of directory in which execution is going +% to take place +\define@cmdkey{bashful}[BL@]{dir}{\def\directory@BL{#1}}% + +% exitCodeFile: String = \BL@exitCodeFile: In which file should the exit code +% be stored if it is not zero. +\def\BL@exitCodeFile{\jobname\unique@BL.exitCode}% +\define@cmdkey{bashful}[BL@]{exitCodeFile}{}% + +% scriptFile: String = \BL@scriptFile: In which file should the script be +% saved? +\def\BL@scriptFile{\jobname\unique@BL.sh}% +\define@cmdkey{bashful}[BL@]{scriptFile}{}% + +% stderrFile: String = \BL@stderrFile: In which file should the standard +% error stream be saved? +\def\BL@stderrFile{\jobname\unique@BL.stderr}% +\define@cmdkey{bashful}[BL@]{stderrFile}{}% + +% stdoutFile: String = \BL@stdoutFile: In which file should the standard +% output stream be saved? +\def\BL@stdoutFile{\jobname\unique@BL.stdout}% +\define@cmdkey{bashful}[BL@]{stdoutFile}{}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% List configuration boolean keys +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% list: Boolean = \ifBL@script: Should we list the script we generate? +\define@boolkey{bashful}[BL@]{script}[true]{}% + +% stdout: Boolean = \ifBL@stderr: Should we list the standard error? +\define@boolkey{bashful}[BL@]{stderr}[true]{}% + +% stdout: Boolean = \ifBL@stdout: Should we list the standard output? +\define@boolkey{bashful}[BL@]{stdout}[true]{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Error checking Boolean keys. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% stdout: Boolean = \ifBL@ignoreExitCode: Should we ignore the exit +% code? +\define@boolkey{bashful}[BL@]{ignoreExitCode}[true]{} + +% stdout: Boolean = \ifBL@ignoreStderr: Should we ignore the exit +% code? +\define@boolkey{bashful}[BL@]{ignoreStderr}[true]{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Miscelaneous keys +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% environment: String = \BL@environment: Which environment should we wrap +% the listings +\def\BL@environment{none@BL}% +\define@cmdkey{bashful}[BL@]{environment}{}% +\newenvironment{none@BL}{}{} % Default, empty environment for wrapping + % the listings + +% prefix: String = \BL@prefix: What prefix should be printed before a listing. +\def\BL@prefix{\@percentchar\space}% +\define@cmdkey{bashful}[BL@]{prefix}{}% + +% shell: String = \BL@shell: Which shell should be used for execution? +\def\BL@shell{bash}% +\define@cmdkey{bashful}[BL@]{shell}{}% + +% verbose: Boolean = \ifBL@verbose: Log every step we do +\define@boolkey{bashful}[BL@]{verbose}[true]{}% + +% The "unique" package flag that tells the package to generated unique names +% for the auxiliary files. If true the generated files (XX.sh, XX.stdout, +% XX.stderr and XX.exitCode) are given unique names in each invocation of the +% \bash command. Unique names are generated by the pattern JOB@LINE.EXTENSION, +% where JOB is the job's name, LINE is the number of the line in the input in +% which the \bash command was invoked, and EXTENSION is one of "sh", "stdout", +% "stderr" and "exitCode". +\DeclareOptionX{unique} {\@unique@BL@true} +\DeclareOptionX{hide} {\@hide@BL@true} +\DeclareOptionX{dir} {\@hide@BL@true\def\directory@BL{#1}} +\DeclareOptionX{verbose} {\BL@verbosetrue} + +\ExecuteOptionsX{} +\ProcessOptionsX\relax + +% \bash: the main command we define. It chains to \bashI which chains to +% \bashII, etc. +\begingroup + %\where@BL + \catcode`\^^M\active% + \gdef\bash{% + \logBL{Beginning a group so that all cat code changes are local}% + \begingroup% + \logBL{Making \^\^M a true newline}% + \catcode`\^^M\active% + \def^^M{^^J}% + \logBL{Checking for optional arguments}% + \@ifnextchar[{\bashI}{\bashI[]}% + }% +\endgroup + +% \bashI: Process the optional arguments and continue +\def\bashI[#1]{\setKeys@BL{#1}\bashII} + +% \bashII: Set category codes of all characters to special, and proceed. +\begingroup + \catcode`\^^M\active% + \gdef\bashII{% + \logBL{bashII: Making \^\^M a true new line}% + \catcode`\^^M\active% + \def^^M{^^J}% + \logBL{bashII: Making all characters other}% + \let\do\@makeother% + \dospecials% + \bashIII}% +\endgroup + +% \bashIII: Consume all tokens until \END (but ignoring the preceding and +% terminating newline), and proceed. +\begingroup + \catcode`\@=0\relax + \catcode`\^^M\active + @catcode`@\=12@relax% + @gdef@bashIII^^M#1^^M% + \END{@bashIV{#1}@bashV{#1}@logBL{bashV: Done!}@endgroup}@endgroup + +% \bashIV: Process the tokens by storing them in a script file, and executing +% this file, +\newcommand\bashIV[1]{% + \logBL{BashIV: begin}% + \makeDirectory@BL + \generateScriptFile@BL{#1}\relax + \executeScriptFile@BL + \logBL{BashIV: done}% +}% + +% \logBL: record a log message in verbose mode +\newcommand\logBL[1]{\ifBL@verbose\typeout{L\the\inputlineno: #1}\fi} + +% A macro to create a new directory +\def\makeDirectory@BL{% + \if@hide@BL@ + \logBL{Making directory \directory@BL}% + \immediate\write18{mkdir -p \directory@BL}% + \else + \logBL{Using current directory}% + \fi +} + +\newcommand\splice[1]{% + \bashIV{#1}% + \expandFileName@BL{\BL@stdoutFile}% + \CatchFileDef{\BL@file@contents}{\BL@stdoutFile}{\relax}% + \ignorespaces\BL@file@contents\unskip +} + +% listing the script file if required, and presenting the standard output and +% standard error files if required. +\newcommand\bashV[1]{% + \logBL{Wrapping up after execution}% + \storeToFile@BL{\BL@prefix#1}{\BL@scriptFile}% + \expandFileName@BL\BL@scriptFile + \expandFileName@BL\BL@stdoutFile + \expandFileName@BL\BL@stderrFile + \logBL{Files are: \BL@scriptFile, \BL@stdoutFile, and \BL@stderrFile}% + \checkScriptErrors@BL + \listEverything@BL + \defineMacros@BL + \logBL{Wrap up done}} + +\def\expandFileName@BL#1{% + \logBL{Setting, if necessary, correct path of \noexpand#1 }% + \if@hide@BL@ + \logBL{Prepending path (\directory@BL) to #1}% + \edef#1{\directory@BL/#1}% + \logBL{Obtained #1}% + \fi +} + +\def\setKeys@BL#1{% + \logBL{Processing key=val pairs in options string [#1]}\relax + \setkeys{bashful}{#1}% +}% + +% Store the list of tokens in the first argument into our script file +\newcommand\generateScriptFile@BL[1]{% + \logBL{Generating script file \BL@scriptFile} + \storeToFile@BL{#1}{\BL@scriptFile}% +}% + +\newwrite\writer@BL +% Store the list of tokens in the first argument into the file given +% in the second argument; prepend directory if necessary +\newcommand\storeToFile@BL[2]{% + \logBL{ #2 :=^^J#1^^J}% + \if@hide@BL@ + \logBL{File #2 will be created in \directory@BL}% + \storeToFileI@BL{#1}{\directory@BL/#2} + \else + \logBL{File #2 will be created in current directory}% + \storeToFileI@BL{#1}{#2}% + \fi + \logBL{Writing done!}% +}% + +% Store the list of tokens in the first argument into the file given +% in the second argument; the second argument could be qualified with +% a directory name. +\newcommand\storeToFileI@BL[2]{% + \logBL{Writing to file #2...}% + \immediate\openout\writer@BL#2% + \immediate\write\writer@BL{#1}% + \immediate\closeout\writer@BL +}% + +% Execute the content of our script file. +\newcommand\executeScriptFile@BL{% + \edef\command@BL{\BL@shell \space \BL@scriptFile}% + \if@hide@BL@ + \logBL{Adding a "cd command"}% + \edef\command@BL{cd \directory@BL;\command@BL} + \fi% + \edef\command@BL{\command@BL \space >\BL@stdoutFile \space 2>\BL@stderrFile}% + \edef\command@BL{\command@BL \space || echo $? >\BL@exitCodeFile}% + \edef\command@BL{\BL@shell\space -c "\command@BL"}% + \logBL{Executing:^^J \command@BL}% + \immediate\write18{\command@BL}% +}% + +\newread\reader@BL + +% Issue an error message if errors found during execution +\newcommand\checkScriptErrors@BL{% + \logBL{Checking for script errors}% +% \begingroup + \newif\ifErrorsFound@\ErrorsFound@false + \checkExitCodeFile@BL + \ifdefined\exitCode@BL + \logBL{Non zero exit code found (\exitCode@BL), and I was not instructed to + ignore it} + \ErrorsFound@true + \fi + \def\eoln{\par} + \def\firstErrorLine{\par} + \checkStderrFile@BL + \logBL{I will now print the contents of file \BL@stderrFile\space (if found)} + \ifx\firstErrorLine\eoln + \relax + \else + \logBL{Standard error was not empty, and I was not instructed to ignore it} + \message{Standard error not empty. Here is how + ^^Jfile \BL@stderrFile\space begins: + ^^J>>>>\firstErrorLine + ^^J>>>>\space + ^^Jbut, you really ought to examine this file yourself!} + \ErrorsFound@true + \fi + \ifErrorsFound@ + \logBL{Issuing an error message since \BL@stderrFile\space was not empty}% + \errmessage{Your shell script failed...}% + \BL@verbosetrue + \logBL{Switching to verbose mode}% + \else + \logBL{File \BL@stderrFile\space was empty}% + \logBL{Proceeding as usual}% + \fi +% \endgroup +}% + +\newcommand\checkExitCodeFile@BL{% + \logBL{Considering \BL@exitCodeFile}% + \ifBL@ignoreExitCode + \logBL{Ignoring \BL@exitCodeFile, as per command flag}% + \else + \logBL{Opening \BL@exitCodeFile}% + \openin\reader@BL=\BL@exitCodeFile + \ifeof\reader@BL + \logBL{File \BL@exitCodeFile\space is missing, exit code was probably 0} + \closein\reader@BL + \else + \logBL{File \BL@exitCodeFile\space exists, let's get the exit code}% + \logBL{Reading first line of \BL@exitCodeFile}% + \catcode`\^^M=5 + \read\reader@BL to \exitCode@BL + \closein\reader@BL + \fi + \fi +} + +\newcommand\checkStderrFile@BL{% + \ifBL@stderr + \logBL{Will be listing \BL@stderrFile, so erroneous content is ignored}% + \else + \ifBL@ignoreStderr + \logBL{Ignoring \BL@stderrFile, as per command flag}% + \else + \checkStderrFileI@BL + \fi + \fi +} + +\newcommand\checkStderrFileI@BL{% + \logBL{Opening \BL@stderrFile}% + \openin\reader@BL=\BL@stderrFile\relax + \ifeof\reader@BL + \logBL{Hmm... \BL@stderrFile\space does not exist (probably a package bug)}% + \logBL{Switching to verbose mode}% + \BL@verbosetrue + \else + \logBL{Reading first line of \BL@stderrFile}% + \catcode`\^^M=5 + \read\reader@BL to \firstErrorLine + \ifeof\reader@BL + \ifx\firstErrorLine\eoln + \logBL{File \BL@stderrFile\space is empty} + \else + \logBL{File \BL@stderrFile\space has one line [\firstErrorLine]}% + \ErrorsFound@true + \fi + \else + \logBL{File \BL@stderrFile\space has two lines or more}% + \ErrorsFound@true + \fi + \fi + \closein\reader@BL +} + +% List the contents of the script, stdout and stderr, as per the flags. +\newcommand\listEverything@BL{% + \logBL{Checking whether any listings are required}% + \newif\if@listSomething@BL@ + \ifBL@script\@listSomething@BL@true\fi + \ifBL@stdout\@listSomething@BL@true\fi + \ifBL@stderr\@listSomething@BL@true\fi + \if@listSomething@BL@ + \beginWrappingEnvironment@BL + \listEverythingWithinEnvironment@BL + \endWrappingEnvironment@BL + \else + \logBL{Nothing has to be listed}% + \fi +} + +% Auxiliary macro to list the contents of the script, stdout and stderr, as per +% the flags. +\newcommand\listEverythingWithinEnvironment@BL{% + \logBL{Laying out the correct \noexpand\lstinputlisting commands}%1 + \ifBL@script\listScript@BL\BL@scriptFile\fi + \ifBL@stdout\listStdout@BL\BL@stdoutFile\fi + \ifBL@stderr\listStderr@BL\BL@stderrFile\fi +}% + +\newcommand\listScript@BL[1]{% + \logBL{Listing script: #1} + \def\flags@BL{style=bashfulScript} + \logBL{Initial flags for listing #1 are \flags@BL} + \ifBL@stdout\edef\flags@BL{\flags@BL, belowskip=0pt}\fi + \ifBL@stderr\edef\flags@BL{\flags@BL, belowskip=0pt}\fi + \doList@BL#1\flags@BL +} + +\newcommand\listStdout@BL[1]{% + \logBL{Listing stdout: #1} + \edef\flags@BL{style=bashfulStdout} + \logBL{Initial flags for listing stdout file are \flags@BL} + \ifBL@script\edef\flags@BL{\flags@BL, aboveskip=0pt}\fi + \ifBL@stderr\edef\flags@BL{\flags@BL, belowskip=0pt}\fi + \doList@BL#1\flags@BL +}% + +\newcommand\listStderr@BL[1]{% + \logBL{Listing stderr: #1}% + \def\flags@BL{style=bashfulStderr}% + \logBL{Initial flags for listing stderr file are \flags@BL} + \ifBL@script\edef\flags@BL{\flags@BL, aboveskip=0pt}\fi + \ifBL@stdout\edef\flags@BL{\flags@BL, aboveskip=0pt}\fi + \doList@BL#1\flags@BL +}% + +\newcommand\doList@BL[2]{% + \logBL{Flags for listing #1 are #2}% + \expandafter\lstset\expandafter{#2}% + \lstinputlisting{#1}% + }% + +\def\beginWrappingEnvironment@BL{% + \logBL{Beginning environment \BL@environment}% + \expandafter\csname\BL@environment\endcsname + \forceLTR@BL + \fixPolyglossiaBug@BL +}% + +\def\endWrappingEnvironment@BL{% + \expandafter\csname end\BL@environment\endcsname +}% + +% Define the \bashStdout and \bashStderr macro. +\newcommand\defineMacros@BL{% + \logBL{Defining macro for the contents of the standard output file}% + \immediate\openin\reader@BL=\BL@stdoutFile + \logBL{Opened file \BL@stdoutFile}% + \begingroup + \endlinechar=-1% + \ifeof\reader@BL + \logBL{File \BL@stdoutFile was empty}% + \global\let\bashStdout\relax + \else + \logBL{Reading contents of \BL@stdoutFile}% + \immediate\read\reader@BL to \BL@temp + \global\let\bashStdout\BL@temp + \fi + \typeout{after EOF}% + \logBL{bashStdout :=^^J\bashStdout^^J}% + \endgroup + \logBL{Closing file \BL@stdoutFile}% + \immediate\closein\reader@BL + \logBL{Defining macro for the contents of the standard error file}% + \immediate\openin\reader@BL=\BL@stderrFile + \logBL{Opened file \BL@stderrFile}% + \begingroup + \endlinechar=-1% + \ifeof\reader@BL + \logBL{File \BL@stdoutFile was empty}% + \global\let\bashStdout\relax + \else + \logBL{Reading contents of \BL@stderrFile}% + \immediate\read\reader@BL to \BL@temp + \global\let\bashStderr\BL@temp + \fi + \logBL{bashStderr :=^^J\bashStderr^^J}% + \endgroup + \logBL{Closing file \BL@stderrFile}% + \immediate\closein\reader@BL +} + +\newcommand\fixPolyglossiaBug@BL{% + \logBL{Trying to fix a Polyglossia package bug}% + \ifdefined\ttfamilylatin + \logBL{Replacing \noexpand\ttfamily with \noexpand\ttfamilylatin}% + \let\ttfamily=\ttfamilylatin + \logBL{Replacing \noexpand\rmfamily with \noexpand\rmfamilylatin}% + \let\rmfamily=\rmfamilylatin + \logBL{Replacing \noexpand\sffamily with \noexpand\sffamilylatin}% + \let\sffamily=\sffamilylatin + \logBL{Replacing \noexpand\normalfont with \noexpand\normalfontlatin}% + \let\normalfont=\normalfontlatin + \else + \logBL{Polyglossia package probably not loaded}% + \relax + \fi +}% + +\newcommand\forceLTR@BL{% + \logBL{Making sure we are not in right-to-left mode}% + \ifdefined\setLTR + \logBL{Command \noexpand\setLTR is defined, invoking it}% + \setLTR + \else + \logBL{Command \noexpand\setLTR is not defined, we are probably LTR}% + \relax + \fi +}% diff --git a/certificate/drupal_template/drupalcamplogo.png b/certificate/drupal_template/drupalcamplogo.png Binary files differnew file mode 100644 index 0000000..0c56de4 --- /dev/null +++ b/certificate/drupal_template/drupalcamplogo.png diff --git a/certificate/drupal_template/fossee-logo.png b/certificate/drupal_template/fossee-logo.png Binary files differnew file mode 100755 index 0000000..6feda2d --- /dev/null +++ b/certificate/drupal_template/fossee-logo.png diff --git a/certificate/drupal_template/iitb-logo.png b/certificate/drupal_template/iitb-logo.png Binary files differnew file mode 100644 index 0000000..2915da3 --- /dev/null +++ b/certificate/drupal_template/iitb-logo.png diff --git a/certificate/drupal_template/template_DCM2015Pcertificate b/certificate/drupal_template/template_DCM2015Pcertificate new file mode 100755 index 0000000..3371830 --- /dev/null +++ b/certificate/drupal_template/template_DCM2015Pcertificate @@ -0,0 +1,21 @@ +* certificate template + +** Usage + - To generate a PDF file type, + #+BEGIN_SRC sh + make $command + #+END_SRC sh + + - To clean the project + #+BEGIN_SRC sh + make clean + #+END_SRC sh + +** License + The tex file and all the images within this project are entirely + PRIVATE. It's usage outside the `Fossee Project` is an legal + offense and will be subject to suitable punishment by Indian law. + + +** Website + [[http://fossee.in]] diff --git a/certificate/drupal_template/text.png b/certificate/drupal_template/text.png Binary files differnew file mode 100644 index 0000000..374109a --- /dev/null +++ b/certificate/drupal_template/text.png diff --git a/certificate/models.py b/certificate/models.py index 3974bde..7bb589b 100644 --- a/certificate/models.py +++ b/certificate/models.py @@ -29,6 +29,8 @@ class Certificate(models.Model): workshop = models.CharField(max_length=100, null=True, blank=True) paper = models.CharField(max_length=100, null=True, blank=True) verified = models.IntegerField(default=0) + serial_key = models.CharField(max_length=200, null=True) + short_key = models.CharField(max_length=50, null=True) class Scilab_participant(models.Model): ''' Autogenerated model file csvimport Mon Dec 1 07:46:00 2014 ''' @@ -107,3 +109,13 @@ class Scipy_speaker(models.Model): paper = models.CharField(max_length=300) purpose = models.CharField(max_length=10, default='SPC') attendance = models.BooleanField(default=False) + +class Drupal_camp(models.Model): + firstname = models.CharField(max_length=200) + lastname = models.CharField(max_length=200) + email = models.EmailField(null=True, blank=True) + # Day 1 - 1, Day 2 - 2, Both days - 3, else 0 + attendance = models.PositiveSmallIntegerField(default=0) + role = models.CharField(max_length=100, null=True, blank=True) + purpose = models.CharField(max_length=10, default='DCM') + is_student = models.IntegerField(default=0) diff --git a/certificate/templates/drupal_download.html b/certificate/templates/drupal_download.html new file mode 100644 index 0000000..a93528c --- /dev/null +++ b/certificate/templates/drupal_download.html @@ -0,0 +1,66 @@ +{% extends 'base.html' %} +{% block header%} + <h1> Drupal Camp Mumbai 2015 </h1> +{% endblock %} +{% block content %} + <div class="modal fade" id="invalidModal" tabindex="-1" role="dialog" aria-labelledby="invalidModalLabel" aria-hidden="true"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> + <h4 class="modal-title" id="invalidModalLabel">Invalid Category</h4> + </div> + <div class="modal-body"> + {% if notregistered == 1 %} + The requested certificate is unavailable for your email address. Please select the appropriate category and retry. + {% else %} + The user has not attended the Drupal Camp Mumbai 2015. + {% endif %} + </div> + </div> + </div> + </div> + <form class="col-lg-12" action="{% url 'certificate:drupal_download' %}" method="post"> + {% csrf_token %} + {{ message }} + <hr> + <div class="input-group" style="width:340px;text-align:center;margin:0 auto;"> + <input style="width:450;" class="form-control input-lg" placeholder="Enter the email address you used for registration" type="text" id="email" name=email> + <span class="input-group-btn"><button class="btn btn-lg btn-primary" type="submit">Download Certificate</button></span> + </div> + </form> + <center><h4>Problem in downloading the certificate? Write to us at <a href="mailto:info@fossee.in">info[at]fossee[dot]in</a></h4> + + <div class="modal fade" id="errorModal" tabindex="-1" role="dialog" aria-labelledby="errorModalLabel" aria-hidden="true"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> + <h4 class="modal-title" id="invalidModalLabel">Problem in downloading</h4> + </div> + <div class="modal-body"> + Sorry could not process your certificate. Kindly contact the FOSSEE team. + </div> + </div> + </div> + </div> +{% endblock %} + +{% block javascript %} +<script> + $(document).ready(function(){ + error = "{{ error }}" + if(error == "True"){ + console.log("edfed") + $("#errorModal").modal(); + } + notreg = "{{ notregistered }}"; + if(notreg == "1"){ + $("#invalidModal").modal(); + } + if(notreg == "2"){ + $("#invalidModal").modal(); + } + }); +</script> +{% endblock %} diff --git a/certificate/templates/drupal_feedback.html b/certificate/templates/drupal_feedback.html new file mode 100644 index 0000000..1d9d9c8 --- /dev/null +++ b/certificate/templates/drupal_feedback.html @@ -0,0 +1,32 @@ +{% extends 'base.html' %} + +{% block header%} + <h1> Drupal Mumbai Camp 2015 </h1> +{% endblock %} +{% block content %} +<form action="{% url 'certificate:drupal_feedback' %}" method="post" style="width:1000px"> + + <div style="padding-left:100px;width:940px;text-align:center;margin:0 auto;"> + <div align=center style="padding-left:200px"> <h1> Feedback </h1> + <p>Please fill the feedback form. This will greatly enable us to do better.</p> + </div> + + {{ detail }} + {% csrf_token %} + <div style="padding-left:200px;text-align:left;" > + <table class="table"> + {{ form }} + </table> + {% for question in questions %} + <label>{{ forloop.counter }}. {{ question.question }} </label><br> + <textarea cols="80" class="form-control" id="{{ question.id }}" name="{{ question.id }}"></textarea><br> + {% endfor %} + <span><button class="btn btn-primary" type="submit">Submit</button></span> + <span style="float:right"><a href="{% url 'certificate:drupal_download' %}" >I have already submitted</a></span> + </div> + </div> + </form> + <hr> +{% endblock %} + + diff --git a/certificate/templates/index.html b/certificate/templates/index.html index fca36d5..9c3816c 100644 --- a/certificate/templates/index.html +++ b/certificate/templates/index.html @@ -9,6 +9,7 @@ <ul class="nav nav-list"> <li ><a href="{% url 'certificate:feedback' %}" >Scilab India Conference 2014</a></li> <li><a href="{% url 'certificate:scipy_feedback' %}" >SciPy India Conference 2014</a></li> + <li><a href="{% url 'certificate:drupal_feedback' %}" >Drupal Camp Mumbai 2015</a></li> </ul> <div> {% endblock %} diff --git a/certificate/templates/verify.html b/certificate/templates/verify.html index 3f3ac72..a4ce037 100644 --- a/certificate/templates/verify.html +++ b/certificate/templates/verify.html @@ -4,6 +4,22 @@ <h1> Certificate Verification </h1> {% endblock %} {% block content %} +{% if serial_key %} +<div> + <table class="table table-bordered" align="center" style="width:50%"> + <caption>Participation Details</caption> + <tbody> + {% for key, value in detail.items %} + <tr> + <td>{{ key }}</td> + <td>{{ value }}</td> + </tr> + {% endfor %} + </tbody> + </table> + <div style="width:40%"><a href="{% url 'certificate:verify' %}" >< Back</a></div> +</div> +{% else %} <div class="modal fade" id="invalidModal" tabindex="-1" role="dialog" aria-labelledby="invalidModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> @@ -17,7 +33,7 @@ </div> </div> </div> - <p>Enter the serial number you received while scanning the QR code on certificate.</p> + <p><b> Enter the alphanumeric characters below the QR code<br> OR <br>Enter the serial number you received while scanning the QR code on certificate</p> <hr> <form action="{% url 'certificate:verify' %}" method="post"> {{ detail }} @@ -26,6 +42,7 @@ <input class="form-control input-lg" placeholder="Enter the serial number" type="text" name=serial_no> <span class="input-group-btn"><button class="btn btn-lg btn-primary" type="submit">Verify</button></span> </div> +{% endif %} </form> <hr> <center><h4>Problem in verfying details ? write to us at <a href="mailto:info@fossee.in">info[at]fossee[dot]in</a></h4> diff --git a/certificate/urls.py b/certificate/urls.py index 9c965c0..bb9871b 100644 --- a/certificate/urls.py +++ b/certificate/urls.py @@ -3,15 +3,18 @@ from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() -urlpatterns = patterns('', +urlpatterns = patterns('certificate.views', # Examples: # url(r'^$', 'fossee_project.views.home', name='home'), # url(r'^blog/', include('blog.urls')), - url(r'^$', 'certificate.views.index', name='index'), - url(r'^download/$', 'certificate.views.download', name='download'), - url(r'^verify/$', 'certificate.views.verify', name='verify'), - url(r'^feedback/$', 'certificate.views.feedback', name='feedback'), - url(r'^scipy_feedback/$', 'certificate.views.scipy_feedback', name='scipy_feedback'), - url(r'^scipy_download/$', 'certificate.views.scipy_download', name='scipy_download'), + url(r'^$', 'index', name='index'), + url(r'^download/$', 'download', name='download'), + url(r'^verify/$', 'verify', name='verify'), + url(r'^verify/(?P<serial_key>.*)/$', 'verify', name='verify-directly'), + url(r'^feedback/$', 'feedback', name='feedback'), + url(r'^scipy_feedback/$', 'scipy_feedback', name='scipy_feedback'), + url(r'^drupal_feedback/$', 'drupal_feedback', name='drupal_feedback'), + url(r'^scipy_download/$', 'scipy_download', name='scipy_download'), + url(r'^drupal_download/$', 'drupal_download', name='drupal_download'), ) diff --git a/certificate/views.py b/certificate/views.py index 04fa09a..a8fa759 100644 --- a/certificate/views.py +++ b/certificate/views.py @@ -2,12 +2,13 @@ from django.shortcuts import render from django.http import HttpResponse from django.shortcuts import render_to_response, redirect from django.template import RequestContext -from certificate.models import Scilab_participant, Certificate, Event, Scilab_speaker, Scilab_workshop, Question, Answer, FeedBack, Scipy_participant, Scipy_speaker +from certificate.models import Scilab_participant, Certificate, Event, Scilab_speaker, Scilab_workshop, Question, Answer, FeedBack, Scipy_participant, Scipy_speaker, Drupal_camp import subprocess import os from string import Template +import hashlib from certificate.forms import FeedBackForm - +from collections import OrderedDict # Create your views here. def index(request): @@ -96,39 +97,103 @@ def download(request): context['message'] = 'You can download the certificate' return render_to_response('download.html', context, ci) -def verify(request): +def verification(serial, _type): context = {} - ci = RequestContext(request) - detail = None - if request.method == 'POST': - serial_no = request.POST.get('serial_no').strip() + if _type == 'key': try: - certificate = Certificate.objects.get(serial_no=serial_no) + certificate = Certificate.objects.get(short_key=serial) + name = certificate.name.title() + paper = certificate.paper + workshop = certificate.workshop + serial_no = certificate.serial_no + certificate.verified += 1 + certificate.save() + purpose, year, type = _get_detail(serial_no) + if type == 'P': + if purpose == 'Drupal Mumbai Camp': + drupal_user = Drupal_camp.objects.get(email=certificate.email) + DAY = drupal_user.attendance + if DAY == 1: + day = 'Day 1' + elif DAY == 2: + day = 'Day 2' + elif DAY == 3: + day = 'Day 1 and Day 2' + detail = OrderedDict([('Name', name), ('Attended', day), + ('Event', purpose), ('Year', year)]) + else: + detail = '{0} had attended {1} {2}'.format(name, purpose, year) + elif type == 'A': + detail = '{0} had presented paper on {3} in the {1} {2}'.format\ + (name, purpose, year, paper) + elif type == 'W': + detail = '{0} had attended workshop on {3} in the {1} {2}'.format\ + (name, purpose, year, workshop) + context['serial_key'] = True except Certificate.DoesNotExist: + detail = 'User does not exist' context["invalidserial"] = 1 - return render_to_response('verify.html', context, context_instance=ci) - else: + context['detail'] = detail + return context + if _type == 'number': + try: + certificate = Certificate.objects.get(serial_no=serial) name = certificate.name.title() paper = certificate.paper workshop = certificate.workshop certificate.verified += 1 certificate.save() - purpose, year, type = _get_detail(serial_no) + purpose, year, type = _get_detail(serial) if type == 'P': - detail = '{0} had attended {1} {2}'.format(name, purpose, year) + if purpose == 'Drupal Mumbai Camp': + drupal_user = Drupal_camp.objects.get(email=certificate.email) + DAY = drupal_user.attendance + if DAY == 1: + day = 'Day 1' + elif DAY == 2: + day = 'Day 2' + elif DAY == 3: + day = 'Day 1 and Day 2' + detail = {} + detail['Name'] = name + detail['Attended'] = day + detail['Event'] = purpose + detail['Year'] = year + else: + detail = '{0} had attended {1} {2}'.format(name, purpose, year) elif type == 'A': detail = '{0} had presented paper on {3} in the {1} {2}'.format(name, purpose, year, paper) elif type == 'W': detail = '{0} had attended workshop on {3} in the {1} {2}'.format(name, purpose, year, workshop) context['detail'] = detail - return render_to_response('verify.html', context, ci) + except Certificate.DoesNotExist: + context["invalidserial"] = 1 + return context + + +def verify(request, serial_key=None): + context = {} + ci = RequestContext(request) + detail = None + if serial_key is not None: + context = verification(serial_key, 'key') + return render_to_response('verify.html', context, ci) + if request.method == 'POST': + serial_no = request.POST.get('serial_no').strip() + context = verification(serial_no, 'number') + if 'invalidserial' in context: + context = verification(serial_no, 'key') + return render_to_response('verify.html', context, ci) return render_to_response('verify.html',{}, ci) def _get_detail(serial_no): + purpose = None if serial_no[0:3] == 'SLC': purpose = 'Scilab Conference' elif serial_no[0:3] == 'SPC': purpose = 'SciPy India' + elif serial_no[0:3] == 'DCM': + purpose = 'Drupal Mumbai Camp' if serial_no[3:5] == '14': year = '2014' @@ -394,3 +459,156 @@ def create_scipy_certificate(certificate_path, name, qrcode, type, paper, worksh print e error = True return [None, error] + + +def drupal_feedback(request): + context = {} + ci = RequestContext(request) + form = FeedBackForm() + questions = Question.objects.filter(purpose='DMC') + if request.method == 'POST': + form = FeedBackForm(request.POST) + if form.is_valid(): + data = form.cleaned_data + try: + FeedBack.objects.get(email=data['email'].strip(), purpose='DMC') + context['message'] = 'You have already submitted the feedback. You can download your certificate.' + return render_to_response('drupal_download.html', context, ci) + except FeedBack.DoesNotExist: + feedback = FeedBack() + feedback.name = data['name'].strip() + feedback.email = data['email'].strip() + feedback.purpose = 'DMC' + feedback.submitted = True + feedback.save() + for question in questions: + answered = request.POST.get('{0}'.format(question.id), None) + answer = Answer() + answer.question = question + answer.answer = answered.strip() + answer.save() + feedback.answer.add(answer) + feedback.save() + context['message'] = 'Thank you for the feedback. You can download your certificate.' + return render_to_response('drupal_download.html', context, ci) + + context['form'] = form + context['questions'] = questions + + return render_to_response('drupal_feedback.html', context, ci) + +def drupal_download(request): + context = {} + err = "" + ci = RequestContext(request) + cur_path = os.path.dirname(os.path.realpath(__file__)) + certificate_path = '{0}/drupal_template/'.format(cur_path) + + if request.method == 'POST': + email = request.POST.get('email').strip() + type = request.POST.get('type', 'P') + paper = None + workshop = None + if type == 'P': + user = Drupal_camp.objects.filter(email=email) + if not user: + context["notregistered"] = 1 + return render_to_response('drupal_download.html', + context, context_instance=ci) + else: + user = user[0] + fname = user.firstname + lname = user.lastname + name = '{0} {1}'.format(fname, lname) + purpose = user.purpose + DAY = user.attendance + if DAY == 1: + day = 'Day 1' + elif DAY == 2: + day = 'Day 2' + elif DAY == 3: + day = 'Day 1 and Day 2' + else: + context['notregistered'] = 2 + return render_to_response('drupal_download.html', context, + context_instance=ci) + year = '15' + id = int(user.id) + hexa = hex(id).replace('0x','').zfill(6).upper() + serial_no = '{0}{1}{2}{3}'.format(purpose, year, hexa, type) + serial_key = (hashlib.sha1(serial_no)).hexdigest() + file_name = '{0}{1}'.format(email,id) + file_name = file_name.replace('.', '') + try: + old_user = Certificate.objects.get(email=email, serial_no=serial_no) + qrcode = 'Verify at: http://fossee.in/certificates/verify/{0} '.format(old_user.short_key) + details = {'name': name, 'day': day, 'serial_key': old_user.short_key} + certificate = create_drupal_certificate(certificate_path, details, + qrcode, type, paper, workshop, file_name) + if not certificate[1]: + old_user.counter = old_user.counter + 1 + old_user.save() + return certificate[0] + except Certificate.DoesNotExist: + uniqueness = False + num = 5 + while not uniqueness: + present = Certificate.objects.filter(short_key__startswith=serial_key[0:num]) + if not present: + short_key = serial_key[0:num] + uniqueness = True + else: + num += 1 + qrcode = 'Verify at: http://fossee.in/certificates/verify/{0} '.format(short_key) + details = {'name': name, 'day': day, 'serial_key': short_key} + certificate = create_drupal_certificate(certificate_path, details, + qrcode, type, paper, workshop, file_name) + if not certificate[1]: + certi_obj = Certificate(name=name, email=email, + serial_no=serial_no, counter=1, workshop=workshop, + paper=paper, serial_key=serial_key, short_key=short_key) + certi_obj.save() + return certificate[0] + + if certificate[1]: + _clean_certificate_certificate(certificate_path, file_name) + context['error'] = True + return render_to_response('drupal_download.html', context, ci) + context['message'] = 'You can download the certificate' + return render_to_response('drupal_download.html', context, ci) + + +def create_drupal_certificate(certificate_path, name, qrcode, type, paper, workshop, file_name): + error = False + try: + download_file_name = None + template = 'template_DCM2015Pcertificate' + download_file_name = 'DCM2015Pcertificate.pdf' + + template_file = open('{0}{1}'.format\ + (certificate_path, template), 'r') + content = Template(template_file.read()) + template_file.close() + + content_tex = content.safe_substitute(name=name['name'].title(), + day=name['day'], serial_key = name['serial_key'], qr_code=qrcode) + create_tex = open('{0}{1}.tex'.format\ + (certificate_path, file_name), 'w') + create_tex.write(content_tex) + create_tex.close() + return_value, err = _make_certificate_certificate(certificate_path, + type, file_name) + if return_value == 0: + pdf = open('{0}{1}.pdf'.format(certificate_path, file_name) , 'r') + response = HttpResponse(content_type='application/pdf') + response['Content-Disposition'] = 'attachment; \ + filename=%s' % (download_file_name) + response.write(pdf.read()) + _clean_certificate_certificate(certificate_path, file_name) + return [response, False] + else: + error = True + except Exception, e: + print e + error = True + return [None, error] diff --git a/fossee_project/settings.py b/fossee_project/settings.py index 0d0018a..4731d89 100644 --- a/fossee_project/settings.py +++ b/fossee_project/settings.py @@ -26,7 +26,7 @@ DEBUG = True TEMPLATE_DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = [] #['localhost'] when debug is False TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". |