Skip to content

Commit

Permalink
Server/Ticket78/Fix interface api calls on the server side. DPCS-team#79
Browse files Browse the repository at this point in the history


Added searching required by API. Changed order of commands in Dockerfile.
Now, after modyfing code and running ./rebuild-docker it doesn't install
requirements once again.
  • Loading branch information
wisniak199 committed Apr 12, 2016
1 parent 54d0412 commit 289f22b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
17 changes: 9 additions & 8 deletions server/alpha/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ FROM python:3.5
MAINTAINER Leonid Logvinov <[email protected]>
RUN mkdir /dpcs
WORKDIR /dpcs
ADD . /dpcs
ENV DJANGO_SETTINGS_MODULE 'server_django.prod_settings'
ADD ./requirements/ /dpcs/requirements/
RUN pip install -r requirements/requirements.common
RUN pip install -r requirements/requirements.prod
RUN apt-get update && apt-get install -y \
ca-certificates \
nginx \
gettext-base \
&& rm -rf /var/lib/apt/lists/*
ADD . /dpcs
RUN python manage.py check --deploy
RUN python manage.py makemigrations
RUN python manage.py migrate
Expand All @@ -14,16 +20,11 @@ RUN python manage.py migrate alpha
RUN python manage.py collectstatic -v0 --no-input
RUN echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'pass')" | python manage.py shell

RUN apt-get update && apt-get install -y \
ca-certificates \
nginx \
gettext-base \
&& rm -rf /var/lib/apt/lists/*

COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 80

RUN nginx

CMD ["gunicorn", "-c", "gunicorn_conf.py", "--chdir", "/dpcs", "server_django.wsgi", "--reload"]
CMD ["gunicorn", "-c", "gunicorn_conf.py", "--chdir", "/dpcs", "server_django.wsgi", "--reload"]

22 changes: 18 additions & 4 deletions server/alpha/alpha/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ast
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
Expand Down Expand Up @@ -128,8 +129,17 @@ def crash_group_detail(request, pk):
@api_view(['GET', 'POST'])
def crash_report_list(request):
if request.method == 'GET':
reports = CrashReport.objects.all()
serializer = CrashReportSerializer(reports, many=True)
search_string = (request.GET.get('search_string', '')).strip('"')
application_filter = request.GET.get('application_filter', '[]')
# possibly BIG security issue
application_filter = ast.literal_eval(application_filter)
reports_filtered = []
for report in CrashReport.objects.all():
if search_string in report.stderr_output and \
(len(application_filter) == 0 or \
report.application.name in application_filter):
reports_filtered.append(report)
serializer = CrashReportSerializer(reports_filtered, many=True)
return Response(serializer.data)

elif request.method == 'POST':
Expand Down Expand Up @@ -265,8 +275,12 @@ def solution_list(request):
json_resp["solution_ack"]["solution_url"] = solutions_url + str(sol.solution_id)
return Response(json_resp, status=status.HTTP_201_CREATED)
elif request.method == 'GET':
solutions = Solution.objects.all()
serializer = SolutionSerializer(solutions, many=True)
search_string = request.GET.get('search_string', '').strip('"')
filtered_solutions = []
for solution in Solution.objects.all():
if search_string in solution.shell_script:
filtered_solutions.append(solution)
serializer = SolutionSerializer(filtered_solutions, many=True)
return Response(serializer.data)


Expand Down

0 comments on commit 289f22b

Please sign in to comment.