mirror of
https://github.com/nikdoof/vapemap.git
synced 2025-12-14 14:52:16 +00:00
Various small PEP8 cleanups
This commit is contained in:
@@ -24,6 +24,7 @@ class ChainAdmin(admin.ModelAdmin):
|
||||
LinkInlineAdmin,
|
||||
]
|
||||
|
||||
|
||||
class StoreAdmin(admin.ModelAdmin):
|
||||
list_filter = ['chain', 'active']
|
||||
list_display = ['name', 'store_type', 'active', 'changed']
|
||||
@@ -63,7 +64,8 @@ class StoreAdmin(admin.ModelAdmin):
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
if not form:
|
||||
form = self.AddBrandForm(initial={'_selected_action': queryset.values_list('id', flat=True)})
|
||||
return render_to_response('admin/add_brand.html', {'stores': queryset, 'brand_form': form}, RequestContext(request))
|
||||
return render_to_response('admin/add_brand.html', {'stores': queryset, 'brand_form': form},
|
||||
RequestContext(request))
|
||||
|
||||
add_brand.short_description = "Add brand to the selected stores"
|
||||
|
||||
@@ -88,7 +90,8 @@ class StoreAdmin(admin.ModelAdmin):
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
if not form:
|
||||
form = self.SetChainForm(initial={'_selected_action': queryset.values_list('id', flat=True)})
|
||||
return render_to_response('admin/set_chain.html', {'stores': queryset, 'chain_form': form }, RequestContext(request))
|
||||
return render_to_response('admin/set_chain.html', {'stores': queryset, 'chain_form': form},
|
||||
RequestContext(request))
|
||||
|
||||
set_chain.short_description = "Set the selected store's chain"
|
||||
|
||||
@@ -98,7 +101,6 @@ class ClaimAdmin(admin.ModelAdmin):
|
||||
list_display = ['generic_obj', 'user', 'status', 'note']
|
||||
actions = ['approve_request']
|
||||
|
||||
|
||||
def approve_request(self, request, queryset):
|
||||
qs = queryset.filter(status=ClaimRequest.CLAIM_STATUS_PENDING)
|
||||
with transaction.commit_on_success():
|
||||
@@ -145,7 +147,8 @@ class CountyAdmin(admin.ModelAdmin):
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
if not form:
|
||||
form = self.SetCountryForm(initial={'_selected_action': queryset.values_list('id', flat=True)})
|
||||
return render_to_response('admin/set_country.html', {'stores': queryset, 'country_form': form}, RequestContext(request))
|
||||
return render_to_response('admin/set_country.html', {'stores': queryset, 'country_form': form},
|
||||
RequestContext(request))
|
||||
|
||||
set_country.short_description = "Set the selected county's country"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.forms.models import model_to_dict
|
||||
from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
|
||||
from tastypie.resources import ModelResource
|
||||
from stores.models import County, Country
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.contrib.sites.models import Site
|
||||
from .models import ClaimRequest, Store
|
||||
|
||||
|
||||
def site(request):
|
||||
return {
|
||||
'site': Site.objects.get_current()
|
||||
|
||||
@@ -40,7 +40,7 @@ class StoreForm(BootstrapModelForm):
|
||||
'long_description': 'input-xxlarge',
|
||||
}
|
||||
widgets = {
|
||||
'long_description': EpicEditorWidget(attrs={'rows': 40}, themes={'editor':'epic-light.css'})
|
||||
'long_description': EpicEditorWidget(attrs={'rows': 40}, themes={'editor': 'epic-light.css'})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ class Command(BaseCommand):
|
||||
help = 'Import a list of stores from CSV'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
file = args[0]
|
||||
if file.startswith('http'):
|
||||
self.stdout.write("Downloading %s\n" % file)
|
||||
f = StringIO(requests.get(file).text)
|
||||
fn = args[0]
|
||||
if fn.startswith('http'):
|
||||
self.stdout.write("Downloading %s\n" % fn)
|
||||
f = StringIO(requests.get(fn).text)
|
||||
else:
|
||||
self.stdout.write("Opening file %s\n" % file)
|
||||
f = open(file, 'r')
|
||||
self.stdout.write("Opening file %s\n" % fn)
|
||||
f = open(fn, 'r')
|
||||
|
||||
self.stdout.write('Formatting data...')
|
||||
# Generate the dataset
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.conf.urls import patterns, include, url
|
||||
from django.conf.urls import patterns, url
|
||||
from stores.views import *
|
||||
from stores.forms import AddressForm, StoreForm
|
||||
from stores.models import Store, Chain
|
||||
|
||||
@@ -34,7 +34,8 @@ class DistanceSearchView(ListView):
|
||||
return SearchQuerySet.none
|
||||
distance = self.get_distance()
|
||||
print location, distance
|
||||
return SearchQuerySet().dwithin('location', location, distance).distance('location', location).order_by('-distance')
|
||||
return SearchQuerySet().dwithin('location', location, distance)\
|
||||
.distance('location', location).order_by('-distance')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super(DistanceSearchView, self).get_context_data(**kwargs)
|
||||
|
||||
@@ -19,7 +19,7 @@ class StoreListView(HaystackSearchListMixin, ListView):
|
||||
if search:
|
||||
ctx.update({
|
||||
'search_query': search,
|
||||
})
|
||||
})
|
||||
return ctx
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -57,7 +57,7 @@ class StockistStoreListView(StoreListView):
|
||||
ctx = super(StockistStoreListView, self).get_context_data(**kwargs)
|
||||
ctx.update({
|
||||
'brand': self.brand,
|
||||
})
|
||||
})
|
||||
return ctx
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -70,7 +70,8 @@ class StoreDetailView(EditorCheckMixin, DetailView):
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super(StoreDetailView, self).get_queryset()
|
||||
return qs.filter(active=True).select_related('address', 'address__county', 'address__country', 'chain').prefetch_related('brands')
|
||||
return qs.filter(active=True).select_related('address', 'address__county', 'address__country', 'chain')\
|
||||
.prefetch_related('brands')
|
||||
|
||||
|
||||
class StoreUpdateView(UpdateView):
|
||||
@@ -98,7 +99,8 @@ class StoreCreateView(SessionWizardView):
|
||||
store_obj.active = False
|
||||
store_obj.save()
|
||||
|
||||
messages.success(self.request, "%s has been sumbitted for moderation and should be visible within the next 24 hours." % store_obj)
|
||||
messages.success(self.request, "%s has been sumbitted for moderation and should be visible within the "
|
||||
"next 24 hours." % store_obj)
|
||||
|
||||
return HttpResponseRedirect(reverse('map'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user