From 5d0a69c7050a15a5bbbcb8d725ffa1ac979bfe52 Mon Sep 17 00:00:00 2001 From: Keegan Date: Mon, 23 Mar 2020 05:14:18 -0400 Subject: [PATCH] Working Mod Pipeline --- .../__pycache__/decorators.cpython-35.pyc | Bin 0 -> 676 bytes .../auth/__pycache__/admin.cpython-35.pyc | Bin 0 -> 185 bytes .../apps/auth/__pycache__/apps.cpython-35.pyc | Bin 0 -> 411 bytes .../auth/__pycache__/models.cpython-35.pyc | Bin 0 -> 182 bytes .../auth/__pycache__/views.cpython-35.pyc | Bin 1267 -> 1485 bytes server/server/apps/auth/apps.py | 3 +- .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 151 bytes server/server/apps/auth/views.py | 9 +- .../content/__pycache__/admin.cpython-35.pyc | Bin 0 -> 188 bytes .../content/__pycache__/models.cpython-35.pyc | Bin 0 -> 185 bytes .../content/__pycache__/views.cpython-35.pyc | Bin 526 -> 606 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 154 bytes server/server/apps/content/views.py | 20 ++-- server/server/apps/course/__init__.py | 0 .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 141 bytes .../course/__pycache__/admin.cpython-35.pyc | Bin 0 -> 267 bytes .../course/__pycache__/models.cpython-35.pyc | Bin 0 -> 849 bytes .../course/__pycache__/urls.cpython-35.pyc | Bin 0 -> 592 bytes .../course/__pycache__/views.cpython-35.pyc | Bin 0 -> 3152 bytes server/server/apps/course/admin.py | 6 + server/server/apps/course/apps.py | 5 + .../apps/course/migrations/0001_initial.py | 23 ++++ .../apps/course/migrations/0002_course_url.py | 19 +++ .../0003_course_unapproved_files.py | 19 +++ .../migrations/0004_course_rejected_files.py | 19 +++ .../server/apps/course/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-35.pyc | Bin 0 -> 818 bytes .../0002_course_url.cpython-35.pyc | Bin 0 -> 666 bytes ...003_course_unapproved_files.cpython-35.pyc | Bin 0 -> 762 bytes .../0004_course_rejected_files.cpython-35.pyc | Bin 0 -> 786 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 153 bytes server/server/apps/course/models.py | 17 +++ server/server/apps/course/tests.py | 3 + server/server/apps/course/urls.py | 13 ++ server/server/apps/course/views.py | 111 ++++++++++++++++++ server/server/apps/decorators.py | 15 +++ server/server/apps/files/__init__.py | 0 .../files/__pycache__/__init__.cpython-35.pyc | Bin 0 -> 141 bytes .../files/__pycache__/admin.cpython-35.pyc | Bin 0 -> 469 bytes .../files/__pycache__/models.cpython-35.pyc | Bin 0 -> 1082 bytes server/server/apps/files/admin.py | 8 ++ server/server/apps/files/apps.py | 5 + server/server/apps/files/forms.py | 8 ++ .../apps/files/migrations/0001_initial.py | 21 ++++ .../migrations/0002_auto_20200302_0345.py | 24 ++++ .../server/apps/files/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-35.pyc | Bin 0 -> 648 bytes .../0002_auto_20200302_0345.cpython-35.pyc | Bin 0 -> 764 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 152 bytes server/server/apps/files/models.py | 20 ++++ server/server/apps/files/tests.py | 3 + server/server/apps/files/views.py | 18 +++ server/server/apps/mod/__init__.py | 0 .../mod/__pycache__/__init__.cpython-35.pyc | Bin 0 -> 139 bytes .../apps/mod/__pycache__/admin.cpython-35.pyc | Bin 0 -> 267 bytes .../mod/__pycache__/models.cpython-35.pyc | Bin 0 -> 751 bytes .../apps/mod/__pycache__/urls.cpython-35.pyc | Bin 0 -> 311 bytes .../apps/mod/__pycache__/views.cpython-35.pyc | Bin 0 -> 822 bytes server/server/apps/mod/admin.py | 7 ++ server/server/apps/mod/apps.py | 5 + .../apps/mod/migrations/0001_initial.py | 24 ++++ server/server/apps/mod/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-35.pyc | Bin 0 -> 870 bytes .../__pycache__/__init__.cpython-35.pyc | Bin 0 -> 150 bytes server/server/apps/mod/models.py | 13 ++ server/server/apps/mod/tests.py | 3 + server/server/apps/mod/urls.py | 9 ++ server/server/apps/mod/views.py | 24 ++++ server/server/settings.py | 9 ++ server/server/templates/class/approve.html | 4 + server/server/templates/class/index.html | 15 +++ server/server/templates/class/remove.html | 4 + server/server/templates/class/show.html | 59 ++++++++++ server/server/templates/class/undelete.html | 4 + server/server/templates/index.html | 5 + server/server/templates/mod/index.html | 16 +++ server/server/templates/mod/not_mod.html | 10 ++ server/server/urls.py | 7 +- 78 files changed, 593 insertions(+), 14 deletions(-) create mode 100644 server/server/apps/__pycache__/decorators.cpython-35.pyc create mode 100644 server/server/apps/auth/__pycache__/admin.cpython-35.pyc create mode 100644 server/server/apps/auth/__pycache__/apps.cpython-35.pyc create mode 100644 server/server/apps/auth/__pycache__/models.cpython-35.pyc create mode 100644 server/server/apps/auth/migrations/__pycache__/__init__.cpython-35.pyc create mode 100644 server/server/apps/content/__pycache__/admin.cpython-35.pyc create mode 100644 server/server/apps/content/__pycache__/models.cpython-35.pyc create mode 100644 server/server/apps/content/migrations/__pycache__/__init__.cpython-35.pyc create mode 100644 server/server/apps/course/__init__.py create mode 100644 server/server/apps/course/__pycache__/__init__.cpython-35.pyc create mode 100644 server/server/apps/course/__pycache__/admin.cpython-35.pyc create mode 100644 server/server/apps/course/__pycache__/models.cpython-35.pyc create mode 100644 server/server/apps/course/__pycache__/urls.cpython-35.pyc create mode 100644 server/server/apps/course/__pycache__/views.cpython-35.pyc create mode 100644 server/server/apps/course/admin.py create mode 100644 server/server/apps/course/apps.py create mode 100644 server/server/apps/course/migrations/0001_initial.py create mode 100644 server/server/apps/course/migrations/0002_course_url.py create mode 100644 server/server/apps/course/migrations/0003_course_unapproved_files.py create mode 100644 server/server/apps/course/migrations/0004_course_rejected_files.py create mode 100644 server/server/apps/course/migrations/__init__.py create mode 100644 server/server/apps/course/migrations/__pycache__/0001_initial.cpython-35.pyc create mode 100644 server/server/apps/course/migrations/__pycache__/0002_course_url.cpython-35.pyc create mode 100644 server/server/apps/course/migrations/__pycache__/0003_course_unapproved_files.cpython-35.pyc create mode 100644 server/server/apps/course/migrations/__pycache__/0004_course_rejected_files.cpython-35.pyc create mode 100644 server/server/apps/course/migrations/__pycache__/__init__.cpython-35.pyc create mode 100644 server/server/apps/course/models.py create mode 100644 server/server/apps/course/tests.py create mode 100644 server/server/apps/course/urls.py create mode 100644 server/server/apps/course/views.py create mode 100644 server/server/apps/decorators.py create mode 100644 server/server/apps/files/__init__.py create mode 100644 server/server/apps/files/__pycache__/__init__.cpython-35.pyc create mode 100644 server/server/apps/files/__pycache__/admin.cpython-35.pyc create mode 100644 server/server/apps/files/__pycache__/models.cpython-35.pyc create mode 100644 server/server/apps/files/admin.py create mode 100644 server/server/apps/files/apps.py create mode 100644 server/server/apps/files/forms.py create mode 100644 server/server/apps/files/migrations/0001_initial.py create mode 100644 server/server/apps/files/migrations/0002_auto_20200302_0345.py create mode 100644 server/server/apps/files/migrations/__init__.py create mode 100644 server/server/apps/files/migrations/__pycache__/0001_initial.cpython-35.pyc create mode 100644 server/server/apps/files/migrations/__pycache__/0002_auto_20200302_0345.cpython-35.pyc create mode 100644 server/server/apps/files/migrations/__pycache__/__init__.cpython-35.pyc create mode 100644 server/server/apps/files/models.py create mode 100644 server/server/apps/files/tests.py create mode 100644 server/server/apps/files/views.py create mode 100644 server/server/apps/mod/__init__.py create mode 100644 server/server/apps/mod/__pycache__/__init__.cpython-35.pyc create mode 100644 server/server/apps/mod/__pycache__/admin.cpython-35.pyc create mode 100644 server/server/apps/mod/__pycache__/models.cpython-35.pyc create mode 100644 server/server/apps/mod/__pycache__/urls.cpython-35.pyc create mode 100644 server/server/apps/mod/__pycache__/views.cpython-35.pyc create mode 100644 server/server/apps/mod/admin.py create mode 100644 server/server/apps/mod/apps.py create mode 100644 server/server/apps/mod/migrations/0001_initial.py create mode 100644 server/server/apps/mod/migrations/__init__.py create mode 100644 server/server/apps/mod/migrations/__pycache__/0001_initial.cpython-35.pyc create mode 100644 server/server/apps/mod/migrations/__pycache__/__init__.cpython-35.pyc create mode 100644 server/server/apps/mod/models.py create mode 100644 server/server/apps/mod/tests.py create mode 100644 server/server/apps/mod/urls.py create mode 100644 server/server/apps/mod/views.py create mode 100644 server/server/templates/class/approve.html create mode 100644 server/server/templates/class/index.html create mode 100644 server/server/templates/class/remove.html create mode 100644 server/server/templates/class/show.html create mode 100644 server/server/templates/class/undelete.html create mode 100644 server/server/templates/mod/index.html create mode 100644 server/server/templates/mod/not_mod.html diff --git a/server/server/apps/__pycache__/decorators.cpython-35.pyc b/server/server/apps/__pycache__/decorators.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bda97686fb0f760632f4ae05e3f101977b434c99 GIT binary patch literal 676 zcmYjPO^?$s5FO{M72BW!5)vm)9CAsxz-hGt#NJkmAVNqL!pg>Oo7Rbg?ND`9PK$sO zC;kL~h=Z@3_zRpEy9KS~d43*y-gqXto2EBjet-M!Cjs~c*G7Q+37US0z;F@}04;$T z0pj)nhydCUW+CoFU=e%*m_@*1D6`}@MnOhwqIk!+LN?ain5J9k8dLe#uq1{K*B?5}__2|ISdCw471+e#` zI$lEcT>#$*l>3NP2v-2aMD7q@auq;{1-pDUGTWYCrmWGG5OR|*O)Ik4jx^W0k)3ky zu<6sYvlnkppVQan>8sMlb1~?pa@A&`9Vz~P;M&-zQVVU9^~SBPKl7oh4T}7LKaYzI zzbHyGuU9*}8}lFK_n zE}AYs7P78{KFQs!EU+U=nXDI=0)4>EGBYQ`R+{RueMtYFHJ(`dS zQMb@@j$N3tRn;wIu9s4odNA78Y>y7^T6S~aARpl6uYu1nK5iu&1V3@Vh;|=zN~Ymo D0Lqmk literal 0 HcmV?d00001 diff --git a/server/server/apps/auth/__pycache__/admin.cpython-35.pyc b/server/server/apps/auth/__pycache__/admin.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c264ae756f8499d624baacb6b9775359551cad8e GIT binary patch literal 185 zcmWgR<>e|lYZYhDz`*brh~a<<$Z`PUVi6#b0z`}qISdTBj0{nX42&sE48fYrFM%=) znvAzt6H{_C^ZYcKqWDs>67$mY^^)`RN{TX*ia>^}WGG?=QefhjnSOa{l74VWX-cJ2 zVqUg>L1|J>X0m>9YEfBg5sXSKC@9uXEG@~<2OF$cP7HxCiYrIaa zs-IOolg8MYL_RqpRArN|WRq9rGW6Y0h*B0x2p0%ZR9UO39}Dr+O8tA|QFXqSsnQ=% zk8q6+zR#i;l}2&XX4^|yK1QZZb-s#v-+dwbh>W9d5wop13eaa+f-yT_9kUF%JIo$r exv9F9>jC-D?7w5*1<1MKdB5!ieUGKtDgOZ!tzd8f literal 0 HcmV?d00001 diff --git a/server/server/apps/auth/__pycache__/models.cpython-35.pyc b/server/server/apps/auth/__pycache__/models.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0d94c9e18451ff845e63da43072d97595a199776 GIT binary patch literal 182 zcmWgR<>e|lYZYh7z`*brh~a<<$Z`PUVi6#b0z`}qISdTBj0{nX42&sE48fYrFM%=) znvA#Da`RJCbBg^mnQn2WWF_XM=j){;6@d&`$xy@sq`<^4bN%wvB>mu$(v(W4#Jp_% xg3_d%%w+xI)S|M~A{doeP*AL&SXz>y4>44)pz;=n4Uk=$lWNBZG^-eh82}q&ET8}Y literal 0 HcmV?d00001 diff --git a/server/server/apps/auth/__pycache__/views.cpython-35.pyc b/server/server/apps/auth/__pycache__/views.cpython-35.pyc index 1450a8835ccbc161a6f17ba172d2b68a05fb28dc..eff689829cddf8152a30a473b4d5fad0783cd620 100644 GIT binary patch delta 367 zcmey&d6rvQjF*?|&Gx7`e^v&D#|%h-3CMN;;^MlA%0+^l3@Ka;Ees4%ybLLf48fY* z8)p?W@!aBc_VIM}3yJr1xiwjm*@p4f7{+v}@AqxY;V+JI^1Y|n^adFW^n4@^$7M7ERtFp~-x#ZAOwn{Y3~u3dp_1VUwGm ZQks)$#|Sc<2T1TR2`~x(u^6KOGXSuf8`uB< diff --git a/server/server/apps/auth/apps.py b/server/server/apps/auth/apps.py index bdf15e1..c849940 100644 --- a/server/server/apps/auth/apps.py +++ b/server/server/apps/auth/apps.py @@ -2,4 +2,5 @@ from django.apps import AppConfig class AuthConfig(AppConfig): - name = 'auth' + name = 'server.apps.auth' + label = 'authentication' diff --git a/server/server/apps/auth/migrations/__pycache__/__init__.cpython-35.pyc b/server/server/apps/auth/migrations/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1728b078c9758f5df1da5938f37ce4e13ab8a5a7 GIT binary patch literal 151 zcmWgR<>e|lYZb=;1dl-k3@`#24nSPY0whux7=kq!{Z=v*frJsnFBkpt)Fl1jlG2n) zr^LK${ese@oXlkX;?$zD)FK#_SWr-`pIBOwp`V+XUX)mpnV(mzA0MBYmst`YuUAlc Ui^C>2KczG$)edBOF%UBV0AX$>g#Z8m literal 0 HcmV?d00001 diff --git a/server/server/apps/auth/views.py b/server/server/apps/auth/views.py index 3b16747..918b3f0 100644 --- a/server/server/apps/auth/views.py +++ b/server/server/apps/auth/views.py @@ -25,4 +25,11 @@ def login(request): request.session["type"] = user_data["user_type"] return redirect(reverse("index")) except InvalidGrantError: - return redirect(reverse("login")) \ No newline at end of file + return redirect(reverse("login")) + +def logout(request): + if 'user' in request.session.keys(): + del request.session["user"] + if 'type' in request.session.keys(): + del request.session["type"] + return redirect(reverse("index")) \ No newline at end of file diff --git a/server/server/apps/content/__pycache__/admin.cpython-35.pyc b/server/server/apps/content/__pycache__/admin.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..03c79153e8bfe0dc236b370c37407f8f54a1d9f6 GIT binary patch literal 188 zcmWgR<>k70-YU+Xfq~&M5W@izkmUfx#Uel=1&A0Kau^tL85yD&85mQT7=ksKUjk(q zG#PKPCZ^m}#sl@w(r6@d&{$xy@$q`<^4Oa1cHB>mu$(v(W4 z#Jp_%g3_d%%w+xI)S|M~A{doeP*AK7G9opvL?3LnUP0w84x8Nkl+v73J4T>s#X!se E0Ck70-YU+Lfq~&M5W@izkmUfx#Uel=1&A0Kau^tL85yD&85mQT7=ksKUjk(q zG#PKP<>sfP<`nyBGTq`#$x6&i&(}*yDgqg>lA(wNNP&r8R{G_sN&3Mhr74w8iFw)j z1*J(jnaTRasYPX}MKCI{prBYkIX|x?HLpY;Vy<36i#i literal 0 HcmV?d00001 diff --git a/server/server/apps/content/__pycache__/views.cpython-35.pyc b/server/server/apps/content/__pycache__/views.cpython-35.pyc index eac079075ba0118fbabdbe84dc3ea801e2fa84b8..2c62637c7f55df84720828a7f9359672de18c858 100644 GIT binary patch literal 606 zcmYjO&2H2%5dNJ1T~yc;5^um>HfJP+5F8P`RN|0BQ8sqBNgaFfIQ>EGY2jgbC0~2$ zD{x|*f~b}G=GQadI4_TmmOpQ=PY(jP$CHz?{ho!sFi8FcG%yM@0wVeebb>KOld_*e zX3!bN98Lb{=gxR*#1DWcH5Fuqll9_(dt)s^;gpfeu~m`szBfC1NFGzU zw!7YNX7Sl_N$aianCpCENy+k&g+4KOU=SFR$o7_Prj_8;0bjzcw(a;6Rw5HHF;{s-sYx z_1Y^JN>W6w@HzA3%>LV?m4U9Z|WYWI7pJ8Qf$zP{|$6>au6A)gt=W|T1?eVw=!>*MtztmM#|o!!v6b-tTC%_PFJ zzhUlm=HjmoOQ||LKQFnQ1I>~b+ps82^LBH~nd=jH5wBKnxopzvU3?#^7*=AHuw;J# D0mqFh delta 372 zcmYjNO-sW-5S>YOTZxVIAVTrrp?KJf^eiHNgMDSo0ccqDGqq_-e5j|9|Lg}yY zclZxH?m-X!5hpQ+&N6S`ym`ZZe6x4fUh#eJ@N4t@69IldO_`%P9653eN=}5bD zHS6zoyGN(NLH{HSjze8M(empgHv@sTuGL+xO!fiVo4sMM#;I+V2msg7Eta#)eAEq6 idVP;|;dd!)?4B9(SwYnaMBQQO528Ai~=ruzrrn@NBG diff --git a/server/server/apps/content/migrations/__pycache__/__init__.cpython-35.pyc b/server/server/apps/content/migrations/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..16cefe1cd33d138c6f6c62fac469361292981521 GIT binary patch literal 154 zcmWgR<>k70-YSj(2p)q77+?f49Dul(1xTbYFa&Ed`mJOr0tq9CU+((lsY&|5C8a5q zPKkNh`URy)Iho1&#i>PQsYNgKRG|IBsH%@KQ}YID6u3nKd)FnK0Y%qvm`!V Xub}c4hfQvNN@-529ms-WAZ7pnBSI)R literal 0 HcmV?d00001 diff --git a/server/server/apps/content/views.py b/server/server/apps/content/views.py index 58704db..4d76a40 100644 --- a/server/server/apps/content/views.py +++ b/server/server/apps/content/views.py @@ -1,16 +1,14 @@ from django.shortcuts import render from django.conf import settings +from ..decorators import login +from ..mod.models import Moderator + # Create your views here. + +@login def index(request): - if 'type' in request.session and request.session['type'] in settings.ALLOWED_USERS: - return render( - request, - 'index.html', - { - 'user': request.session['user'], - }, - ) - else: - request.session.flush() - return render(request, 'disallow.html') \ No newline at end of file + + is_mod = Moderator.objects.filter(username=request.session['user']).count() > 0 + + return render(request, 'index.html', { 'user': request.session['user'], 'is_mod': is_mod} ) \ No newline at end of file diff --git a/server/server/apps/course/__init__.py b/server/server/apps/course/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/server/apps/course/__pycache__/__init__.cpython-35.pyc b/server/server/apps/course/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e0055bd9c7247e329b5eb9430b76d8e066a89cdd GIT binary patch literal 141 zcmWgR<>mUjD=Llw2p)q77+?f49Dul(1xTbYFa&Ed`mJOr0tq9CUsn3%sY&|5C8a5q zPKkNh`URy)Iho1&#i>PQsYNgKRG9{xL7|vJ~J<~BtBlRpz;=nO>TZlX-=vg K$jo9OW&i*ikRu5I literal 0 HcmV?d00001 diff --git a/server/server/apps/course/__pycache__/admin.cpython-35.pyc b/server/server/apps/course/__pycache__/admin.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..03b15b9779badc84fba8dfaa8ebbe657f427c11d GIT binary patch literal 267 zcmX|5yH3ME5S;VbmK7-|6&)YoCf87;KnOuklg>g&wr>@kIX|>#2c?Ct;g{S}9 zGa{><*_~ajX0O-l)y>Dt>k+`W$0Z`)J$SfVPuiz|1zLeZK8nu5I*Y1Ke8+vMNtIk6L_dK7cGjU2GS{B;z>gZT4WMAw4{($8VB9dm+4US zeYke=D|G6SiVKC({qR2Bcf6zCjK|Th4-a2g9>5>ytN{H}6#Whr$CrQv*b>MHkT2W= z?!ylZ`ydExJb3aU^MMC&ISUV%0yAQI+lmXRbGtpR9y+He`Zp>8mJZo74}=e!z?MPo zCm>nqB0XCHS$WvTy{zAfBlbRw5RyexVNjXKciB@}lc^vA#x+hvB% z1Us9W-lA%h7G_kdV$0N?-irOoL|gVir6{j=HwWwnOs^@6yG9&dfuj4Uz5{Fkk4Kg` z^uRJ(tA)J!2`a%4{=QGYiFJCpYxw>%)=2ASEsH$WLfs2>G_0<5n!Ene_U7jG-t;Ne zJ4NZlR>QvpYd=jTLUQ93 z+zb~tOu4O!E$lZ+n#lz#_p8ck2W3+`pjuV;I5{^>6FQS6?QD)=HAN2Ba!1*dD<4&e zqU}6l@`{|06aOv2$8*?n7MLO5u=2W^^L2aF@WTGT4(`xd0%bYP;A7k9Cwm)iHq+oA Dw=v8a literal 0 HcmV?d00001 diff --git a/server/server/apps/course/__pycache__/urls.cpython-35.pyc b/server/server/apps/course/__pycache__/urls.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9939ef872ca6313990351cec61023dfcadab08a3 GIT binary patch literal 592 zcmZXROHRWu5QfKjHBH(Q7H|SU>ZVyDRaJ#J0GsZzph|12P00&8=_6ZC!2wvX;y&K8 z>J?ZqPKbnB$N6J_GqL^|U-$dY$Ls$2ivWDXztP3@1HR%Nh2kU-10)0j0)%Qnb%-@c zbO?0Z8xR=42v8H44jU7w1+)Wi8d1=$ArhS37CJTT)X;5VuZDIF`z;*Quv^0m1y?2n z4p0wf!^PV&v~|G{v=9^G0m3qh)!kak5)Hl`J5$Z=~e@)yR+;P-NdXoIo@vZ)6kVJ z-Gu2X8=*_VH7t%>N(>ZfqmQ|&i`$B+3*(LwS4j^=y7(XVrC>Z2pTIp8Q1Wx{@7Thh z6(v19hUtr+my0-B`hxK-2Lz14X5P;3UNbL*Y=s78TcKCG1(xW0ACe zmCb?W%wOOPzlY+WD~FViTshG#?WEQlhbmlD)|N(U^+>JmPd!?x*DH4i2akWK1N;ed zKOfs4VNt(h#qpm(43IGBGe|t>d%#HQLF_{kKtFJOAL0TeA@oD+2fzyu7a=J@zl8k| zcoE_DiVHV@BsJjmT+*}>6gF~6 z%SxKSTe+ldC2io#xnvpmCD`meNzMlxCQQI1;eg)Y=?Z4ma?TaV9O+Dd<9}m*q-gxpP zj)pxYaA0l)+xwpJw{E3Von$iUK zpAHgX0%|=vYB;Z}oowGZJ#^kMVWhT_jCZTj#|_#5$TGF?K!NcQDN|I!@?&cEGodyz z{oo+NKokZ%iBef3Wpbj6R6&x*OvO#Vh1SR`G(A@nn%Diq8i0AA zK#3wZL!%&^7tEGzz_Hb1)W@ltd0)3I8%0Y6?zcS0hT9&dyv=T9Lz2JcWva;O#*6sT zI}fDHIAGRCh4Yoi9W@(1Le#*3mnW>a5$dchp(by%$R{;D?=i<_b4(Uzi@b$mbsHFO41 zVY}&F_ateb59#BV4C$jBymKJ^c^e=AbSwLM=NOj{ih;%Q5TtvB)|&D1UXAFNmys9pAQ;%Ganxj7mbvEJ;D1YLSyn zU(x4)m2Z;NX3!VWYG?Zp)zsTq{R^ocaeB+vNGsWJhE`g{rqsW%@iJ5DQ+RPoJ(DJX zvuU!vkS1qYaVaN``i@ZxEYfC=#`AYx@N9Q_J*)@A~_eDrHJq30r-<11X?)O0IVvWhzPs%9?+ vHt|}XB^f%G%xzk?w~W$VoPH9E59k7GZyGCj81T;~?`F^r+so~%?Hm69$X8$8 literal 0 HcmV?d00001 diff --git a/server/server/apps/course/admin.py b/server/server/apps/course/admin.py new file mode 100644 index 0000000..a8d12bf --- /dev/null +++ b/server/server/apps/course/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +from .models import Course + +# Register your models here. +admin.site.register(Course) \ No newline at end of file diff --git a/server/server/apps/course/apps.py b/server/server/apps/course/apps.py new file mode 100644 index 0000000..ff833cd --- /dev/null +++ b/server/server/apps/course/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ClassConfig(AppConfig): + name = 'course' diff --git a/server/server/apps/course/migrations/0001_initial.py b/server/server/apps/course/migrations/0001_initial.py new file mode 100644 index 0000000..aace0dd --- /dev/null +++ b/server/server/apps/course/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.10 on 2020-03-02 04:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('files', '0002_auto_20200302_0345'), + ] + + operations = [ + migrations.CreateModel( + name='Course', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=100, unique=True)), + ('files', models.ManyToManyField(blank=True, related_name='classes', to='files.File')), + ], + ), + ] diff --git a/server/server/apps/course/migrations/0002_course_url.py b/server/server/apps/course/migrations/0002_course_url.py new file mode 100644 index 0000000..d8911f6 --- /dev/null +++ b/server/server/apps/course/migrations/0002_course_url.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.10 on 2020-03-02 04:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('course', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='course', + name='url', + field=models.CharField(default='-', max_length=20, unique=True), + preserve_default=False, + ), + ] diff --git a/server/server/apps/course/migrations/0003_course_unapproved_files.py b/server/server/apps/course/migrations/0003_course_unapproved_files.py new file mode 100644 index 0000000..f410f26 --- /dev/null +++ b/server/server/apps/course/migrations/0003_course_unapproved_files.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.10 on 2020-03-22 17:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('files', '0002_auto_20200302_0345'), + ('course', '0002_course_url'), + ] + + operations = [ + migrations.AddField( + model_name='course', + name='unapproved_files', + field=models.ManyToManyField(blank=True, related_name='classes_unap', to='files.File'), + ), + ] diff --git a/server/server/apps/course/migrations/0004_course_rejected_files.py b/server/server/apps/course/migrations/0004_course_rejected_files.py new file mode 100644 index 0000000..cc059ef --- /dev/null +++ b/server/server/apps/course/migrations/0004_course_rejected_files.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.10 on 2020-03-23 04:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('files', '0002_auto_20200302_0345'), + ('course', '0003_course_unapproved_files'), + ] + + operations = [ + migrations.AddField( + model_name='course', + name='rejected_files', + field=models.ManyToManyField(blank=True, related_name='classes_reject', to='files.File'), + ), + ] diff --git a/server/server/apps/course/migrations/__init__.py b/server/server/apps/course/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/server/apps/course/migrations/__pycache__/0001_initial.cpython-35.pyc b/server/server/apps/course/migrations/__pycache__/0001_initial.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..970d1bf6b9a786d4140ec875679e2ab5117a7025 GIT binary patch literal 818 zcmZ`%&2AGh5T5mJHrdUl<+mIvfy6DB>^6ZLLWM{{LP{^~DMDCI?4(Zjul6pGT#LB# z7`&3Nocao!7;jRQ3zj_|dptAWH=d(jFMRpq(`QZqe#1Y*L;Vz&9--hk9Y_H(2WAdr z1ZD)B59q{Q_>M*wgad0AZd{nTz&$wcw{Fo9`ox5pTq#z`BG<;x3NBK;u%^3lfXXQ@ z{S$=%n*j4+0!(RxJ%JS}9*7pKeH)v%fTPj|(S~&gI8Jm4fQN7cWQmUW7)^N71s(zK z*#~-Lx}}mCQyY3EHYU(QNtVj3m|%U_H=2rk zRbAd9aWH_`It5<~@>)%X*&5MU3V7 zBGlc+%2LORrlj$GGsXA^Cv*>XP;QimQGHz6c2q=sH}C?-C&$jQ)7Z}Xo(cGx<*Q=A e=MABTLu0(hw9{T-4AXhDtI=CaRoe<2xqksDN7eNJ literal 0 HcmV?d00001 diff --git a/server/server/apps/course/migrations/__pycache__/0002_course_url.cpython-35.pyc b/server/server/apps/course/migrations/__pycache__/0002_course_url.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f2bfea7acffb280f6042bf075023af4f77a71b59 GIT binary patch literal 666 zcmY*XO>fjN5S_%?bQ7{rBviqLdk!=UToGzPDyQ~R4rqn2ygSov7U!dOLTRt%!cXDG z@9~vW|3XiUv%4xdp2n4n+l7a=W5U4!oBhO& zz!NYZ6W}f^nU8Bnuo`(17QwZV;}|H0)ea!fF<=6i0zLrD;06Rv03UJ?`R$B8VmXgp za=g{y;ziRNOD>yEr!Qq$mtCne3-#h;ttxWS;6-n=8=aM;(d{6esa|(?!3$ogzDrH@ zvOB+h!m3@|*X2b|AKh+i$ddU+aHFM6fD z0-qtZR3p`klB@|m+xQUi$cr+;>}<5?ny^$)vttK?eV1@TII zL!5X8PRy za>4n4E}#eBDChxqVC%uH2P+TIhs$*Gn+`(i>bR~pvgoU}Q97twPHRm2=FOvs2P>_VLJh&P2~f?M}Q&l0JdaAfHB}>zyxp#_ylgjqrD-lA>fR# zJk!zn0fe4>t^`;5d7kGBRt$a17WpF2m*nNkSFd$Ywu4k$&uqfzut5qM#DHf_QFHBE zeKa&h*U9#pBO9wyaV}6#)}m;>TZA-FWsA+uc=(=lTNbr78Fgt4zfAxwYcA@6vDyeTWLq)UYB@Ezir0WCe_ z&d!Twchwqgzv{T{_}%aO0rCaqSoLR>-SBmG*$=pTPqSv-uohLBDK4+MJiLe1>;nqt-Ain)5MKRQSVB$$MSvMzK#irbLj{uw6roC*gc-&KH)rkQv5_U^P72svmo&^Hh_%Cbj$V zICa_&H@$lxDbM_9H}k*eIj%R#KFWZ%j+w=t=Y)Rf1pIZD^TanHu4K8W#yIbK=#Y2D XJAA$Lgfp1oi+&o%wn1&1KJgXpi-}_Zg2x~N1{i@12OutH0TL+;48fX=ek&P@K*9*(mz#chYLb3%Noh)@ zQ(|7WenDwcPG+)xacWUnY7vY|EGQ_}PtGqbDo)kU%}g&!EXmBzE7p&X&&", views.show, name="show"), + path("/approve/", views.approve, name="approve"), + path("/remove/", views.remove, name="remove"), + path("/undelete/", views.undelete, name="undelete"), +] \ No newline at end of file diff --git a/server/server/apps/course/views.py b/server/server/apps/course/views.py new file mode 100644 index 0000000..971b9c2 --- /dev/null +++ b/server/server/apps/course/views.py @@ -0,0 +1,111 @@ +from django.shortcuts import render, get_object_or_404 +from django.core.exceptions import PermissionDenied + +from django.http import Http404 + +from .models import Course +from ..mod.models import Moderator +from ..files.models import File + +from ..decorators import login + +# Create your views here. + +@login +def index(request): + courses = Course.objects.all() + + return render(request, 'class/index.html', {'classes': courses}) + +@login +def show(request, course_url): + course = get_object_or_404(Course, url=course_url) + + is_mod = False + + try: + mod = Moderator.objects.get(username=request.session['user']) + except Moderator.DoesNotExist: + is_mod = False + + if mod.admin: + is_mod = True + + elif course in mod.classes.all(): + is_mod = True + + return render(request, 'class/show.html', {'course': course, 'is_mod': is_mod}) + +@login +def approve(request, course_url, doc_id): + course = get_object_or_404(Course, url=course_url) + try: + mod = Moderator.objects.get(username=request.session['user']) + except Moderator.DoesNotExist: + raise PermissionDenied + + if mod.admin or (course in mod.classes.all()): + try: + doc = course.unapproved_files.get(id=doc_id) + except File.DoesNotExist: + try: + doc = course.files.get(id=doc_id) + except File.DoesNotExist: + raise Http404("Error: Document Not Related to this Course") + raise Http404("Error: Document Already Approved") + course.unapproved_files.remove(doc) + course.files.add(doc) + + return render(request, 'class/approve.html', {'doc': doc, 'course': course}) + else: + raise PermissionDenied + +@login +def remove(request, course_url, doc_id): + course = get_object_or_404(Course, url=course_url) + try: + mod = Moderator.objects.get(username=request.session['user']) + except Moderator.DoesNotExist: + raise PermissionDenied + + if mod.admin or (course in mod.classes.all()): + try: + doc = course.files.get(id=doc_id) + except File.DoesNotExist: + try: + doc = course.unapproved_files.get(id=doc_id) + except File.DoesNotExist: + raise Http404("Error: Document Not Related to this Course") + + course.unapproved_files.remove(doc) + course.rejected_files.add(doc) + + return render(request, 'class/remove.html', {'doc': doc, 'course': course}) + + course.files.remove(doc) + course.rejected_files.add(doc) + + return render(request, 'class/remove.html', {'doc': doc, 'course': course}) + else: + raise PermissionDenied + +@login +def undelete(request, course_url, doc_id): + course = get_object_or_404(Course, url=course_url) + try: + mod = Moderator.objects.get(username=request.session['user']) + except Moderator.DoesNotExist: + raise PermissionDenied + + if mod.admin or (course in mod.classes.all()): + try: + doc = course.rejected_files.get(id=doc_id) + except File.DoesNotExist: + raise Http404("Error: Document Not Related to this Course") + + course.rejected_files.remove(doc) + course.files.add(doc) + + return render(request, 'class/undelete.html', {'doc': doc, 'course': course}) + else: + raise PermissionDenied \ No newline at end of file diff --git a/server/server/apps/decorators.py b/server/server/apps/decorators.py new file mode 100644 index 0000000..0b86373 --- /dev/null +++ b/server/server/apps/decorators.py @@ -0,0 +1,15 @@ +from django.shortcuts import render +from django.conf import settings + + +def login(function): + def wrap(request, *args, **kwargs): + if 'type' in request.session and request.session['type'] in settings.ALLOWED_USERS: + return function(request, *args, **kwargs) + else: + request.session.flush() + return render(request, 'disallow.html') + + wrap.__doc__ = function.__doc__ + wrap.__name__ = function.__name__ + return wrap \ No newline at end of file diff --git a/server/server/apps/files/__init__.py b/server/server/apps/files/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/server/apps/files/__pycache__/__init__.cpython-35.pyc b/server/server/apps/files/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2c403f15a3caae87c709ff989124ee6d8ae39944 GIT binary patch literal 141 zcmWgR<>m7Ah>2qWg2x~N1{i@12OutH0TL+;48fX=ek&P@K*9*(mz92bYLb3%Noh)@ zQ(|7WenDwcPG+)xacWUnY7vY|EGQ_}Ps_|nE!K~Z&&G$h@e!=_z2f1L=eIAon5lfhh*7 z0F)0~1~)PQ8Nxf3gg`(DTL+{O$Oxu!YllBV%$iWhJS%o=p9R;MR&#<5i+~ZD9iUS{ z%qS#v+{lU|rg6|5QQZ~&)OeYk#Ow_Zyl-<}h+J{rbU4pTS!;^BoIlk<|01VG30W3; z!xx#-(tdzBMlR>R&yyE5OQ!2uZpNZ`OsaaOvw32bc~<6dh^n&50u|WAbu+9shDH~W zZVz48bNM80r6+PFie)*Rm&Mv-Ged9_p){qf2`FhBwan~VnWl3`*RCyB|F3Hwb=~ue QeP5R}DNB@nukW9+9|>M;k^lez literal 0 HcmV?d00001 diff --git a/server/server/apps/files/__pycache__/models.cpython-35.pyc b/server/server/apps/files/__pycache__/models.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d48d285e871a7ab10f6e2b11cbec0262d3f35479 GIT binary patch literal 1082 zcmZuwJ#*7Q5Z#kxSyCKG!b~Rl0WMtF=5vOEVFH;6G;tFeTyP^>XGe}?D<=u!B(6fk zPvI|JOXa^n18*gVNx{jx+TAVvR zStnTIIO+)Fri(}=IihBsl+$>!MA#_HIC_b|%L_dz;#7@+yBhpUyXBx!X>= z?Wo)S*lnM-&y47;1x{N3!RWZgoh)=37P^6&cG%f)#+iqyGL1Y-;-X_2FP`T`I3FwH zP2xoH!1pA}`ad>_s)`dK+j;&DG$`m56SuQ1E3pU2rVEm0D#bV5S^WZmIB{yG~WhI;-1|6XT6woD3u98VbZS5YTY?@M{d8B-T zWW&;Ri$V1^6NApS@uXy7q%?t)pt(#qZb^ArhDkl6nPKCD{Rv;Ru{E<~V{ttrj-qd%0%T!l5c0~2q GE&DI*EBGb= literal 0 HcmV?d00001 diff --git a/server/server/apps/files/admin.py b/server/server/apps/files/admin.py new file mode 100644 index 0000000..c8f8790 --- /dev/null +++ b/server/server/apps/files/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin + +from .models import File + +# Register your models here. +@admin.register(File) +class FileAdmin(admin.ModelAdmin): + readonly_fields = ('id',) \ No newline at end of file diff --git a/server/server/apps/files/apps.py b/server/server/apps/files/apps.py new file mode 100644 index 0000000..c86f272 --- /dev/null +++ b/server/server/apps/files/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class FilesConfig(AppConfig): + name = 'files' diff --git a/server/server/apps/files/forms.py b/server/server/apps/files/forms.py new file mode 100644 index 0000000..d3199e6 --- /dev/null +++ b/server/server/apps/files/forms.py @@ -0,0 +1,8 @@ +from django import forms + +from .models import File + +class UploadFileForm(forms.ModelForm): + class Meta: + model = File + fields = ["name", "payload"] \ No newline at end of file diff --git a/server/server/apps/files/migrations/0001_initial.py b/server/server/apps/files/migrations/0001_initial.py new file mode 100644 index 0000000..1d73c35 --- /dev/null +++ b/server/server/apps/files/migrations/0001_initial.py @@ -0,0 +1,21 @@ +# Generated by Django 2.2.10 on 2020-03-02 01:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='File', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=100, unique=True)), + ], + ), + ] diff --git a/server/server/apps/files/migrations/0002_auto_20200302_0345.py b/server/server/apps/files/migrations/0002_auto_20200302_0345.py new file mode 100644 index 0000000..6f19bdd --- /dev/null +++ b/server/server/apps/files/migrations/0002_auto_20200302_0345.py @@ -0,0 +1,24 @@ +# Generated by Django 2.2.10 on 2020-03-02 03:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('files', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='file', + name='payload', + field=models.FileField(blank=True, upload_to=''), + ), + migrations.AddField( + model_name='file', + name='uploader', + field=models.CharField(default='----', max_length=100), + preserve_default=False, + ), + ] diff --git a/server/server/apps/files/migrations/__init__.py b/server/server/apps/files/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/server/apps/files/migrations/__pycache__/0001_initial.cpython-35.pyc b/server/server/apps/files/migrations/__pycache__/0001_initial.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e0fc00903c0513b12eaa34d55233e12cc0582153 GIT binary patch literal 648 zcmYjO&5qMB5S}<`+WhpoAn^pfY>K!dw6IbUhuzC^st}f2PqXeiKWisIxh^lkBk(Rf zfv=qQ6*w_YS}m4m@@YQ%n{S-6`8@r(`}FyD0PqL?TM^+43j2zZq#b|;r~+6AP%&6D z2;NHuGK3#QhJXR=LwE>b9fFMDW-)oBi?CoWtyF15r<&TjxN0P7yYVkW{4eQ;;)w0JfuBY@ia5v{R6oKQK}y^PnVI zs^{c!?vksMxsNWYMTIU}DUB}PDb&(BrliYSqbgwz{0N~DzGVzUTtjq59 zkt~CY`&!-ic)iHnjB_u?xl1{xseA2l&iQ>W^pTmWT6HAma)~Y066>u(YnYeHE)9wf zul#$N&{vYTeb=nKEtg#03NymAY4P~FzrZ}BgG2iJq456;hm`OiniZqwJpf~ z7c{4jXj@zCXkJ@9{iI^KT)yN-Yv=93L?jwh*ql<%Vire95VIG-z+5jPm&m=S%jR5e c2J?g8fqXJFqUWUGX0ONhc;m;ie%iC}AELse3IG5A literal 0 HcmV?d00001 diff --git a/server/server/apps/files/migrations/__pycache__/0002_auto_20200302_0345.cpython-35.pyc b/server/server/apps/files/migrations/__pycache__/0002_auto_20200302_0345.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3925915c40f766abf60168838dc6db973c046c6c GIT binary patch literal 764 zcmZ8f%Z}496uo&gZ9)nI3?mls0a-8!E$k2)Kq?Xvvzb{{BP_SqlSy$NI0?{h5Gp^z zFL}#qet{L&Nvi>z*giKtzV{qEN8@pD@%`e%I~(8^{MB5-C)DdH4M?vA5+Ju=Zb5Ft z+y?6{+JFxHphX9S1uF-(4$K`u7tW%=HEo2*)dejF(=^=_s-pXd^% zXTf&F*=b~NdPSRm6h(m^u}%+TI$(_SwNelc8T-_7Y1EkrMI{Op#WEAMqU$C#uMlTO zta41~&&W*|YyZs^S3L~MO6;!hC#Xk6?1tax@fWd(&zct3ugPd!wF{Xo<4&{MPrRz? zxI4x8<}ZlpJSU8|P01$7BuSm7Ah>2qWg2x~N1{i@12OutH0TL+;48fX=ek&P@K*9*(m#cnxYLb3%Noh)@ zQ(|7WenDwcPG+)xacWUnY7vY|EGQ_}Ps_|nE!NM?OfO0-$;{6y){l?R%*!l^kJl@x Uyv1RYo1apelWGStz8HuZ06VoNT>t<8 literal 0 HcmV?d00001 diff --git a/server/server/apps/files/models.py b/server/server/apps/files/models.py new file mode 100644 index 0000000..6e1350d --- /dev/null +++ b/server/server/apps/files/models.py @@ -0,0 +1,20 @@ +from django.db import models +from django.utils.text import slugify +from uuid import uuid4 +from time import strftime + +# Create your models here. +def gen_filename(instance, filename): + return "upload_{0}_{1}_{2}.{3}".format(strftime('%Y-%m-%d-%H-%M%S'), uuid4(), slugify(instance.name), filename.split('.')[-1]) + +class File(models.Model): + id = models.AutoField(primary_key=True) + name = models.CharField(max_length=100, unique=True) + + + uploader = models.CharField(max_length=100) + + payload = models.FileField(blank=True, upload_to=gen_filename) + + def __str__(self): + return self.name diff --git a/server/server/apps/files/tests.py b/server/server/apps/files/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/server/server/apps/files/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/server/server/apps/files/views.py b/server/server/apps/files/views.py new file mode 100644 index 0000000..4565d78 --- /dev/null +++ b/server/server/apps/files/views.py @@ -0,0 +1,18 @@ +from django.shortcuts import render +from django.http import HttpResponseRedirect + +from .forms import UploadFileForm +from .models import File + +# Create your views here. +def upload_file(request): + if 'type' in request.session and request.session['type'] in settings.ALLOWED_USERS: + if request.method == 'POST': + form = UploadFileForm(request.POST, request.FILES) + if form.is_valid(): + inst = File(name=request.POST['title'] , payload=request.FILES['file']) + inst.save() + return HttpResponseRedirect('/upload/success') + else: + form = UploadFileForm() + return render(request, 'upload.html', {'form':form}) \ No newline at end of file diff --git a/server/server/apps/mod/__init__.py b/server/server/apps/mod/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/server/apps/mod/__pycache__/__init__.cpython-35.pyc b/server/server/apps/mod/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c16df92ffac7ef3cd0f45382cc24ac282e250c58 GIT binary patch literal 139 zcmWgR<>h*?D=Llw2p)q77+?f49Dul(1xTbYFa&Ed`mJOr0tq9CUl#i1sY&|5C8a5q zPKkNh`URy)Iho1&#i>PQsYNgKQ})`KR!M)FS8^*Uaz3?7KaT`q%iEWb+|T7rq?4oD M^pa0kR@qAa0vBLHEdT%j literal 0 HcmV?d00001 diff --git a/server/server/apps/mod/__pycache__/models.cpython-35.pyc b/server/server/apps/mod/__pycache__/models.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9f57cbb0358da8542e874bb655c7e54e13feab6e GIT binary patch literal 751 zcmYjNy>8nu5I*Y1vScYvGZY2-1RiQ_or)rjfnWh( zA?$-7u=U{4hr$OQz{Mhb!6&dFW>U9YNL||B*E7N37)@(*0xTV}7aj;7wt;Pf+>bzt z&><7s0ak*kayk^o0A29CkZ6%(((AO)UTr3D5DsBUiJbCji6*D5pH zsj6mbptoYUG)c{VP$`=0?&jqX<(Wy}RCm2F5f@jim)+?@R<^y;V!3jcNtKYS6Pz}z z7Da&bY7=fGYi>(is5|zywnEbpx}N}BKp|v}E1LFNDEk=WKnr>G3@XE-KOgh&Vv}EV zJs(bxF5mSVS(Q0f-wXA6vE5GR*wh*>dbt}+M5*o+rKxS_p#$>p=KsLUf7$gSGgInR zQ)&`Qk)W3XO(@IEgyo#H6b;FeVRWqATPuf-r){GS)<8{@T z`8jKb%hvi4k4nk37Fx~mjT>>#9azjq7ozC|T}qC~J96Z`_Z+@n1SaNN)?Bwsz8PhO ab}H%8dsKFL%JP}%r*WvycKdD>hrwSS_qMSB literal 0 HcmV?d00001 diff --git a/server/server/apps/mod/__pycache__/urls.cpython-35.pyc b/server/server/apps/mod/__pycache__/urls.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c9f662266cd7973f8cdbacbae41ea80e6800f266 GIT binary patch literal 311 zcmX|5yG{c!5F9`5av_P7ihsB!ZYU8#NVGKRt^oP4l?V5*?7Kv1;cNHs;b;XaL0qDeunZ=H z71(DmIm`qfoNZ`><^t<-dL}EBEJ~+`?V0_N?69-P5JlUYh$uVV+DaN7wom0G&dgqS zn|?L=CU{N@K2IPCVxgUTN%A;N^19dF#2G2ceXza@pYZdfPVjT1j<#0oVKk=)-MuL{ n*3Ir!1?vyiUm7_EMUSX-Z{<$0xFt3=_AWge((NT*@?87^kuyz% literal 0 HcmV?d00001 diff --git a/server/server/apps/mod/__pycache__/views.cpython-35.pyc b/server/server/apps/mod/__pycache__/views.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ed20b06de344067b6225c9bd086db27475462cd8 GIT binary patch literal 822 zcmaJfjN5Pf!blkCFMAVDP#NENqSb`ffC2vro0?4?LRgs8Hy)n=Q-i|zDF+tczt zIP*978NPDb6L(IGvjuv>itU;4%gpohY>!66pZnz}$AKTXH3G8tX_}9;2>KW*pk~Mz zYL1M92@VmU3Q+fu^~mo*^ilOuhseT>AEJs-$H-zZ8AC)6F}?sRN;H5N;4mGosRB~& zLM>s{lSOqxz z&@jATQo0cH2rJ;4K;*{IOV~kI>2I9Fe8qp$-5ipHw`-A}OOBFv71MC);?_vrw<@eWj$C zD*O7PG*)|c^&Jln@~U$ET-0TwBMPK}i?saQN@HC>r8?9%=m&K6Yj1KcXOlzQip!UI zb2?eHv#Km6MD$GRKU=<7n29HOR?2fTUR=6?$j!-2<(m3|UdyKf57-V%*b~0R25gIm z>@nBd6rZL;mxy`Z9ILT8QQ8)*H5XWCPHX-^#nj}mQDrShYa4J6kx{0}b7 z@RxMu)W5)qmE25=Mq015`|a+x-tEySdHdtj=bt{nA9%1r()Z}-cO*D%4Y}$j0V9;H2~c`>+@Qr%jL;cmg-zUl4HUO!Sfh9|3=4 z9qvpU&XfS(?EF3J|JXeafj@Dfo&tXcd<*zCp#pN4hZb(jpn%Vb+)EQ5uUVa$XjZjK zqe&-|$(vl1q7h7*uw(_2A2BBSl`_$VK*_c71vkT5iGrzReuYaDYgB{~D?BuVmM#vN z6zp3rv79%Tx0}=&6SbwdZqf7@FGOkj94}Za8`GajrZsBQn@Uz*nN*=<4f5QD3903j zv#D02uFTy7SMABzU)>eH`mgZu$P99a&2y9FIpJH0q^Eg)-7;yT(yhPdnR2YL_z^Lx8rSj&U!KqP0SapoL9Si>ex9#&Ujx^r@f{qX7Iji*ayp7+jeXR{{Z`S B>mmRE literal 0 HcmV?d00001 diff --git a/server/server/apps/mod/migrations/__pycache__/__init__.cpython-35.pyc b/server/server/apps/mod/migrations/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c1a0c2fbd2dcbd9e107a41fd415320152030d79c GIT binary patch literal 150 zcmWgR<>fMJi-}_Zg2x~N1{i@12OutH0TL+;48fX=ek&P@K*9*(m$QC(YLb3%Noh)@ zQ(|7WenDwcPG+)xacWUnY7vY|EGQ_}&&^NK&&^CPN-W9D&nwoCkI&4@EQycTE2zB1 RVFQ#b%}KQb8D0#;3;_C6C941c literal 0 HcmV?d00001 diff --git a/server/server/apps/mod/models.py b/server/server/apps/mod/models.py new file mode 100644 index 0000000..0d09bb7 --- /dev/null +++ b/server/server/apps/mod/models.py @@ -0,0 +1,13 @@ +from django.db import models + +# Create your models here. + +class Moderator(models.Model): + id = models.AutoField(primary_key=True) + username = models.CharField(max_length=16, unique=True) + admin = models.BooleanField(default=False) + + classes = models.ManyToManyField("course.Course", related_name="mods", blank=True) + + def __str__(self): + return self.username \ No newline at end of file diff --git a/server/server/apps/mod/tests.py b/server/server/apps/mod/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/server/server/apps/mod/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/server/server/apps/mod/urls.py b/server/server/apps/mod/urls.py new file mode 100644 index 0000000..3a8844c --- /dev/null +++ b/server/server/apps/mod/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from . import views + +app_name = "mod" + +urlpatterns = [ + path("", views.dashboard, name="dash"), +] \ No newline at end of file diff --git a/server/server/apps/mod/views.py b/server/server/apps/mod/views.py new file mode 100644 index 0000000..97a23a0 --- /dev/null +++ b/server/server/apps/mod/views.py @@ -0,0 +1,24 @@ +from django.shortcuts import render, get_object_or_404 + +from .models import Moderator +from ..course.models import Course + +from ..decorators import login +# Create your views here. + +@login +def dashboard(request): + try: + mod = Moderator.objects.get(username=request.session['user']) + except Moderator.DoesNotExist: + return render(request, 'mod/not_mod.html', {'user': request.session['user']}) + + classes = mod.classes.all() + if mod.admin: + classes = Course.objects.all() + + if not classes: + return render(request, 'mod/not_mod.html', {'user': request.session['user']}) + + return render(request, 'mod/index.html', {'user': request.session['user'], 'classes': classes}) + diff --git a/server/server/settings.py b/server/server/settings.py index f626e66..ec2f355 100644 --- a/server/server/settings.py +++ b/server/server/settings.py @@ -38,6 +38,11 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'server.apps.files', + 'server.apps.mod', + 'server.apps.content', + 'server.apps.auth.apps.AuthConfig', + 'server.apps.course', ] MIDDLEWARE = [ @@ -84,6 +89,10 @@ DATABASES = { } +MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') +STATIC_ROOT = os.path.join(BASE_DIR, 'static/') +MEDIA_URL = '/media/' + # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators diff --git a/server/server/templates/class/approve.html b/server/server/templates/class/approve.html new file mode 100644 index 0000000..e74a9eb --- /dev/null +++ b/server/server/templates/class/approve.html @@ -0,0 +1,4 @@ +{% extends 'base.html' %} +{% block body %} + Success. You have Approved {{ doc.name }} by {{ doc.uploader }} Download for the Course {{ course.name }}. +{% endblock %} \ No newline at end of file diff --git a/server/server/templates/class/index.html b/server/server/templates/class/index.html new file mode 100644 index 0000000..3198f4b --- /dev/null +++ b/server/server/templates/class/index.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% block body %} +
+

