##// END OF EJS Templates
Do not process posts from the this board, they could not be modified by anyone else
neko259 -
r2120:f62cdfb1 default
parent child Browse files
Show More
@@ -6,7 +6,7 import httplib2
6 from django.core.management import BaseCommand
6 from django.core.management import BaseCommand
7 from django.utils.dateparse import parse_datetime
7 from django.utils.dateparse import parse_datetime
8
8
9 from boards.models import GlobalId
9 from boards.models import GlobalId, KeyPair
10 from boards.models.post.sync import SyncManager, TAG_ID, TAG_UPDATE_TIME
10 from boards.models.post.sync import SyncManager, TAG_ID, TAG_UPDATE_TIME
11
11
12 __author__ = 'neko259'
12 __author__ = 'neko259'
@@ -91,16 +91,24 class Command(BaseCommand):
91 for model in models:
91 for model in models:
92 tag_id = model.find(TAG_ID)
92 tag_id = model.find(TAG_ID)
93 global_id, exists = GlobalId.from_xml_element(tag_id)
93 global_id, exists = GlobalId.from_xml_element(tag_id)
94 tag_update_time = model.find(TAG_UPDATE_TIME)
94
95 if tag_update_time:
95 from_this_board = self._is_from_this_board(global_id)
96 update_time = tag_update_time.text
96
97 if from_this_board:
98 # If the post originates from this board, no need to process
99 # it again, nobody else could modify it
100 logger.debug('* Processed (-) post {}'.format(global_id))
97 else:
101 else:
98 update_time = None
102 tag_update_time = model.find(TAG_UPDATE_TIME)
99 if not exists or update_time is None or global_id.post.last_edit_time < parse_datetime(update_time):
103 if tag_update_time:
100 logger.debug('Processed (+) post {}'.format(global_id))
104 update_time = tag_update_time.text
101 ids_to_sync.append(global_id)
105 else:
102 else:
106 update_time = None
103 logger.debug('* Processed (-) post {}'.format(global_id))
107 if not exists or update_time is None or global_id.post.last_edit_time < parse_datetime(update_time):
108 logger.debug('Processed (+) post {}'.format(global_id))
109 ids_to_sync.append(global_id)
110 else:
111 logger.debug('* Processed (-) post {}'.format(global_id))
104 logger.info('Starting sync...')
112 logger.info('Starting sync...')
105
113
106 if len(ids_to_sync) > 0:
114 if len(ids_to_sync) > 0:
@@ -119,3 +127,9 class Command(BaseCommand):
119 logger.info('Nothing to get, everything synced')
127 logger.info('Nothing to get, everything synced')
120 else:
128 else:
121 raise Exception('Invalid response status')
129 raise Exception('Invalid response status')
130
131 def _is_from_this_board(self, global_id):
132 from_this_board = KeyPair.objects.filter(
133 key_type=global_id.key_type,
134 public_key=global_id.key).exists()
135 return from_this_board
@@ -4,7 +4,7 simplejson
4 pytube
4 pytube
5 requests
5 requests
6 pillow
6 pillow
7 django>=1.8
7 django>=1.8,<2.1
8 bbcode
8 bbcode
9 django-debug-toolbar
9 django-debug-toolbar
10 pytz
10 pytz
General Comments 0
You need to be logged in to leave comments. Login now