<commit_before>from tastypie.resources import ModelResource
from tastypie import fields, utils
from tastypie.authentication import BasicAuthentication
from tastypie.authorization import DjangoAuthorization

from .models import Project, IdeaPhase, PlanPhase, ActPhase, ResultsPhase


class ProjectResource(ModelResource):
#    ideaphase = fields.OneToOneField(
#                 'apps.projects.api.IdeaPhaseResource', 'ideaphase', full=True)
#    planphase = fields.OneToOneField(
#                 'projects.api.PlanPhaseResource', 'planphase', full=False)
#    actphase = fields.OneToOneField(
#                'projects.api.ActPhaseResource', 'actphase', full=False)
#    resultsphase = fields.OneToOneField(
#                'projects.api.ResultsPhaseResource', 'resultsphase', full=False)

    class Meta:
        queryset = Project.objects.select_related('IdeaPhase').filter(phase='plan').all()
        authentication = BasicAuthentication()
        authorization = DjangoAuthorization()


class IdeaPhaseResource(ModelResource):
    project = fields.OneToOneField(ProjectResource, 'project')

    class Meta:
        queryset = IdeaPhase.objects.select_related('IdeaPhase').all()
        authentication = BasicAuthentication()
        authorization = DjangoAuthorization()


class PlanPhaseResource(ModelResource):
    project = fields.OneToOneField(ProjectResource, 'project')

    class Meta:
        queryset = PlanPhase.objects.all()
        authentication = BasicAuthentication()
        authorization = DjangoAuthorization()


class ActPhaseResource(ModelResource):
    project = fields.OneToOneField(ProjectResource, 'project')

    class Meta:
        queryset = ActPhase.objects.all()
        authentication = BasicAuthentication()
        authorization = DjangoAuthorization()


class ResultsPhaseResource(ModelResource):
    project = fields.OneToOneField(ProjectResource, 'project')

    class Meta:
        queryset = ResultsPhase.objects.all()
        authentication = BasicAuthentication()
        authorization = DjangoAuthorization()

<commit_msg>Changed API so we don't do authentication yet, but make project api read only. Also added filters so we can filter on lat-long<commit_after>from tastypie.resources import ModelResource
from tastypie import fields, utils
from tastypie.authorization import DjangoAuthorization

from .models import Project, IdeaPhase, PlanPhase, ActPhase, ResultsPhase

class ResourceBase(ModelResource):
    class Meta:
        authorization = DjangoAuthorization()
        list_allowed_methods = ['get']
        detail_allowed_methods = ['get']



class ProjectResource(ResourceBase):
#    ideaphase = fields.OneToOneField(
#                 'apps.projects.api.IdeaPhaseResource', 'ideaphase', full=True)
#    planphase = fields.OneToOneField(
#                 'projects.api.PlanPhaseResource', 'planphase', full=False)
#    actphase = fields.OneToOneField(
#                'projects.api.ActPhaseResource', 'actphase', full=False)
#    resultsphase = fields.OneToOneField(
#                'projects.api.ResultsPhaseResource', 'resultsphase', full=False)

    class Meta:
        queryset = Project.objects.filter(phase='plan').all()
        filtering = {
             "latitude": ('gte', 'lte'),
             "longitude": ('gte', 'lte'),
             "title": ('startswith', 'contains')
        }

class IdeaPhaseResource(ResourceBase):
    project = fields.OneToOneField(ProjectResource, 'project')

    class Meta:
        queryset = IdeaPhase.objects.select_related('IdeaPhase').all()


class PlanPhaseResource(ResourceBase):
    project = fields.OneToOneField(ProjectResource, 'project')

    class Meta:
        queryset = PlanPhase.objects.all()


class ActPhaseResource(ResourceBase):
    project = fields.OneToOneField(ProjectResource, 'project')

    class Meta:
        queryset = ActPhase.objects.all()


class ResultsPhaseResource(ResourceBase):
    project = fields.OneToOneField(ProjectResource, 'project')

    class Meta:
        queryset = ResultsPhase.objects.all()


{'fraction_non_alphanumeric': 0.09997525365008661, 'fraction_numerical': 0.0, 'mean_word_length': 3.7164527421236873, 'pattern_counts': {'":': 3, '<': 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': '7108524', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1055, 'n_words': 232}