# HG changeset patch # User Ilyas # Date 2013-03-23 23:38:14 # Node ID f67fe28f5c7591e870d9c0da72e3e13746557d5a # Parent b62ef70fbdc5a568210fe9da911d77e576acd98b Added admin loing possibility. Now it is abailable under {BASE_URL}/boards/login Added base css and html resources diff --git a/boards/__init__.pyc b/boards/__init__.pyc index fb27594e598397f8c24513463d994c5fd2f87861..5bb8ea45bc6bc1b07d9c460191a3622d96c3e8aa GIT binary patch literal 143 zc${PY%*)kO@g^Xd0SXv_*a3)(S%5?e14FO|NW@PAB!@;6TL20D6#er2qHO(w%94!y zJpGic#Ju!;{k+tq{KTRZI1MI?_2c6+^D;}~!0yGHY0>%?C z0zUAVm;ZP*b1mRrmSkeTX-TA0t_XVVte1i*S8qegnb|`>p4DIre@C z%`W&H?Y8Al}{S@n{fUng_L&WSH-JTGdj@drlyOi%y- diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -50,6 +50,9 @@ class PostManager(models.Manager): return len(posts) == 0 + def is_admin(self, user, passw): + return Admins.objects.filter(name = user, password = passw) is not None + class Tag(models.Model): """ @@ -75,4 +78,19 @@ class Post(models.Model): tags = models.ManyToManyField(Tag) def __unicode__(self): - return self.title + ' (' + self.text + ')' \ No newline at end of file + return self.title + ' (' + self.text + ')' + + +class Admins(models.Model): + """ + Model for admin users + """ + + objects = PostManager() + + name = models.CharField(max_length=100) + password = models.CharField(max_length=100) + + def __unicode__(self): + return self.name + '/' + '*' * len(self.password) + diff --git a/boards/models.pyc b/boards/models.pyc index ea9b230b06d658500475ff1e4f72cab3747d3980..cf2d705eed7fdef3eff8151ebb4292f42477446d GIT binary patch literal 4281 zc$}?QYi}Dx6rCMEVmr>GZqhWg&;^NNT1diMyeizLpa|6slT;Ov=xXDgIGe6_jdwy* zlzd7hKJpj%kNg0*=Z<%6H$?*BB%aKB?m73|nd`!zbG0X5wtwh|;ZK1+-_R%hgNlIu z91#i8bHtt_9JHl~r05mIUV+;E*U`D(U;#`Oy z_o^bO@IZ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`GdW(LkRu&K!n2t+MZi)fN><}Km$&Tuf{Q_c zMD^bEg~`5pGN#7bzf|Mx%%Ev|8=l<79JJn8G}yqyS?9 zV-7&KXfwc$Ko2idz=E&!kYxMT3_bqg$*~}JRk4#LA6pNtf7U^RwE8fNz3FDyg`V)Crf5acCUDLh}0dcy&@?F= zefnCRr04!F_A=+}%)fDI>C>{XEWa8%`Fxq>zOh2aB-CDwgW>Fegm3feIM29sW(<|! z8Wk4Vz6K*}Fi&m-Lw-Ow*4RXKXDbp#NED5+bYpS9R4eaqZ{R8HH2~G#(Khg%TKrn# zd+Yi;@~`!qZTcxd>PY(IF8{W(IM`(2^kA+>Q$^+e4-5}(z_84DxJiRc=5t8vBAZyP z`Q*`hQku&gyOo?fWC*0Xzft4Aezv5Y&HzUhG-NAmHCoLyj#m4J!*prBqEx)Qs~}yh Y(B`fpEq7TJ<9Ja4cq!^brGvEo02FIKk^lez diff --git a/boards/urls.py b/boards/urls.py --- a/boards/urls.py +++ b/boards/urls.py @@ -2,8 +2,13 @@ from django.conf.urls import patterns, u from boards import views urlpatterns = patterns('', + # /boards/ url(r'^$', views.index, name = 'index'), + + # login page + url(r'^login$', views.login, name='login'), + # /boards/tag/ url(r'^(?P\w+)/$', views.tag, name = 'tag'), # /boards/post_id/ diff --git a/boards/urls.pyc b/boards/urls.pyc index 0f2af1c8287a06e80673a385042e8a29032deb1b..5d7aee9a06cf722246529e32ed7cb242293d1938 GIT binary patch literal 590 zc$`I$!BWC75QaBtDFsBh;1h7D<4k+;;DJG(fYEyEI5?F=D7FdH1kp1OqVMPf=x%B? zO*YB*r`dnweGU7cSBtw9{I&s(8yw~XgTT(91gIEf3@Q#82S$`b=|SZ~<^z)qga?v? z@Im^p?SQ}@z>zb8T?YdP!xr`&>^j(Q;lRPr!IKsa9qc)HO7Iv!)(0_y`)G_Fi*IZZ z$CV8+>~d>mt&H_>v#-mDk6rtW^+nsKY`w6U!ikhrO3E(|^BlC*eZtFlQ-+eJi*rQgLiS8E-w zw0e%wvPsEg>WtGxPdcxKNy&6do>GD-IZea1Y$XqmbgLaSWw*}|(N+J!Tw+K>a?tfl uvU|51t&%2tqNL07H#b=m@)P4pN;0do*q3rn&RpGRY|I01LLZ;-5&HqZ0eHLs diff --git a/boards/views.py b/boards/views.py --- a/boards/views.py +++ b/boards/views.py @@ -1,12 +1,17 @@ -from django.http import HttpResponse - -from boards.models import Post +from django.template import RequestContext +from boards.models import Post, Admins +from django.shortcuts import render +from django.http import HttpResponseRedirect def index(request): # TODO Show a real index page with all threads list threads = Post.objects.get_threads() - return HttpResponse('Imageboard, motherfucker! Do you post to it?!') + context = RequestContext(request) + context['threads'] = None if len(threads) == 0 else threads + + return render(request, 'posting_general.html', + context) def new_post(request): """Add a new post (in thread or as a reply).""" @@ -37,4 +42,19 @@ def thread(request): opening_post_id = request.GET['id'] posts = Post.objects.get_thread(opening_post_id) - # TODO Show all posts for the current thread \ No newline at end of file + # TODO Show all posts for the current thread + +def login(request): + if 'name' in request.POST and 'password' in request.POST\ + and Admins.objects.is_admin(request.POST['name'], + request.POST['password']): + + if request.POST['name'] == 'ilyas': + request.session['admin'] = True + return HttpResponseRedirect('/boards') + else: + + return render(request, 'login.html', {'error' : 'Login error'}) + + else : + return render(request, 'login.html', {}) diff --git a/boards/views.pyc b/boards/views.pyc index f14e017d4da09adc1df8f343401b3142668a3f1c..678a583515f3c30c4c9dccfa6c3c194158e2a921 GIT binary patch literal 2176 zc$}@3!H(ND5I~2b*K0ZJje*@JXbS{FTQtfc_MvDm4T2OwkseZ~m2>jNP)x#>SE3Y= zuCu`I$?Zqvy-Wesc0p~&IPXZYAP3WZ+* zIY1#`B0!KHKpsFLVIrYu!KCG9CFDm?v|-ZrdJFPnC^|6dpne2@1583tZ60(%9rNH0 zs16TKK!rT$f$G9IzJq6H|KTSVIC7^b68(0it$SV?r{B4l+;lAzf0Wj_HV%GKMP{tu zKzgl>(zVymQT*mym1tX)#_B|?tkyF(qqhKlo%km*rIXx%Z1MXgh1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{xJX~xc*OjGF{10!fLPdIs)(2aIHAqeI0GbDMq_W16o_xfNSUn1bW$>BC zk2kz-G!crOh;9VRgl<;bffG9^HLkhCo;qcbkaK0?n0mbXgv>uayC9Dx0xn%Rn&H~I zYm!m@p=%Oe(smwyIhvfF=hKtfY& z@6e(edj{6QjT^yjo$+Xi3{H95MmYCb&?6|FpHSqx+;&z?1IOS y^UnCUWJYon+Zi>RP+2qD;*5II_x>YvMxhTW^WApI-#?8|(Q%MG9y}jDOa1~dIY-t2 diff --git a/templates/base.html b/templates/base.html new file mode 100644 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,20 @@ + + + + + {% block head %}{% endblock %} + + +
+ + {% if request.session.admin == True %} + Admin panel TODO: Need to implement
+ {% endif %} + + +
+ +{% block content %}{% endblock %} + + + \ No newline at end of file diff --git a/templates/login.html b/templates/login.html new file mode 100644 --- /dev/null +++ b/templates/login.html @@ -0,0 +1,22 @@ + + + + + Login page + + + + {% if error != none%} + + {{ error }} + + {% endif %} + +
{% csrf_token %} + + Login:
+ Password:
+ +
+ + \ No newline at end of file diff --git a/templates/posting_general.html b/templates/posting_general.html --- a/templates/posting_general.html +++ b/templates/posting_general.html @@ -1,8 +1,13 @@ - - -
-
-
-
- - +{% extends "base.html" %} + +{% block content %} + + {% if threads %} + TODO: need to implement message list + {{ threads }} + {% else %} + List is still empty. Add some bool shit! + {% endif %} + +{% endblock %} +