Show More
@@ -0,0 +1,8 b'' | |||||
|
1 | html{ | |||
|
2 | background: #BBBBBB; | |||
|
3 | } | |||
|
4 | ||||
|
5 | #admin_panel{ | |||
|
6 | background: #FF0000; | |||
|
7 | color: #00FF00 | |||
|
8 | } No newline at end of file |
@@ -0,0 +1,20 b'' | |||||
|
1 | <!DOCTYPE html> | |||
|
2 | <html> | |||
|
3 | <head> | |||
|
4 | <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/base_page.css" media="all"/> | |||
|
5 | {% block head %}{% endblock %} | |||
|
6 | </head> | |||
|
7 | <body> | |||
|
8 | <div id="admin_panel"> | |||
|
9 | ||||
|
10 | {% if request.session.admin == True %} | |||
|
11 | Admin panel TODO: Need to implement <BR /> | |||
|
12 | {% endif %} | |||
|
13 | ||||
|
14 | ||||
|
15 | </div> | |||
|
16 | ||||
|
17 | {% block content %}{% endblock %} | |||
|
18 | ||||
|
19 | </body> | |||
|
20 | </html> No newline at end of file |
@@ -0,0 +1,22 b'' | |||||
|
1 | <!DOCTYPE html> | |||
|
2 | <html> | |||
|
3 | <head> | |||
|
4 | <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/login.css" media="all"/> | |||
|
5 | <title>Login page</title> | |||
|
6 | </head> | |||
|
7 | ||||
|
8 | <body> | |||
|
9 | {% if error != none%} | |||
|
10 | <span id="error_message"> | |||
|
11 | {{ error }} | |||
|
12 | </span> | |||
|
13 | {% endif %} | |||
|
14 | ||||
|
15 | <form action="login" method="POST">{% csrf_token %} | |||
|
16 | ||||
|
17 | Login: <input type="text" name="name"><br /> | |||
|
18 | Password: <input type="password" name="password"><br /> | |||
|
19 | <input type="submit"> | |||
|
20 | </form> | |||
|
21 | </body> | |||
|
22 | </html> No newline at end of file |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,5 +1,6 b'' | |||||
1 | from django.contrib import admin |
|
1 | from django.contrib import admin | |
2 | from boards.models import Post, Tag |
|
2 | from boards.models import Post, Tag, Admins | |
3 |
|
3 | |||
4 | admin.site.register(Post) |
|
4 | admin.site.register(Post) | |
5 | admin.site.register(Tag) |
|
5 | admin.site.register(Tag) | |
|
6 | admin.site.register(Admins) |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -50,6 +50,9 b' class PostManager(models.Manager):' | |||||
50 |
|
50 | |||
51 | return len(posts) == 0 |
|
51 | return len(posts) == 0 | |
52 |
|
52 | |||
|
53 | def is_admin(self, user, passw): | |||
|
54 | return Admins.objects.filter(name = user, password = passw) is not None | |||
|
55 | ||||
53 |
|
56 | |||
54 | class Tag(models.Model): |
|
57 | class Tag(models.Model): | |
55 | """ |
|
58 | """ | |
@@ -75,4 +78,19 b' class Post(models.Model):' | |||||
75 | tags = models.ManyToManyField(Tag) |
|
78 | tags = models.ManyToManyField(Tag) | |
76 |
|
79 | |||
77 | def __unicode__(self): |
|
80 | def __unicode__(self): | |
78 | return self.title + ' (' + self.text + ')' No newline at end of file |
|
81 | return self.title + ' (' + self.text + ')' | |
|
82 | ||||
|
83 | ||||
|
84 | class Admins(models.Model): | |||
|
85 | """ | |||
|
86 | Model for admin users | |||
|
87 | """ | |||
|
88 | ||||
|
89 | objects = PostManager() | |||
|
90 | ||||
|
91 | name = models.CharField(max_length=100) | |||
|
92 | password = models.CharField(max_length=100) | |||
|
93 | ||||
|
94 | def __unicode__(self): | |||
|
95 | return self.name + '/' + '*' * len(self.password) | |||
|
96 |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -2,8 +2,13 b' from django.conf.urls import patterns, u' | |||||
2 | from boards import views |
|
2 | from boards import views | |
3 |
|
3 | |||
4 | urlpatterns = patterns('', |
|
4 | urlpatterns = patterns('', | |
|
5 | ||||
5 | # /boards/ |
|
6 | # /boards/ | |
6 | url(r'^$', views.index, name = 'index'), |
|
7 | url(r'^$', views.index, name = 'index'), | |
|
8 | ||||
|
9 | # login page | |||
|
10 | url(r'^login$', views.login, name='login'), | |||
|
11 | ||||
7 | # /boards/tag/ |
|
12 | # /boards/tag/ | |
8 | url(r'^(?P<tag>\w+)/$', views.tag, name = 'tag'), |
|
13 | url(r'^(?P<tag>\w+)/$', views.tag, name = 'tag'), | |
9 | # /boards/post_id/ |
|
14 | # /boards/post_id/ |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,12 +1,17 b'' | |||||
1 |
from django. |
|
1 | from django.template import RequestContext | |
2 |
|
2 | from boards.models import Post, Admins | ||
3 | from boards.models import Post |
|
3 | from django.shortcuts import render | |
|
4 | from django.http import HttpResponseRedirect | |||
4 |
|
5 | |||
5 | def index(request): |
|
6 | def index(request): | |
6 | # TODO Show a real index page with all threads list |
|
7 | # TODO Show a real index page with all threads list | |
7 | threads = Post.objects.get_threads() |
|
8 | threads = Post.objects.get_threads() | |
8 |
|
9 | |||
9 | return HttpResponse('Imageboard, motherfucker! Do you post to it?!') |
|
10 | context = RequestContext(request) | |
|
11 | context['threads'] = None if len(threads) == 0 else threads | |||
|
12 | ||||
|
13 | return render(request, 'posting_general.html', | |||
|
14 | context) | |||
10 |
|
15 | |||
11 | def new_post(request): |
|
16 | def new_post(request): | |
12 | """Add a new post (in thread or as a reply).""" |
|
17 | """Add a new post (in thread or as a reply).""" | |
@@ -37,4 +42,19 b' def thread(request):' | |||||
37 | opening_post_id = request.GET['id'] |
|
42 | opening_post_id = request.GET['id'] | |
38 | posts = Post.objects.get_thread(opening_post_id) |
|
43 | posts = Post.objects.get_thread(opening_post_id) | |
39 |
|
44 | |||
40 | # TODO Show all posts for the current thread No newline at end of file |
|
45 | # TODO Show all posts for the current thread | |
|
46 | ||||
|
47 | def login(request): | |||
|
48 | if 'name' in request.POST and 'password' in request.POST\ | |||
|
49 | and Admins.objects.is_admin(request.POST['name'], | |||
|
50 | request.POST['password']): | |||
|
51 | ||||
|
52 | if request.POST['name'] == 'ilyas': | |||
|
53 | request.session['admin'] = True | |||
|
54 | return HttpResponseRedirect('/boards') | |||
|
55 | else: | |||
|
56 | ||||
|
57 | return render(request, 'login.html', {'error' : 'Login error'}) | |||
|
58 | ||||
|
59 | else : | |||
|
60 | return render(request, 'login.html', {}) |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,4 +1,5 b'' | |||||
1 | # Django settings for neboard project. |
|
1 | # Django settings for neboard project. | |
|
2 | import os | |||
2 |
|
3 | |||
3 | DEBUG = True |
|
4 | DEBUG = True | |
4 | TEMPLATE_DEBUG = DEBUG |
|
5 | TEMPLATE_DEBUG = DEBUG | |
@@ -63,7 +64,11 b" STATIC_ROOT = ''" | |||||
63 | STATIC_URL = '/static/' |
|
64 | STATIC_URL = '/static/' | |
64 |
|
65 | |||
65 | # Additional locations of static files |
|
66 | # Additional locations of static files | |
|
67 | # It is really a hack, put real paths, not related | |||
66 | STATICFILES_DIRS = ( |
|
68 | STATICFILES_DIRS = ( | |
|
69 | os.path.dirname(__file__) + '/boards/static', | |||
|
70 | ||||
|
71 | # '/d/work/python/django/neboard/neboard/boards/static', | |||
67 | # Put strings here, like "/home/html/static" or "C:/www/django/static". |
|
72 | # Put strings here, like "/home/html/static" or "C:/www/django/static". | |
68 | # Always use forward slashes, even on Windows. |
|
73 | # Always use forward slashes, even on Windows. | |
69 | # Don't forget to use absolute paths, not relative paths. |
|
74 | # Don't forget to use absolute paths, not relative paths. | |
@@ -87,10 +92,17 b' TEMPLATE_LOADERS = (' | |||||
87 | # 'django.template.loaders.eggs.Loader', |
|
92 | # 'django.template.loaders.eggs.Loader', | |
88 | ) |
|
93 | ) | |
89 |
|
94 | |||
|
95 | TEMPLATE_CONTEXT_PROCESSORS = ( | |||
|
96 | 'django.core.context_processors.media', | |||
|
97 | 'django.core.context_processors.static', | |||
|
98 | 'django.core.context_processors.request', | |||
|
99 | 'django.contrib.auth.context_processors.auth', | |||
|
100 | ) | |||
|
101 | ||||
90 | MIDDLEWARE_CLASSES = ( |
|
102 | MIDDLEWARE_CLASSES = ( | |
91 | 'django.middleware.common.CommonMiddleware', |
|
103 | 'django.middleware.common.CommonMiddleware', | |
92 | 'django.contrib.sessions.middleware.SessionMiddleware', |
|
104 | 'django.contrib.sessions.middleware.SessionMiddleware', | |
93 | 'django.middleware.csrf.CsrfViewMiddleware', |
|
105 | # 'django.middleware.csrf.CsrfViewMiddleware', | |
94 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
|
106 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
95 | 'django.contrib.messages.middleware.MessageMiddleware', |
|
107 | 'django.contrib.messages.middleware.MessageMiddleware', | |
96 | # Uncomment the next line for simple clickjacking protection: |
|
108 | # Uncomment the next line for simple clickjacking protection: |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,8 +1,13 b'' | |||||
1 | <html> |
|
1 | {% extends "base.html" %} | |
2 | <body> |
|
2 | ||
3 | <div id="postform"> |
|
3 | {% block content %} | |
4 | </div> |
|
4 | ||
5 | <div id="posts"> |
|
5 | {% if threads %} | |
6 | </div> |
|
6 | TODO: need to implement message list | |
7 | </body> |
|
7 | {{ threads }} | |
8 | </html> |
|
8 | {% else %} | |
|
9 | List is still empty. Add some bool shit! | |||
|
10 | {% endif %} | |||
|
11 | ||||
|
12 | {% endblock %} | |||
|
13 |
General Comments 0
You need to be logged in to leave comments.
Login now