Esempio n. 1
0
def person_productions(request, person_id, person, type):
    try:
        person = check_url(Person, person_id, person)
    except UnmatchingSlugException as e:
        return HttpResponsePermanentRedirect(e.args[0].get_absolute_url())
    return productions_list(request, person, type,
                            'people/production_list.html')
Esempio n. 2
0
def play_productions(request, play_id, play, type):
    try:
        play = check_url(Play, play_id, play)
    except UnmatchingSlugException as e:
        if type == 'future':
            url = e.args[0].get_future_url()
        elif type == 'past':
            url = e.args[0].get_past_url()
        return HttpResponsePermanentRedirect(url)
    return productions_list(request, play, type, 'plays/production_list.html')
Esempio n. 3
0
def search_around(request, s, type=''):
    s = s.strip()
    m = re.match(r'([-\d.]+)\s*,\s*([-\d.]+)$', s)

    if m:
        lat, lon = m.groups()
        name = request.GET.get('name', '')
    elif validate_postcode(s):
        try:
            r = urllib.request.urlopen(
                'https://mapit.mysociety.org/postcode/%s' %
                urllib.parse.quote(s)).read()
            loc = json.loads(r)
            lat, lon = loc['wgs84_lat'], loc['wgs84_lon']
            name = re.sub(r'(\d[A-Z]{2})', r' \1', s.upper())
        except:
            return search(request, redirect_okay=False)
    elif validate_partial_postcode(s):
        try:
            r = urllib.request.urlopen(
                'https://mapit.mysociety.org/postcode/partial/' +
                urllib.parse.quote(s)).read()
            r = json.loads(r)
            lat, lon = r['wgs84_lat'], r['wgs84_lon']
        except:
            return search(request, redirect_okay=False)
        name = s.upper()
    else:
        raise Http404()

    if not lat or not lon:
        return

    places = Place.objects.around(float(lat), float(lon))
    if not type:
        past, future = productions_for(places, 'places')
        alert = AlertLocal.objects.filter(user=request.user.id,
                                          latitude=lat,
                                          longitude=lon)
        return render(
            request, 'search-around.html', {
                'places': places,
                'past': past,
                'future': future,
                'lat': lat,
                'lon': lon,
                'latlon': '%s,%s' % (lat, lon),
                'name': name,
                'alert': alert,
            })
    return productions_list(request, places, type,
                            'search-around-productions.html', {
                                'lat': lat,
                                'lon': lon,
                            })
Esempio n. 4
0
def search_around(request, s, type=''):
    s = s.strip()
    m = re.match('([-\d.]+)\s*,\s*([-\d.]+)$', s)

    if m:
        lat, lon = m.groups()
        name = request.GET.get('name', '')
    elif validate_postcode(s):
        try:
            r = urllib.urlopen('http://mapit.mysociety.org/postcode/%s' % urllib.quote(s)).read()
            loc = simplejson.loads(r)
            pc, lat, lon = loc['postcode'], loc['wgs84_lat'], loc['wgs84_lon']
            name = re.sub('(\d[A-Z]{2})', r' \1', s.upper())
        except:
            return search(request, redirect_okay=False)
    elif validate_partial_postcode(s):
        try:
            r = urllib.urlopen('http://mapit.mysociety.org/postcode/partial/' + urllib.quote(s)).read()
            r = simplejson.loads(r)
            lat, lon = r['wgs84_lat'], r['wgs84_lon']
        except:
            return search(request, redirect_okay=False)
        name = s.upper()
    else:
        raise Exception, 'Bad request'

    if not lat or not lon:
        return

    places = Place.objects.around(float(lat), float(lon))
    if not type:
        past, future = productions_for(places, 'places')
        alert = AlertLocal.objects.filter(user=request.user.id, latitude=lat, longitude=lon)
        return render(request, 'search-around.html', {
            'places': places,
            'past': past,
            'future': future,
            'lat': lat,
            'lon': lon,
            'latlon': '%s,%s' % (lat, lon),
            'name': name,
            'alert': alert,
        })
    return productions_list(request, places, type, 'search-around-productions.html', {
        'lat': lat,
        'lon': lon,
    })
Esempio n. 5
0
from mixins import ListMixin

from shortcuts import check_url, UnmatchingSlugException
from utils import int_to_base32
from common.models import Alert
from models import Person
from forms import PersonEditForm
from photos.forms import PhotoForm
from productions.objshow import productions_list, productions_for, productions_past, productions_future

def person_productions(request, person_id, person, type):
    try:
        person = check_url(Person, person_id, person)
    except UnmatchingSlugException, e:
        return HttpResponsePermanentRedirect(e.args[0].get_absolute_url())
    return productions_list(request, person, type, 'people/production_list.html')

def person_short_url(request, person_id):
    try:
        person = check_url(Person, person_id)
    except UnmatchingSlugException, e:
        person = e.args[0]
    return HttpResponsePermanentRedirect(person.get_absolute_url())

def person(request, person_id, person):
    try:
        person = check_url(Person, person_id, person)
    except UnmatchingSlugException, e:
        return HttpResponsePermanentRedirect(e.args[0].get_absolute_url())

    #if person.productions.count() == 0:
Esempio n. 6
0
def search_parts(request, search):
    return productions_list(request, search, 'parts', 'search-parts.html')
Esempio n. 7
0
from people.models import Person
from photos.forms import PhotoForm

def place_short_url(request, place_id):
    try:
        place = check_url(Place, place_id)
    except UnmatchingSlugException, e:
        place = e.args[0]
    return HttpResponsePermanentRedirect(place.get_absolute_url())

def place_productions(request, place_id, place, type):
    try:
        place = check_url(Place, place_id, place)
    except UnmatchingSlugException, e:
        return HttpResponsePermanentRedirect(e.args[0].get_absolute_url())
    return productions_list(request, place, type, 'places/production_list.html')

def productions(request, place_id, place):
    try:
        place = check_url(Place, place_id, place)
    except UnmatchingSlugException, e:
        return HttpResponsePermanentRedirect(e.args[0].get_absolute_url())

    productions = Production.objects.filter(places=place).order_by('play__title').select_related('play')
    Production.objects.prefetch_companies(productions)
    Production.objects.prefetch_places(productions)

    return render(request, 'places/productions.html', {
        'productions': productions,
        'place': place,
    })
Esempio n. 8
0
def place_productions(request, place_id, place, type):
    try:
        place = check_url(Place, place_id, place)
    except UnmatchingSlugException as e:
        return HttpResponsePermanentRedirect(e.args[0].get_absolute_url())
    return productions_list(request, place, type, 'places/production_list.html')
Esempio n. 9
0
def search_parts(request, search):
    return productions_list(request, search, 'parts', 'search-parts.html')