Quellcode durchsuchen

Withdraw changes for autocompleting category fullpath in the category form

master
Asia Biega vor 13 Jahren
Ursprung
Commit
24535ab84a

+ 0
- 3
oscar/apps/dashboard/catalogue/app.py Datei anzeigen

46
                 name='catalogue-category-create'),
46
                 name='catalogue-category-create'),
47
             url(r'^categories/update/(?P<pk>\d+)/$', self.category_update_view.as_view(),
47
             url(r'^categories/update/(?P<pk>\d+)/$', self.category_update_view.as_view(),
48
                 name='catalogue-category-update'),
48
                 name='catalogue-category-update'),
49
-
50
-            url(r'^categories-autocomplete/$', views.category_autocomplete,
51
-                name='catalogue-category-autocomplete'),
52
         )
49
         )
53
         return self.post_process_urls(urlpatterns)
50
         return self.post_process_urls(urlpatterns)
54
 
51
 

+ 0
- 27
oscar/apps/dashboard/catalogue/forms.py Datei anzeigen

1
 from django import forms
1
 from django import forms
2
 from django.forms.models import inlineformset_factory
2
 from django.forms.models import inlineformset_factory
3
 from django.db.models import get_model
3
 from django.db.models import get_model
4
-from django.utils.translation import ugettext as _
5
 
4
 
6
 from treebeard.forms import MoveNodeForm
5
 from treebeard.forms import MoveNodeForm
7
 
6
 
15
 
14
 
16
 class CategoryForm(MoveNodeForm):
15
 class CategoryForm(MoveNodeForm):
17
 
16
 
18
-    _ref_node_id = forms.CharField(required=False,
19
-                                   label=_(u"Relative to (category)"))
20
-
21
-    def __init__(self, *args, **kwargs):
22
-        super(CategoryForm, self).__init__(*args, **kwargs)
23
-        if self.initial:
24
-            ref_pk = self.initial['_ref_node_id']
25
-            if ref_pk:
26
-                try:
27
-                    c = Category.objects.get(pk=ref_pk)
28
-                except Category.DoesNotExist:
29
-                    self.initial['_ref_node_id'] = ''
30
-                else:
31
-                    self.initial['_ref_node_id'] = c.full_name
32
-
33
-    def clean__ref_node_id(self):
34
-        cd = self.cleaned_data
35
-        if '_ref_node_id' in cd and cd['_ref_node_id']:
36
-            try:
37
-                c = Category.objects.get(full_name=cd['_ref_node_id'])
38
-            except Category.DoesNotExist:
39
-                raise forms.ValidationError(_('The specified category does not exist'))
40
-            else:
41
-                cd['_ref_node_id'] = c.pk
42
-        return cd['_ref_node_id']
43
-
44
     class Meta(MoveNodeForm.Meta):
17
     class Meta(MoveNodeForm.Meta):
45
         model = Category
18
         model = Category
46
 
19
 

+ 1
- 10
oscar/apps/dashboard/catalogue/views.py Datei anzeigen

1
 from django.views import generic
1
 from django.views import generic
2
 from django.db.models import get_model
2
 from django.db.models import get_model
3
-from django.http import HttpResponseRedirect, HttpResponse
3
+from django.http import HttpResponseRedirect
4
 from django.contrib import messages
4
 from django.contrib import messages
5
 from django.core.urlresolvers import reverse
5
 from django.core.urlresolvers import reverse
6
 
6
 
7
 from oscar.apps.dashboard.catalogue import forms
7
 from oscar.apps.dashboard.catalogue import forms
8
 from oscar.core.loading import get_classes
8
 from oscar.core.loading import get_classes
9
 
9
 
10
-import simplejson
11
-
12
 ProductForm, CategoryForm, StockRecordForm, StockAlertSearchForm, ProductCategoryFormSet, ProductImageFormSet = get_classes(
10
 ProductForm, CategoryForm, StockRecordForm, StockAlertSearchForm, ProductCategoryFormSet, ProductImageFormSet = get_classes(
13
     'dashboard.catalogue.forms', ('ProductForm', 'CategoryForm', 'StockRecordForm',
11
     'dashboard.catalogue.forms', ('ProductForm', 'CategoryForm', 'StockRecordForm',
14
                                   'StockAlertSearchForm',
12
                                   'StockAlertSearchForm',
281
         else:
279
         else:
282
             return reverse("dashboard:catalogue-category-detail-list", 
280
             return reverse("dashboard:catalogue-category-detail-list", 
283
                             args=(parent.pk,))
281
                             args=(parent.pk,))
284
-
285
-
286
-def category_autocomplete(request):
287
-    q = request.GET.get('term', '')
288
-    categories =Category.objects.filter(full_name__icontains=q)
289
-    result = [c.full_name for c in categories]
290
-    return HttpResponse(simplejson.dumps(result))

+ 0
- 12
oscar/static/oscar/js/oscar/dashboard.js Datei anzeigen

85
                 }
85
                 }
86
             );
86
             );
