##// END OF EJS Templates
Moved exceptions to a separate module
neko259 -
r1602:beb32860 default
parent child Browse files
Show More
@@ -0,0 +1,10 b''
1 class BannedException(Exception):
2 pass
3
4
5 class ArchiveException(Exception):
6 pass
7
8
9 class SyncException(Exception):
10 pass
@@ -3,6 +3,7 b' import logging'
3 from datetime import datetime, timedelta, date
3 from datetime import datetime, timedelta, date
4 from datetime import time as dtime
4 from datetime import time as dtime
5
5
6 from boards.abstracts.exceptions import BannedException, ArchiveException
6 from django.db import models, transaction
7 from django.db import models, transaction
7 from django.utils import timezone
8 from django.utils import timezone
8 from django.dispatch import Signal
9 from django.dispatch import Signal
@@ -33,16 +34,15 b' class PostManager(models.Manager):'
33 """
34 """
34
35
35 if thread is not None and thread.is_archived():
36 if thread is not None and thread.is_archived():
36 raise Exception('Cannot post into an archived thread')
37 raise ArchiveException('Cannot post into an archived thread')
37
38
38 if not utils.is_anonymous_mode():
39 if not utils.is_anonymous_mode():
39 is_banned = Ban.objects.filter(ip=ip).exists()
40 is_banned = Ban.objects.filter(ip=ip).exists()
40 else:
41 else:
41 is_banned = False
42 is_banned = False
42
43
43 # TODO Raise specific exception and catch it in the views
44 if is_banned:
44 if is_banned:
45 raise Exception("This user is banned")
45 raise BannedException("This user is banned")
46
46
47 if not tags:
47 if not tags:
48 tags = []
48 tags = []
@@ -1,9 +1,10 b''
1 import xml.etree.ElementTree as et
1 import xml.etree.ElementTree as et
2
2
3 from boards.abstracts.exceptions import SyncException
4 from boards.models import KeyPair, GlobalId, Signature, Post, Tag
3 from boards.models.attachment.downloaders import download
5 from boards.models.attachment.downloaders import download
4 from boards.utils import get_file_mimetype, get_file_hash
6 from boards.utils import get_file_mimetype, get_file_hash
5 from django.db import transaction
7 from django.db import transaction
6 from boards.models import KeyPair, GlobalId, Signature, Post, Tag
7
8
8 EXCEPTION_NODE = 'Sync node returned an error: {}.'
9 EXCEPTION_NODE = 'Sync node returned an error: {}.'
9 EXCEPTION_OP = 'Load the OP first.'
10 EXCEPTION_OP = 'Load the OP first.'
@@ -52,10 +53,6 b" ID_TYPE_MD5 = 'md5'"
52 STATUS_SUCCESS = 'success'
53 STATUS_SUCCESS = 'success'
53
54
54
55
55 class SyncException(Exception):
56 pass
57
58
59 class SyncManager:
56 class SyncManager:
60 @staticmethod
57 @staticmethod
61 def generate_response_get(model_list: list):
58 def generate_response_get(model_list: list):
General Comments 0
You need to be logged in to leave comments. Login now