from django.conf.urls import patterns, url

from samples.models import Sample
from panelists.models import Panelist
from .rest_views import RestListBase, SamplesRestList, DeviceWithCalibrationSetRest
from .rest_views import IncompleteMeasurements, PostMeasurement, PostNewRounds, PutMeasurement
from .serializers import AllSamplesSerializer, PanelistsSerializer
from .certificates import CertificateRestReport, ProjectWithClientListView

# web api itself is mostly used by the control sw

urlpatterns = patterns('',

                       # used by control sw
                       url(regex=r'^panelists/$',
                           view=RestListBase.as_view(model=Panelist, serializer_class=PanelistsSerializer),
                           name='panelists_rest_list'),

                       # used by control sw
                       url(regex=r'^allsamples/$',
                           view=SamplesRestList.as_view(model=Sample, serializer_class=AllSamplesSerializer),
                           name='samples_rest_list'),

                       # control sw only
                       url(regex=r'^deviceswithcalib/$',
                           view=DeviceWithCalibrationSetRest.as_view()),

                       url(regex=r'^im/$',
                           view=IncompleteMeasurements.as_view()),

                       # save new measurements
                       url(r'^postmeasurement/$',
                           PostMeasurement.as_view()),

                       # update measurements (existing parts)
                       url(r'^putmeasurement/(?P<pk>\d+)/$',
                           PutMeasurement.as_view()),

                       # add new rounds to an existing measurement
                       url(r'^postnewrounds/$',
                           PostNewRounds.as_view()),

                       # one request fits all json stuff for external cert generation
                       url(regex=r'^rest_report/(?P<pk>\d+)/$',
                           view=CertificateRestReport.as_view(),
                           name='cert_rest'),

                       # plain project list, as part of a preselection step for external certificate generation
                       url(regex=r'^project_list/$',
                           view=ProjectWithClientListView.as_view(),
                           name='project_list'),

                       )