Classes

+
+
+ {% for class in classes %} +
+ {{class.name}} +

{{ class.files.all|length }} Document

+
+ {% endfor %} +
+ +{% endblock %} \ No newline at end of file diff --git a/server/server/templates/class/remove.html b/server/server/templates/class/remove.html new file mode 100644 index 0000000..fac2279 --- /dev/null +++ b/server/server/templates/class/remove.html @@ -0,0 +1,4 @@ +{% extends 'base.html' %} +{% block body %} + Success. You have Removed {{ doc.name }} by {{ doc.uploader }} Download for the Course {{ course.name }}. +{% endblock %} \ No newline at end of file diff --git a/server/server/templates/class/show.html b/server/server/templates/class/show.html new file mode 100644 index 0000000..df8aed2 --- /dev/null +++ b/server/server/templates/class/show.html @@ -0,0 +1,59 @@ +{% extends 'base.html' %} +{% block head %} + + +{% endblock %} +{% block body %} +
+

{{ course.name }}

+
+
+ {% if is_mod %} +

You have moderator permissions on this course, which means you can approve of reject uploaded files.

+ {% endif %} + {% for doc in course.files.all %} +
+

{{ doc.name }}

+ Download +

Uploaded By {{ doc.uploader }}

+ {% if is_mod %} + REMOVE + {% endif %} +
+ {% endfor %} + + {% if is_mod %} + {% for doc in course.unapproved_files.all %} +
+

UNAPPROVED

+

{{ doc.name }}

+ Download +

Uploaded By {{ doc.uploader }}

+ APPROVE + REMOVE +
+ {% endfor %} + {% for doc in course.rejected_files.all %} +
+

UNAPPROVED

+

{{ doc.name }}

+ Download +

Uploaded By {{ doc.uploader }}

+ UNDELETE +
+ {% endfor %} + {% endif %} +
+ +{% endblock %} \ No newline at end of file diff --git a/server/server/templates/class/undelete.html b/server/server/templates/class/undelete.html new file mode 100644 index 0000000..ab3749e --- /dev/null +++ b/server/server/templates/class/undelete.html @@ -0,0 +1,4 @@ +{% extends 'base.html' %} +{% block body %} + Success. You have Restored {{ doc.name }} by {{ doc.uploader }} Download for the Course {{ course.name }}. +{% endblock %} \ No newline at end of file diff --git a/server/server/templates/index.html b/server/server/templates/index.html index 533ac1b..8253a38 100644 --- a/server/server/templates/index.html +++ b/server/server/templates/index.html @@ -2,4 +2,9 @@ {% block body %}

Study Bank

Welcome, {{ user }}

+ {% if is_mod %} + Moderator Dashboard + {% endif %} + + View Courses {% endblock %} \ No newline at end of file diff --git a/server/server/templates/mod/index.html b/server/server/templates/mod/index.html new file mode 100644 index 0000000..740bfa5 --- /dev/null +++ b/server/server/templates/mod/index.html @@ -0,0 +1,16 @@ +{% extends 'base.html' %} +{% block body %} +
+

