Repository: dpgmediamagazines/django-arctic

Issue:
Burger menu in safari
the burger menu in safari doesn't usually turn into a cross when clicked, instead it removes the middle bar and doesn't do the animation to create a cross.
Before:
<img width="70" alt="screen shot 2016-05-18 at 21 14 30" src="https://cloud.githubusercontent.com/assets/710948/15371825/b2dc63c0-1d3d-11e6-8f6e-139a578a0005.png">
After:
<img width="64" alt="screen shot 2016-05-18 at 21 14 45" src="https://cloud.githubusercontent.com/assets/710948/15371830/b46c8daa-1d3d-11e6-99ae-5fc5a0d18475.png">



Discussion:

Resolving patch:
diff --git a/arctic/generics.py b/arctic/generics.py
--- a/arctic/generics.py
+++ b/arctic/generics.py
@@ -130,45 +130,77 @@ def get_parent_ids(self):
         """
         return None
 
+    def ordering_url(self, field):
+        """
+        Creates a url link for sorting the given field, the direction of sorting
+        will be either ascending if the field is not yet sorted, or the
+        opposite of the current sorting if the field is sorted.
+        """
+
+        path = self.request.path
+        direction = ''
+        query_params = self.request.GET.copy()
+        ordering = self.request.GET.get('order', '').split(',')
+        if not ordering:
+            ordering = self.get_default_ordering()
+        merged_ordering = list(ordering) # copy the list
+
+        for ordering_field in self.ordering_fields:
+            if (ordering_field.lstrip('-') not in ordering) and \
+               (('-' + ordering_field.lstrip('-')) not in ordering):
+               merged_ordering.append(ordering_field)
+
+        new_ordering = []
+        for item in merged_ordering:
+            if item.lstrip('-') == field.lstrip('-'):
+                if (item[0] == '-') or not (item in ordering):
+                    if item in ordering:
+                        direction = 'desc'
+                    new_ordering.insert(0, item.lstrip('-'))
+                else:
+                    direction = 'asc'
+                    new_ordering.insert(0, '-' + item)
+
+        query_params['order'] = ','.join(new_ordering)
+
+        return (path + '?' + query_params.urlencode(safe=','), direction)
+
+
     def get_list_display(self):
+        """
+        Creates a list of dictionaries with the field names, labels,
+        column_links, widget classes, order_url and order_direction,
+        this simplifies the creation of a table in a template.
+        """
+
         model = self.object_list.model
         result = []
         if not self.list_display:
-            result.append(('', str(model._meta.verbose_name)))
+            result.append({
+                'name': '',
+                'verbose': str(model._meta.verbose_name),
+            })
         else:
             prefix = self.get_prefix()
             for field_name in self.list_display:
+                item = {}
                 if isinstance(field_name, tuple):
                     # custom property that is not a field of the model
-                    name = prefix + field_name[0]
-                    verbose = field_name[1]
+                    item['name'] = prefix + field_name[0]
+                    item['label'] = field_name[1]
                 else:
-                    name = prefix + field_name
-                    verbose = model._meta.get_field(field_name).verbose_name
-                result.append((name, verbose))
+                    item['name'] = prefix + field_name
+                    item['label'] = model._meta.get_field(field_name).verbose_name
+                if item['name'] in self.column_links.keys():
+                    item['column_link'] = self.column_links[item['name']]
+                if item['name'] in self.column_widgets.keys():
+                    item['widget'] = self.column_widgets[item['name']]
+                if item['name'] in self.ordering_fields:
+                    item['order_url'], item['order_direction'] = self.ordering_url(item['name'])
+                result.append(item)
 
         return result
 
-    # common method to be used for column_links and column_widgets
-    def _get_column_items(self, column_items):
-        result = {}
-        list_display = list(OrderedDict(self.get_list_display()).keys())
-        for key, value in column_items.items():
-            try:
-                result[list_display.index(key)] = value
-            except ValueError:
-                pass
-
-        return result
-
-
-    def get_column_links(self):
-        return self._get_column_items(self.column_links)
-
-
-    def get_column_widgets(self):
-        return self._get_column_items(self.column_widgets)
-
 
     def get_list_items(self, objects):
         items = []
@@ -232,10 +264,6 @@ def get_tool_links(self):
     def get_prefix(self):
         return self.prefix + '-' if self.prefix else ''
 
-    def get_ordering_fields(self):
-        prefix = self.get_prefix()
-        return [prefix + f for f in self.ordering_fields]
-
     def get_default_ordering(self):
         prefix = self.get_prefix()
         return [prefix + f for f in self.default_ordering]
@@ -289,15 +317,8 @@ def get_context_data(self, **kwargs):
         context['list_header'] = self.get_list_display()
         context['list_items'] = self.get_list_items(context['object_list'])
         context['list_display_links'] = self.get_list_display_links()
-        context['column_links'] = self.get_column_links()
-        context['column_widgets'] = self.get_column_widgets()
         context['tool_links'] = self.get_tool_links()
         context['parent_ids'] = self.get_parent_ids()
-        context['ordering_fields'] = self.get_ordering_fields()
-        context['ordering'] = {
-            f.lstrip('-'): 'desc' if f.startswith('-') else 'asc'
-            for f in self.get_ordering_with_prefix()
-        }
         if self.list_filter or self.search_fields:
             context['has_filter'] = True
             context['filter'] = self.filterset
diff --git a/arctic/templatetags/arctic_tags.py b/arctic/templatetags/arctic_tags.py
--- a/arctic/templatetags/arctic_tags.py
+++ b/arctic/templatetags/arctic_tags.py
@@ -2,6 +2,8 @@
 from django import template
 from django.core.urlresolvers import reverse
 
+from collections import OrderedDict
+
 register = template.Library()
 
 
@@ -198,6 +200,7 @@ def subview(parser, token):
 def lookup(dct, key):
     return dct.get(key)
 
+
 @register.filter()
 def typename(obj):
     return type(obj).__name__
@@ -207,6 +210,14 @@ def typename(obj):
 def index(List, i):
     return List[int(i)]
 
+
+@register.filter
+def keys(obj):
+    if type(obj) in (dict, OrderedDict,):
+        return list(obj.keys())
+    return []
+
+
 @register.filter
 def get_item(dictionary, key):
     return dictionary.get(key)
diff --git a/example/articles/views.py b/example/articles/views.py
--- a/example/articles/views.py
+++ b/example/articles/views.py
@@ -25,6 +25,7 @@ class ArticleListView(ListView):
     paginate_by = 20
     model = Article
     list_filter = []
+    ordering_fields = ['title', 'description']
     search_fields = ['title']
     list_display = ['title', 'description']
     list_display_links = [


Test patch:
diff --git a/arctic/static/arctic/build/components/Snap.svg/test.html b/arctic/static/arctic/build/components/Snap.svg/test.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/basic.html b/arctic/static/arctic/build/components/modernizr/test/basic.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse.html b/arctic/static/arctic/build/components/modernizr/test/caniuse.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.eot b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.eot
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.otf b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.otf
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.svg b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.svg
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.ttf b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.ttf
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.woff b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/Windsong-webfont.woff
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/alpha.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/alpha.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/apng_test.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/apng_test.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/before-after.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/before-after.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/form_validation.html b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/form_validation.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/ga.js b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/ga.js
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/green5x5.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/green5x5.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/hashchange.html b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/hashchange.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/jquery.min.js b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/jquery.min.js
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/mathml.html b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/mathml.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/mathml_ref.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/mathml_ref.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/modernizr-1.7.min.js b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/modernizr-1.7.min.js
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/png_alpha_result.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/png_alpha_result.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/pushstate.html b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/pushstate.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/red30x30.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/red30x30.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/ruby.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/ruby.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/stroked-text.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/stroked-text.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/style.css b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/style.css
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/svg-html-blur.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/svg-html-blur.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/svg-img.svg b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/svg-img.svg
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/svg-img.svg.1 b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/svg-img.svg.1
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/svg_blur.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/svg_blur.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/table.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/table.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/text-shadow1.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/text-shadow1.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/text-shadow2.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/text-shadow2.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/windsong_font.png b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/windsong_font.png
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/caniuse_files/xhtml.html b/arctic/static/arctic/build/components/modernizr/test/caniuse_files/xhtml.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/index.html b/arctic/static/arctic/build/components/modernizr/test/index.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/js/basic.html b/arctic/static/arctic/build/components/modernizr/test/js/basic.html
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/js/dumpdata.js b/arctic/static/arctic/build/components/modernizr/test/js/dumpdata.js
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/js/setup.js b/arctic/static/arctic/build/components/modernizr/test/js/setup.js
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/js/unit-caniuse.js b/arctic/static/arctic/build/components/modernizr/test/js/unit-caniuse.js
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/js/unit.js b/arctic/static/arctic/build/components/modernizr/test/js/unit.js
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/qunit/qunit.css b/arctic/static/arctic/build/components/modernizr/test/qunit/qunit.css
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/qunit/qunit.js b/arctic/static/arctic/build/components/modernizr/test/qunit/qunit.js
old mode 100755
new mode 100644
diff --git a/arctic/static/arctic/build/components/modernizr/test/qunit/run-qunit.js b/arctic/static/arctic/build/components/modernizr/test/qunit/run-qunit.js
old mode 100755
new mode 100644