Beispiel #1
0
 def url_components(self, name, **kwargs):
     kwargs.update({
         'play': self.play.slug,
         'play_id': int_to_base32(self.play.id),
         'production_id': int_to_base32(self.id),
     })
     return reverse(name, kwargs=kwargs)
Beispiel #2
0
 def url_components(self, name, **kwargs):
     kwargs.update({
         'play': self.play.slug,
         'play_id': int_to_base32(self.play.id),
         'production_id': int_to_base32(self.id),
     })
     return reverse(name, kwargs=kwargs)
Beispiel #3
0
def merge(request, url):
    try:
        splits = url.split('/', 2)
        if len(splits) == 2:
            splits.append(None)
        type, id, slug = splits
        if type == 'production' and slug == 'merge':
            slug = None
    except ValueError:
        raise Exception(url)

    if type in type_dict:
        obj_type = type_dict[type]
    else:
        raise Http404

    try:
        object = check_url(obj_type, id, slug)
    except UnmatchingSlugException as e:
        return HttpResponseRedirect(e.args[0].get_absolute_url() + "/merge")

    if request.POST.get('stop'):
        if 'merging_' + type in request.session:
            del request.session['merging_' + type]
        if not request.session.keys():
            request.session.flush()
        if request.user.is_authenticated:
            messages.success(request, u"We have forgotten your search for a duplicate.")
        return HttpResponseRedirect(object.get_absolute_url())

    if request.POST.get('dupe') and request.session.get('merging_' + type):
        # Send email
        other_id = request.session['merging_' + type]['id']
        other = obj_type.objects.get(id=other_id)
        mail_admins(
            'Merge request',
            u'%s\nand\n%s\n\n%s : https://theatricalia.com%s\n%s : https://theatricalia.com%s\n\nRequest made by: %s\n\nATB,\nMatthew' % (
                other, object, int_to_base32(other.id), other.get_absolute_url(),
                int_to_base32(object.id), object.get_absolute_url(), request.user),
            fail_silently=True
        )
        del request.session['merging_' + type]
        return render(request, 'merged/thanks.html', {
            'object': object,
            'other': other,
        })

    request.session['merging_' + type] = {
        'id': object.id,
        'name': str(object),
    }

    return render(request, 'merged/start.html', {
        'object': object,
    })
Beispiel #4
0
 def send_email(self, email_template):
     self.save()
     send_email(
         "Alert confirmation", email_template, {
             'object': self.content_object,
             'id': int_to_base32(self.id),
             'token': self.make_token(random.randint(0, 32767)),
         }, self.content_object.email)
Beispiel #5
0
def send_confirmation_email(request, user):
    send_email(
        request, "Theatricalia account confirmation",
        'registration/confirmation-email.txt', {
            'email': user.email,
            'uid': int_to_base32(user.id),
            'user': user,
            'token': default_token_generator.make_token(user),
            'protocol': 'http',
        }, user.email)
Beispiel #6
0
 def send_email(self, request, email_template):
     self.save()
     send_email(request, "Alert confirmation",
         email_template,
         {
             'object': self.content_object,
             'id': int_to_base32(self.id),
             'token': self.make_token(random.randint(0,32767)),
         }, self.content_object.email
     )
Beispiel #7
0
def send_confirmation_email(request, user):
    send_email(request, "Theatricalia account confirmation",
        'registration/confirmation-email.txt',
        {
            'email': user.email,
            'uid': int_to_base32(user.id),
            'user': user,
            'token': default_token_generator.make_token(user),
            'protocol': 'http',
        }, user.email
    )
Beispiel #8
0
def person_js(request, person_id, person):
    try:
        person = check_url(Person, person_id, person)
    except UnmatchingSlugException as e:
        return HttpResponsePermanentRedirect(e.args[0].get_absolute_url())
    plays = person.plays.all()

    past = [{
        'id': int_to_base32(p.id),
        'desc': str(p)
    } for p in productions_past(person, '')]
    future = [{
        'id': int_to_base32(p.id),
        'desc': str(p)
    } for p in productions_future(person, '')]
    plays = [{
        'id': int_to_base32(p.id),
        'title': str(p)
    } for p in person.plays.all()]
    person = {
        'id': int_to_base32(person.id),
        'first_name': person.first_name,
        'last_name': person.last_name,
        'slug': person.slug,
        'bio': person.bio,
        'dob': person.dob,
        'died': person.died,
        'web': person.web,
        'imdb': person.imdb,
        'musicbrainz': person.musicbrainz,
        'openplaques': person.openplaques,
    }
    out = {
        'person': person,
        'past': past,
        'future': future,
        'plays': plays,
    }
    response = HttpResponse(content_type='application/json')
    json.dump(out, response, ensure_ascii=False)
    return response
