##// END OF EJS Templates
Fixed an import issue in models. Removed tests for admin because the user model has changed.
neko259 -
r140:aaf68ba2 1.1
parent child Browse files
Show More
@@ -228,7 +228,7 b' class Post(models.Model):'
228 parent = models.BigIntegerField()
228 parent = models.BigIntegerField()
229 tags = models.ManyToManyField(Tag)
229 tags = models.ManyToManyField(Tag)
230 last_edit_time = models.DateTimeField()
230 last_edit_time = models.DateTimeField()
231 user = models.ForeignKey(User, null=True, default=None)
231 user = models.ForeignKey('User', null=True, default=None)
232
232
233 def __unicode__(self):
233 def __unicode__(self):
234 return '#' + str(self.id) + ' ' + self.title + ' (' + \
234 return '#' + str(self.id) + ' ' + self.title + ' (' + \
@@ -285,7 +285,7 b' class User(models.Model):'
285 last_access_time = models.DateTimeField()
285 last_access_time = models.DateTimeField()
286
286
287 fav_tags = models.ManyToManyField(Tag)
287 fav_tags = models.ManyToManyField(Tag)
288 fav_threads = models.ManyToManyField(Post)
288 fav_threads = models.ManyToManyField(Post, related_name='+')
289
289
290 def save_setting(self, name, value):
290 def save_setting(self, name, value):
291 setting, created = Setting.objects.get_or_create(name=name, user=self)
291 setting, created = Setting.objects.get_or_create(name=name, user=self)
@@ -314,6 +314,7 b' class User(models.Model):'
314 def __unicode__(self):
314 def __unicode__(self):
315 return self.user_id
315 return self.user_id
316
316
317
317 class Setting(models.Model):
318 class Setting(models.Model):
318
319
319 name = models.CharField(max_length=50)
320 name = models.CharField(max_length=50)
@@ -54,48 +54,6 b' class BoardTests(TestCase):'
54 admin.save()
54 admin.save()
55 return admin
55 return admin
56
56
57 def test_admin_login(self):
58 client = Client()
59
60 self.assertFalse('admin' in client.session)
61
62 admin = self._create_test_user()
63
64 response = client.post('/login',
65 {'name': admin.name, 'password': admin.password})
66
67 # it means that login passed and user are redirected to another page
68 self.assertEqual(302, response.status_code)
69
70 self.assertTrue('admin' in client.session)
71 self.assertTrue(client.session['admin'])
72
73 admin.delete()
74
75 wrong_name = 'sd2f1s3d21fs3d21f'
76 wrong_password = 'sd2f1s3d21fs3d21fsdfsd'
77
78 client.post('/login', {'name': wrong_name, 'password': wrong_password})
79 self.assertFalse(client.session['admin'])
80
81 def test_admin_logout(self):
82 client = Client()
83
84 self.assertFalse('admin' in client.session)
85
86 admin = self._create_test_user()
87
88 client.post('/login',
89 {'name': admin.name, 'password': admin.password})
90
91 self.assertTrue(client.session['admin'])
92
93 client.get('/logout')
94
95 self.assertFalse(client.session['admin'])
96
97 admin.delete()
98
99 def test_get_thread(self):
57 def test_get_thread(self):
100 opening_post = self._create_post()
58 opening_post = self._create_post()
101 op_id = opening_post.id
59 op_id = opening_post.id
General Comments 0
You need to be logged in to leave comments. Login now