Keep repeat mode in url_userview, if item is next or previous

This commit is contained in:
Dirk Alders 2020-02-23 17:50:54 +01:00
parent 5b5d205476
commit 55f12b2202
2 changed files with 12 additions and 5 deletions

View File

@ -9,6 +9,7 @@ SHUFFLE_ENABLE = 2
REPEAT_DISABLE = 0 REPEAT_DISABLE = 0
REPEAT_ENABLE = 1 REPEAT_ENABLE = 1
REPEAT_KEEP = 2
SEARCH_DISABLE = 0 SEARCH_DISABLE = 0
SEARCH_KEEP = 1 SEARCH_KEEP = 1
@ -72,6 +73,8 @@ def url_args(request, repeat=REPEAT_DISABLE, shuffle=SHUFFLE_KEEP, search=SEARCH
args_d = {} args_d = {}
if repeat == REPEAT_ENABLE: if repeat == REPEAT_ENABLE:
args_d['repeat'] = None args_d['repeat'] = None
elif repeat == REPEAT_KEEP and is_repeatview(request):
args_d['repeat'] = None
if shuffle == SHUFFLE_ENABLE: if shuffle == SHUFFLE_ENABLE:
args_d['shuffle'] = binascii.hexlify(os.urandom(24)).decode('utf-8') args_d['shuffle'] = binascii.hexlify(os.urandom(24)).decode('utf-8')
elif shuffle == SHUFFLE_KEEP: elif shuffle == SHUFFLE_KEEP:

View File

@ -30,8 +30,8 @@ def get_wrapper_class(full_path):
}.get(get_item_type(full_path), base_view) }.get(get_item_type(full_path), base_view)
def get_wrapper_instance(full_path, request): def get_wrapper_instance(full_path, request, is_nxt_prv_item=False):
return get_wrapper_class(full_path)(request, full_path) return get_wrapper_class(full_path)(request, full_path, is_nxt_prv_item)
def random_copy(request, lst): def random_copy(request, lst):
@ -46,9 +46,10 @@ def random_copy(request, lst):
class base_view(object): class base_view(object):
def __init__(self, request, full_path): def __init__(self, request, full_path, is_nxt_prv_item):
self.request = request self.request = request
self.full_path = full_path self.full_path = full_path
self.is_nxt_prv_item = is_nxt_prv_item
# #
self.item = get_item_by_rel_path(pygal.get_rel_path(full_path)) self.item = get_item_by_rel_path(pygal.get_rel_path(full_path))
if self.item is None: if self.item is None:
@ -227,7 +228,10 @@ class base_view(object):
@property @property
def url_userview(self): def url_userview(self):
return pygal.url_userview(self.request, self.item.rel_path, search=pygal.SEARCH_KEEP) if self.is_nxt_prv_item:
return pygal.url_userview(self.request, self.item.rel_path, search=pygal.SEARCH_KEEP, repeat=pygal.REPEAT_KEEP)
else:
return pygal.url_userview(self.request, self.item.rel_path, search=pygal.SEARCH_KEEP, repeat=pygal.REPEAT_DISABLE)
@property @property
def url_webnail(self): def url_webnail(self):
@ -256,7 +260,7 @@ class base_view(object):
for i in range(i + direction, i + direction * lgt, direction): for i in range(i + direction, i + direction * lgt, direction):
full_path = fp_il[i % lgt] full_path = fp_il[i % lgt]
if get_item_type(full_path) != TYPE_FOLDER: if get_item_type(full_path) != TYPE_FOLDER:
return get_wrapper_instance(full_path, self.request) return get_wrapper_instance(full_path, self.request, is_nxt_prv_item=True)
return self return self
@property @property