Classes Moderated by {{ user }}

+
+
+ + {% for class in classes %} +
+ {{class.name}} +

{{ class.files.all|length }} Document

+
+ {% endfor %} +
+ +{% endblock %} \ No newline at end of file diff --git a/server/server/templates/mod/not_mod.html b/server/server/templates/mod/not_mod.html new file mode 100644 index 0000000..3a38baf --- /dev/null +++ b/server/server/templates/mod/not_mod.html @@ -0,0 +1,10 @@ +{% extends 'base.html' %} +{% block body %} +
+

Access Denied

+
+
+

Sorry, {{ user }}, but you do not have moderator permissions over any sites.

+
+ +{% endblock %} \ No newline at end of file diff --git a/server/server/urls.py b/server/server/urls.py index f6d32b2..5ad473e 100644 --- a/server/server/urls.py +++ b/server/server/urls.py @@ -14,13 +14,18 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include from .apps.auth import views as auth_views from .apps.content import views as content_views +from .apps.course import views as course_views +from .apps.mod import views as mod_views urlpatterns = [ path('admin/', admin.site.urls), path('login/', auth_views.login, name="login"), + path('logout/', auth_views.logout, name="logout"), + path('courses/', include("server.apps.course.urls", namespace="courses")), + path('mod/', include("server.apps.mod.urls", namespace="mod")), path('', content_views.index, name="index"), ]