87
         }
87
         }
88
-    },
89
-    catalogue: {
90
-        init: function() {
91
-        },
92
-        category_autocomplete: function(url) {
93
-            return function () {
94
-                $("#id__ref_node_id").autocomplete({
95
-                    'source': url,
96
-                    'minLength': 3,
97
-                });
98
-            }
99
-        }
100
     }
88
     }
101
 };
89
 };
102
 
90
 

+ 0
- 7
oscar/templates/dashboard/catalogue/category_create.html Datei anzeigen

2
 {% load category_tags %}
2
 {% load category_tags %}
3
 {% block body_class %}catalogue{% endblock %}
3
 {% block body_class %}catalogue{% endblock %}
4
 
4
 
5
-{% block extrascripts %}
6
-    {{ block.super }}
7
-    <script type="text/javascript">
8
-        $(oscar.dashboard.catalogue.category_autocomplete("{% url dashboard:catalogue-category-autocomplete %}"));
9
-    </script>
10
-{% endblock %}
11
-
12
 {% block title %}
5
 {% block title %}
13
 Category management | {{ block.super }}
6
 Category management | {{ block.super }}
14
 {% endblock %}
7
 {% endblock %}

+ 0
- 7
oscar/templates/dashboard/catalogue/category_list.html Datei anzeigen

2
 {% load category_tags %}
2
 {% load category_tags %}
3
 {% block body_class %}catalogue{% endblock %}
3
 {% block body_class %}catalogue{% endblock %}
4
 
4
 
5
-{% block extrascripts %}
6
-    {{ block.super }}
7
-    <script src="{{ STATIC_URL }}oscar/js/jquery/jquery-ui-1.8.21.custom.min.js" type="text/javascript" charset="utf-8"></script>
8
-    <script src="{{ STATIC_URL }}oscar/js/sortable/jquery.ui.nestedSortable.js" type="text/javascript" charset="utf-8"></script>
9
-    <script type="text/javascript">$(oscar.dashboard.catalogue.init);</script>
10
-{% endblock %}
11
-
12
 {% block title %}
5
 {% block title %}
13
 Category management | {{ block.super }}
6
 Category management | {{ block.super }}
14
 {% endblock %}
7
 {% endblock %}

+ 1
- 1
oscar/templates/dashboard/layout.html Datei anzeigen

82
     {{ block.super }}
82
     {{ block.super }}
83
     <script src="{{ STATIC_URL }}oscar/js/oscar/ui.js" type="text/javascript" charset="utf-8"></script>
83
     <script src="{{ STATIC_URL }}oscar/js/oscar/ui.js" type="text/javascript" charset="utf-8"></script>
84
     <script src="{{ STATIC_URL }}oscar/js/oscar/dashboard.js" type="text/javascript" charset="utf-8"></script>
84
     <script src="{{ STATIC_URL }}oscar/js/oscar/dashboard.js" type="text/javascript" charset="utf-8"></script>
85
-    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
85
+    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>
86
 	<script type="text/javascript">$(oscar.dashboard.init);</script>
86
 	<script type="text/javascript">$(oscar.dashboard.init);</script>
87
 {% endblock %}
87
 {% endblock %}

+ 0
- 1
requirements.txt Datei anzeigen

14
 South==0.7.3
14
 South==0.7.3
15
 purl==0.3.2
15
 purl==0.3.2
16
 django-sorting==0.1
16
 django-sorting==0.1
17
-simplejson==2.5.2

+ 0
- 1
setup.py Datei anzeigen

34
           'sorl-thumbnail==11.12',
34
           'sorl-thumbnail==11.12',
35
           'python-memcached==1.48',
35
           'python-memcached==1.48',
36
           'django-sorting==0.1',
36
           'django-sorting==0.1',
37
-          'simplejson==2.5.2',
38
           ],
37
           ],
39
       # See http://pypi.python.org/pypi?%3Aaction=list_classifiers
38
       # See http://pypi.python.org/pypi?%3Aaction=list_classifiers
40
       classifiers=['Environment :: Web Environment',
39
       classifiers=['Environment :: Web Environment',

Laden…
Abbrechen
Speichern