Beispiel #9
0
import os, sys
sys.path.insert(0, '../..')
sys.path.insert(0, '..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'theatricalia.settings'

import re
from plays.models import Play
from utils import int_to_base32

plays = Play.objects.filter(title__istartswith='NT 2000: ')

for p in plays:
    without = p.title.replace('NT 2000: ', '')
    without = re.sub('^(A|An|The) (.*)', r'\2, \1', without)
    matches = Play.objects.filter(title=without)
    if len(matches)==1 and list(p.authors.all()) != list(matches[0].authors.all()):
        print int_to_base32(matches[0].id), int_to_base32(p.id), '|', matches[0].title, ' = ', p.title
        print '  ', p.authors.all()[0].id, matches[0].authors.all()[0].id
Beispiel #10
0
        return HttpResponseRedirect(e.args[0].get_absolute_url() + "/merge")
    except:
        raise Exception

    if request.POST.get('stop'):
        if 'merging_' + type in request.session:
            del request.session['merging_' + type]
        if request.user.is_authenticated():
            messages.success(request, u"We have forgotten your search for a duplicate.")
        return HttpResponseRedirect(object.get_absolute_url())

    if request.POST.get('dupe') and request.session.get('merging_' + type):
        # Send email
        other_id = request.session['merging_' + type]['id']
        other = obj_type.objects.get(id=other_id)
        mail_admins('Merge request', '%s\nand\n%s\n\n%s : http://theatricalia.com%s\n%s : http://theatricalia.com%s\n\nRequest made by: %s\n\nATB,\nMatthew' % (other, object, int_to_base32(other.id), other.get_absolute_url(), int_to_base32(object.id), object.get_absolute_url(), request.user), fail_silently=True)
        del request.session['merging_' + type]
        return render(request, 'merged/thanks.html', {
            'object': object,
            'other': other,
        })

    request.session['merging_' + type] = {
        'id': object.id,
        'name': unicode(object),
    }

    return render(request, 'merged/start.html', {
        'object': object,
    })
Beispiel #11
0
 def get_absolute_url(self):
     return reverse('photo-view',
                    kwargs={'photo_id': int_to_base32(self.id)})
Beispiel #12
0
 def construct_url(self, name, *args):
     return (name, (int_to_base32(self.id), self.slug) + args)
Beispiel #13
0
 def make_token(self, rand):
     rand = int_to_base32(rand)
     hash = hmac.new(settings.SECRET_KEY, unicode(self.id) + rand, hashlib.sha1).hexdigest()[::2]
     return "%s-%s" % (rand, hash)
Beispiel #14
0
 def construct_url(self, name, *args):
     return reverse(name, args=(int_to_base32(self.id), self.slug) + args)
Beispiel #15
0
 def id32(self):
     return int_to_base32(self.id)
Beispiel #16
0
 def id32(self):
     return int_to_base32(self.id)
Beispiel #17
0
 def construct_url(self, name, *args):
     return reverse(name, args=(int_to_base32(self.id), self.slug) + args)
Beispiel #18
0
 def get_absolute_url(self):
     return ('photo-view', (), { 'photo_id': int_to_base32(self.id) })
Beispiel #19
0
 def path_for_unsubscribe(self):
     return reverse('emailconfirmation-unsubscribe', kwargs={
         'id': int_to_base32(self.id),
         'token': self.make_token(random.randint(0,32767)),
     })
Beispiel #20
0
        'future': future,
        'plays': plays,
        'photo_form': photo_form,
        'flickr': flickr,
        'alert': alert,
        'same_name': same_name,
    })

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

    past   = [ {'id': int_to_base32(p.id), 'desc': unicode(p) } for p in productions_past(person, '') ]
    future = [ {'id': int_to_base32(p.id), 'desc': unicode(p) } for p in productions_future(person, '') ]
    plays  = [ {'id': int_to_base32(p.id), 'title': unicode(p) } for p in person.plays.all() ]
    person = {
        'id': int_to_base32(person.id),
        'first_name': person.first_name,
        'last_name': person.last_name,
        'slug': person.slug,
        'bio': person.bio,
        'dob': person.dob,
        'died': person.died,
        'web': person.web,
        'imdb': person.imdb,
        'musicbrainz': person.musicbrainz,
        'openplaques': person.openplaques,
    }
Beispiel #21
0
 def get_absolute_url(self):
     return reverse('photo-view', kwargs={ 'photo_id': int_to_base32(self.id) })