Explorar el Código

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

master
Dirk Alders hace 4 años
padre
commit
55f12b2202
Se han modificado 2 ficheros con 12 adiciones y 5 borrados
  1. 3
    0
      __init__.py
  2. 9
    5
      views/userviews.py

+ 3
- 0
__init__.py Ver fichero

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

+ 9
- 5
views/userviews.py Ver fichero

30
     }.get(get_item_type(full_path), base_view)
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
 def random_copy(request, lst):
37
 def random_copy(request, lst):
46
 
46
 
47
 
47
 
48
 class base_view(object):
48
 class base_view(object):
49
-    def __init__(self, request, full_path):
49
+    def __init__(self, request, full_path, is_nxt_prv_item):
50
         self.request = request
50
         self.request = request
51
         self.full_path = full_path
51
         self.full_path = full_path
52
+        self.is_nxt_prv_item = is_nxt_prv_item
52
         #
53
         #
53
         self.item = get_item_by_rel_path(pygal.get_rel_path(full_path))
54
         self.item = get_item_by_rel_path(pygal.get_rel_path(full_path))
54
         if self.item is None:
55
         if self.item is None:
227
 
228
 
228
     @property
229
     @property
229
     def url_userview(self):
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
     @property
236
     @property
233
     def url_webnail(self):
237
     def url_webnail(self):
256
         for i in range(i + direction, i + direction * lgt, direction):
260
         for i in range(i + direction, i + direction * lgt, direction):
257
             full_path = fp_il[i % lgt]
261
             full_path = fp_il[i % lgt]
258
             if get_item_type(full_path) != TYPE_FOLDER:
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
         return self
264
         return self
261
 
265
 
262
     @property
266
     @property

Loading…
Cancelar
Guardar