Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christopher M Reffett
whats-open
Commits
2445573f
Commit
2445573f
authored
Mar 23, 2013
by
Daniel Bond
Browse files
alphabetized
parent
daff625b
Changes
3
Hide whitespace changes
Inline
Side-by-side
website/api.py
View file @
2445573f
from
website.models
import
Restaurant
import
re
def
export_data
():
restaurants
=
list
()
for
restaurant
in
Restaurant
.
objects
.
all
():
# Sort the restaurants by alphabetical order ignoring "the" and "a"
alphalist
=
sorted
(
Restaurant
.
objects
.
all
(),
key
=
lambda
r
:
re
.
sub
(
'^(the|a) '
,
''
,
r
.
name
,
count
=
1
,
flags
=
re
.
IGNORECASE
))
for
restaurant
in
alphalist
:
restaurant_data
=
{
'name'
:
restaurant
.
name
,
'id'
:
restaurant
.
id
}
open_times
=
list
()
for
time
in
restaurant
.
main_schedule
.
open_times
.
all
():
...
...
website/views.py
View file @
2445573f
...
...
@@ -4,7 +4,6 @@ from website.api import export_data
from
django.shortcuts
import
render_to_response
from
django.http
import
HttpResponse
from
django.views.decorators.http
import
condition
import
re
import
hashlib
import
json
...
...
@@ -15,15 +14,7 @@ def restaurant_grid(request):
if
request
.
GET
[
'sort'
]
==
'location'
:
# Display the grid by location (instead of listing alphabetically)
pass
# Not implemented yet
restaurants
=
Restaurant
.
objects
.
all
()
# Sort the restaurants by alphabetical order ignoring "the" and "a"
restaurants
=
sorted
(
restaurants
,
key
=
lambda
r
:
re
.
sub
(
'^(the|a) '
,
''
,
r
.
name
,
count
=
1
,
flags
=
re
.
IGNORECASE
))
# Restaurants in lists of 4 to easily create rows in template
restRows
=
[
restaurants
[
x
:
x
+
4
]
for
x
in
xrange
(
0
,
len
(
restaurants
),
4
)]
return
render_to_response
(
'restaurant_grid.html'
,
{
'restRows'
:
restRows
,
'restaurants'
:
restaurants
},
return
render_to_response
(
'restaurant_grid.html'
,
context_instance
=
RequestContext
(
request
))
def
gen_etag
(
request
):
...
...
whats_open/templates/base.html
View file @
2445573f
...
...
@@ -37,7 +37,8 @@
</div>
<div
class =
clock
>
at {% now "H:i" %}
<!--All nice and static... this will too will likely be changing soon. -->
<!-- this is in 24 hour time :-/ -->
</div>
<div
class=
"row"
>
<div
class=
"span6 offset5"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment