Show More
@@ -0,0 +1,130 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | import datetime | |||
|
3 | from south.db import db | |||
|
4 | from south.v2 import SchemaMigration | |||
|
5 | from django.db import models | |||
|
6 | ||||
|
7 | ||||
|
8 | class Migration(SchemaMigration): | |||
|
9 | ||||
|
10 | def forwards(self, orm): | |||
|
11 | # Deleting model 'Admin' | |||
|
12 | db.delete_table(u'boards_admin') | |||
|
13 | ||||
|
14 | # Adding model 'User' | |||
|
15 | db.create_table(u'boards_user', ( | |||
|
16 | (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | |||
|
17 | ('user_id', self.gf('django.db.models.fields.CharField')(max_length=50)), | |||
|
18 | ('rank', self.gf('django.db.models.fields.IntegerField')()), | |||
|
19 | ('registration_time', self.gf('django.db.models.fields.DateTimeField')()), | |||
|
20 | ('last_access_time', self.gf('django.db.models.fields.DateTimeField')()), | |||
|
21 | )) | |||
|
22 | db.send_create_signal(u'boards', ['User']) | |||
|
23 | ||||
|
24 | # Adding M2M table for field fav_tags on 'User' | |||
|
25 | m2m_table_name = db.shorten_name(u'boards_user_fav_tags') | |||
|
26 | db.create_table(m2m_table_name, ( | |||
|
27 | ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), | |||
|
28 | ('user', models.ForeignKey(orm[u'boards.user'], null=False)), | |||
|
29 | ('tag', models.ForeignKey(orm[u'boards.tag'], null=False)) | |||
|
30 | )) | |||
|
31 | db.create_unique(m2m_table_name, ['user_id', 'tag_id']) | |||
|
32 | ||||
|
33 | # Adding M2M table for field fav_threads on 'User' | |||
|
34 | m2m_table_name = db.shorten_name(u'boards_user_fav_threads') | |||
|
35 | db.create_table(m2m_table_name, ( | |||
|
36 | ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), | |||
|
37 | ('user', models.ForeignKey(orm[u'boards.user'], null=False)), | |||
|
38 | ('post', models.ForeignKey(orm[u'boards.post'], null=False)) | |||
|
39 | )) | |||
|
40 | db.create_unique(m2m_table_name, ['user_id', 'post_id']) | |||
|
41 | ||||
|
42 | # Adding model 'Setting' | |||
|
43 | db.create_table(u'boards_setting', ( | |||
|
44 | (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | |||
|
45 | ('name', self.gf('django.db.models.fields.CharField')(max_length=50)), | |||
|
46 | ('value', self.gf('django.db.models.fields.CharField')(max_length=50)), | |||
|
47 | ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['boards.User'])), | |||
|
48 | )) | |||
|
49 | db.send_create_signal(u'boards', ['Setting']) | |||
|
50 | ||||
|
51 | # Adding field 'Post.user' | |||
|
52 | db.add_column(u'boards_post', 'user', | |||
|
53 | self.gf('django.db.models.fields.related.ForeignKey')(default=None, to=orm['boards.User'], null=True), | |||
|
54 | keep_default=False) | |||
|
55 | ||||
|
56 | ||||
|
57 | def backwards(self, orm): | |||
|
58 | # Adding model 'Admin' | |||
|
59 | db.create_table(u'boards_admin', ( | |||
|
60 | ('password', self.gf('django.db.models.fields.CharField')(max_length=100)), | |||
|
61 | (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | |||
|
62 | ('name', self.gf('django.db.models.fields.CharField')(max_length=100)), | |||
|
63 | )) | |||
|
64 | db.send_create_signal(u'boards', ['Admin']) | |||
|
65 | ||||
|
66 | # Deleting model 'User' | |||
|
67 | db.delete_table(u'boards_user') | |||
|
68 | ||||
|
69 | # Removing M2M table for field fav_tags on 'User' | |||
|
70 | db.delete_table(db.shorten_name(u'boards_user_fav_tags')) | |||
|
71 | ||||
|
72 | # Removing M2M table for field fav_threads on 'User' | |||
|
73 | db.delete_table(db.shorten_name(u'boards_user_fav_threads')) | |||
|
74 | ||||
|
75 | # Deleting model 'Setting' | |||
|
76 | db.delete_table(u'boards_setting') | |||
|
77 | ||||
|
78 | # Deleting field 'Post.user' | |||
|
79 | db.delete_column(u'boards_post', 'user_id') | |||
|
80 | ||||
|
81 | ||||
|
82 | models = { | |||
|
83 | u'boards.ban': { | |||
|
84 | 'Meta': {'object_name': 'Ban'}, | |||
|
85 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
86 | 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}) | |||
|
87 | }, | |||
|
88 | u'boards.post': { | |||
|
89 | 'Meta': {'object_name': 'Post'}, | |||
|
90 | '_text_rendered': ('django.db.models.fields.TextField', [], {}), | |||
|
91 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
92 | 'image': ('boards.thumbs.ImageWithThumbsField', [], {'max_length': '100', 'blank': 'True'}), | |||
|
93 | 'image_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), | |||
|
94 | 'image_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}), | |||
|
95 | 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
96 | 'parent': ('django.db.models.fields.BigIntegerField', [], {}), | |||
|
97 | 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), | |||
|
98 | 'poster_user_agent': ('django.db.models.fields.TextField', [], {}), | |||
|
99 | 'pub_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
100 | 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['boards.Tag']", 'symmetrical': 'False'}), | |||
|
101 | 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}), | |||
|
102 | 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'markdown'", 'max_length': '30'}), | |||
|
103 | 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}), | |||
|
104 | 'user': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['boards.User']", 'null': 'True'}) | |||
|
105 | }, | |||
|
106 | u'boards.setting': { | |||
|
107 | 'Meta': {'object_name': 'Setting'}, | |||
|
108 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
109 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), | |||
|
110 | 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['boards.User']"}), | |||
|
111 | 'value': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | |||
|
112 | }, | |||
|
113 | u'boards.tag': { | |||
|
114 | 'Meta': {'object_name': 'Tag'}, | |||
|
115 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
116 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) | |||
|
117 | }, | |||
|
118 | u'boards.user': { | |||
|
119 | 'Meta': {'object_name': 'User'}, | |||
|
120 | 'fav_tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['boards.Tag']", 'symmetrical': 'False'}), | |||
|
121 | 'fav_threads': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'+'", 'symmetrical': 'False', 'to': u"orm['boards.Post']"}), | |||
|
122 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
123 | 'last_access_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
124 | 'rank': ('django.db.models.fields.IntegerField', [], {}), | |||
|
125 | 'registration_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
126 | 'user_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | |||
|
127 | } | |||
|
128 | } | |||
|
129 | ||||
|
130 | complete_apps = ['boards'] No newline at end of file |
@@ -4,7 +4,7 b' from django.test.client import Client' | |||||
4 |
|
4 | |||
5 | import boards |
|
5 | import boards | |
6 |
|
6 | |||
7 |
from boards.models import Post, |
|
7 | from boards.models import Post, Tag | |
8 | from neboard import settings |
|
8 | from neboard import settings | |
9 |
|
9 | |||
10 | TEST_TEXT = 'test text' |
|
10 | TEST_TEXT = 'test text' | |
@@ -78,13 +78,6 b' class BoardTests(TestCase):' | |||||
78 | self.assertEqual(settings.MAX_THREAD_COUNT, |
|
78 | self.assertEqual(settings.MAX_THREAD_COUNT, | |
79 | len(Post.objects.get_threads())) |
|
79 | len(Post.objects.get_threads())) | |
80 |
|
80 | |||
81 | def test_get(self): |
|
|||
82 | """Test if the get computes properly""" |
|
|||
83 |
|
||||
84 | post = self._create_post() |
|
|||
85 |
|
||||
86 | self.assertTrue(post.is_get()) |
|
|||
87 |
|
||||
88 | def test_pages(self): |
|
81 | def test_pages(self): | |
89 | """Test that the thread list is properly split into pages""" |
|
82 | """Test that the thread list is properly split into pages""" | |
90 |
|
83 | |||
@@ -160,6 +153,7 b' class BoardTests(TestCase):' | |||||
160 |
|
153 | |||
161 | response_not_existing = client.get(THREAD_PAGE + str( |
|
154 | response_not_existing = client.get(THREAD_PAGE + str( | |
162 | existing_post_id + 1) + '/') |
|
155 | existing_post_id + 1) + '/') | |
|
156 | response_not_existing.get_full_path() | |||
163 | self.assertEqual(HTTP_CODE_NOT_FOUND, |
|
157 | self.assertEqual(HTTP_CODE_NOT_FOUND, | |
164 | response_not_existing.status_code, |
|
158 | response_not_existing.status_code, | |
165 | u'Not existing thread is opened') |
|
159 | u'Not existing thread is opened') |
@@ -11,7 +11,7 b' from boards import utils' | |||||
11 | from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \ |
|
11 | from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \ | |
12 | ThreadCaptchaForm, PostCaptchaForm |
|
12 | ThreadCaptchaForm, PostCaptchaForm | |
13 |
|
13 | |||
14 |
from boards.models import Post |
|
14 | from boards.models import Post, Tag, Ban, User, RANK_USER, RANK_MODERATOR, NO_PARENT | |
15 | from boards import authors |
|
15 | from boards import authors | |
16 | import neboard |
|
16 | import neboard | |
17 |
|
17 | |||
@@ -292,8 +292,10 b' def _get_user(request):' | |||||
292 | md5.update(session.session_key) |
|
292 | md5.update(session.session_key) | |
293 | new_id = md5.hexdigest() |
|
293 | new_id = md5.hexdigest() | |
294 |
|
294 | |||
|
295 | time_now = timezone.now() | |||
295 | user = User.objects.create(user_id=new_id, rank=RANK_USER, |
|
296 | user = User.objects.create(user_id=new_id, rank=RANK_USER, | |
296 |
registration_time=time |
|
297 | registration_time=time_now, | |
|
298 | last_access_time=time_now) | |||
297 |
|
299 | |||
298 | session['user_id'] = user.id |
|
300 | session['user_id'] = user.id | |
299 | else: |
|
301 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now