# -*- coding: utf-8 -*-
from django.db import models
from place import Place
from django.contrib.auth.models import User
from math import exp


class AveragePlaceManager(models.Manager):

    def for_map(self, map_places):
        return self.filter(
            place__in=map_places,
        ).select_related('place').order_by('place__name')

    def from_place(self, place):
        try:
            average_place = self.get(place=place)
        except AveragePlace.DoesNotExist:
            average_place = AveragePlace(
                place=place,
            )
        return average_place


class AveragePlace(models.Model):

    dummy_id = models.CharField(primary_key=True, max_length=40)
    place = models.ForeignKey(Place, on_delete=models.DO_NOTHING)
    elo_skill = models.FloatField(default=0)

    objects = AveragePlaceManager()

    def to_serializable(self):
        ret = self.place.to_serializable()
        ret.update({
            'skill': self.elo_skill,
            'probability': 1.0 / (1 + exp(self.elo_skill)),
            'certainty': 1
        })
        return ret

    class Meta:
        app_label = 'geography'
        managed = False

    """ READ ONLY MODEL """
    def save(self, **kwargs):
        raise NotImplementedError

@@ -74,52 +74,8 @@
 ace%0A
-from django.contrib.auth.models import User%0A
 from

remove unused import