<commit_before>from django.shortcuts import render, redirect
from django.core.context_processors import csrf
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse
from django.core.urlresolvers import reverse
from rest_framework import viewsets
from django.core import serializers
from serializers import MarkerSerializer, TourSerializer
from django.contrib import messages
from Toury import models

def index(request):
    return render(request, 'Toury/index.html', None)

def tours(request):
    tours = models.Tour.objects.all()
    return render(request, 'Toury/tours.html', {'tours': tours})

def new_tour(request):
    newtour = models.Tour()
    newtour.name = request.POST['name']
    newtour.save()
    return redirect('Toury.views.tour', tour_id=newtour.id)

def delete(request, tour_id):
    #if request.method == 'POST':
    tour = models.Tour.objects.get(pk=tour_id)
    tour.delete()
    #else:
    #    messages.add_message(request, messages.ERROR, "Oops! You can't do that")
    return redirect('Toury.views.tours')

def create(request):
    return render(request, 'Toury/create.html', None)

@csrf_exempt
def tour(request, tour_id):
    tour = models.Tour.objects.get(pk=tour_id)

    if request.method == 'GET':
        if 'format' in request.GET:
                return HttpResponse(serializers.serialize('json', tour.markers.all()))

    if request.method == 'POST':
        m = models.Marker()
        m.tour = tour
        m.description = request.POST['description']
        # m.direction = request.POST['direction']
        m.trigger_latitude = request.POST['trigger_latitude']
        m.trigger_longitude = request.POST['trigger_longitude']
        m.marker_latitude = request.POST['marker_latitude']
        m.marker_longitude = request.POST['marker_longitude']
        m.radius = request.POST['radius']
        m.title = request.POST['title']
        m.save()
        return redirect('/tour/' + str(tour.id))

    return render(request, 'Toury/tour.html', {'tour': tour})

@csrf_exempt
def marker(request, marker_id):
    m = models.Marker.objects.get(pk=marker_id)<commit_msg>fix model bug<commit_after>from django.shortcuts import render, redirect
from django.core.context_processors import csrf
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse
from django.core.urlresolvers import reverse
from rest_framework import viewsets
from django.core import serializers
from serializers import MarkerSerializer, TourSerializer
from django.contrib import messages
from Toury import models

def index(request):
    return render(request, 'Toury/index.html', None)

def tours(request):
    tours = models.Tour.objects.all()
    return render(request, 'Toury/tours.html', {'tours': tours})

def new_tour(request):
    newtour = models.Tour()
    newtour.name = request.POST['name']
    newtour.save()
    return redirect('Toury.views.tour', tour_id=newtour.id)

def delete(request, tour_id):
    #if request.method == 'POST':
    tour = models.Tour.objects.get(pk=tour_id)
    tour.delete()
    #else:
    #    messages.add_message(request, messages.ERROR, "Oops! You can't do that")
    return redirect('Toury.views.tours')

def create(request):
    return render(request, 'Toury/create.html', None)

@csrf_exempt
def tour(request, tour_id):
    tour = models.Tour.objects.get(pk=tour_id)

    if request.method == 'GET':
        if 'format' in request.GET:
                return HttpResponse(serializers.serialize('json', tour.markers.all()))

    if request.method == 'POST':
        m = models.Marker()
        m.tour = tour
        m.description = request.POST['description']
        m.trigger_latitude = request.POST['trigger_latitude']
        m.trigger_longitude = request.POST['trigger_longitude']
        m.marker_latitude = request.POST['marker_latitude']
        m.marker_longitude = request.POST['marker_longitude']
        m.radius = request.POST['radius']
        m.title = request.POST['title']
        m.save()
        return redirect('/tour/' + str(tour.id))

    return render(request, 'Toury/tour.html', {'tour': tour})

@csrf_exempt
def marker(request, marker_id):
    m = models.Marker.objects.get(pk=marker_id)
{'fraction_non_alphanumeric': 0.12446758163748226, 'fraction_numerical': 0.0, 'mean_word_length': 3.776271186440678, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2075096', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1282, 'n_words': 291}