Просмотр исходного кода

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

master
Dirk Alders 4 лет назад
Родитель
Сommit
55f12b2202
2 измененных файлов: 12 добавлений и 5 удалений
  1. 3
    0
      __init__.py
  2. 9
    5
      views/userviews.py

+ 3
- 0
__init__.py Просмотреть файл

@@ -9,6 +9,7 @@ SHUFFLE_ENABLE = 2
9 9
 
10 10
 REPEAT_DISABLE = 0
11 11
 REPEAT_ENABLE = 1
12
+REPEAT_KEEP = 2
12 13
 
13 14
 SEARCH_DISABLE = 0
14 15
 SEARCH_KEEP = 1
@@ -72,6 +73,8 @@ def url_args(request, repeat=REPEAT_DISABLE, shuffle=SHUFFLE_KEEP, search=SEARCH
72 73
     args_d = {}
73 74
     if repeat == REPEAT_ENABLE:
74 75
         args_d['repeat'] = None
76
+    elif repeat == REPEAT_KEEP and is_repeatview(request):
77
+        args_d['repeat'] = None
75 78
     if shuffle == SHUFFLE_ENABLE:
76 79
         args_d['shuffle'] = binascii.hexlify(os.urandom(24)).decode('utf-8')
77 80
     elif shuffle == SHUFFLE_KEEP:

+ 9
- 5
views/userviews.py Просмотреть файл

@@ -30,8 +30,8 @@ def get_wrapper_class(full_path):
30 30
     }.get(get_item_type(full_path), base_view)
31 31
 
32 32
 
33
-def get_wrapper_instance(full_path, request):
34
-    return get_wrapper_class(full_path)(request, full_path)
33
+def get_wrapper_instance(full_path, request, is_nxt_prv_item=False):
34
+    return get_wrapper_class(full_path)(request, full_path, is_nxt_prv_item)
35 35
 
36 36
 
37 37
 def random_copy(request, lst):
@@ -46,9 +46,10 @@ def random_copy(request, lst):
46 46
 
47 47
 
48 48
 class base_view(object):
49
-    def __init__(self, request, full_path):
49
+    def __init__(self, request, full_path, is_nxt_prv_item):
50 50
         self.request = request
51 51
         self.full_path = full_path
52
+        self.is_nxt_prv_item = is_nxt_prv_item
52 53
         #
53 54
         self.item = get_item_by_rel_path(pygal.get_rel_path(full_path))
54 55
         if self.item is None:
@@ -227,7 +228,10 @@ class base_view(object):
227 228
 
228 229
     @property
229 230
     def url_userview(self):
230
-        return pygal.url_userview(self.request, self.item.rel_path, search=pygal.SEARCH_KEEP)
231
+        if self.is_nxt_prv_item:
232
+            return pygal.url_userview(self.request, self.item.rel_path, search=pygal.SEARCH_KEEP, repeat=pygal.REPEAT_KEEP)
233
+        else:
234
+            return pygal.url_userview(self.request, self.item.rel_path, search=pygal.SEARCH_KEEP, repeat=pygal.REPEAT_DISABLE)
231 235
 
232 236
     @property
233 237
     def url_webnail(self):
@@ -256,7 +260,7 @@ class base_view(object):
256 260
         for i in range(i + direction, i + direction * lgt, direction):
257 261
             full_path = fp_il[i % lgt]
258 262
             if get_item_type(full_path) != TYPE_FOLDER:
259
-                return get_wrapper_instance(full_path, self.request)
263
+                return get_wrapper_instance(full_path, self.request, is_nxt_prv_item=True)
260 264
         return self
261 265
 
262 266
     @property

Загрузка…
Отмена
Сохранить