Synchronise badges with Blender ID
Synchronisation is performed in the background by the Celery Beat, every 10 minutes. It has a time limit of 9 minutes to prevent multiple refresh tasks from running at the same time. Synchronisation is also possible with the `manage.py badges sync` CLI command, which can sync either a single user or all users.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from collections import defaultdict
|
||||
import datetime
|
||||
import os.path
|
||||
from os import getenv
|
||||
from collections import defaultdict
|
||||
|
||||
import requests.certs
|
||||
|
||||
# Certificate file for communication with other systems.
|
||||
@@ -204,8 +206,18 @@ CELERY_BEAT_SCHEDULE = {
|
||||
'schedule': 600, # every N seconds
|
||||
'args': ('gcs', 100)
|
||||
},
|
||||
'refresh-blenderid-badges': {
|
||||
'task': 'pillar.celery.badges.sync_badges_for_users',
|
||||
'schedule': 600, # every N seconds
|
||||
'args': (540, ), # time limit in seconds, keep shorter than 'schedule'
|
||||
}
|
||||
}
|
||||
|
||||
# Badges will be re-fetched every timedelta.
|
||||
# TODO(Sybren): A proper value should be determined after we actually have users with badges.
|
||||
BLENDER_ID_BADGE_EXPIRY = datetime.timedelta(hours=4)
|
||||
|
||||
|
||||
# Mapping from user role to capabilities obtained by users with that role.
|
||||
USER_CAPABILITIES = defaultdict(**{
|
||||
'subscriber': {'subscriber', 'home-project'},
|
||||
|
Reference in New Issue
Block a user