Skip to content

Commit

Permalink
api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ravikiran-gunale committed Oct 16, 2015
1 parent b97a956 commit 35fcdc3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
11 changes: 11 additions & 0 deletions calhost
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
mydb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)

23 changes: 21 additions & 2 deletions whitewalkers/apis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
from django.shortcuts import render, redirect
from django.views.decorators.csrf import csrf_exempt
import json
from apis.models import Questions, User, Response

@csrf_exempt
def fetch_user_profile(request):
data = request.POST
#uid = data['email_id']
uid = data['email_id']
# query_output = mongo_query('uid')
response = HttpResponse(json.dumps({
'status': 'success',
Expand All @@ -19,9 +20,10 @@ def fetch_user_profile(request):
return response


def get_questions(request):
def get_questions_extension(request):
data = request.GET
uid = data['email_id']

#questions = mongo_query(age, gender)
questions = [{'question': 'GOT rocks?',
'template_id': 4,
Expand Down Expand Up @@ -61,6 +63,23 @@ def get_response(request):
response['Access-Control-Allow-Origin'] = '*'
return response

@csrf_exempt
def post_questions(request):
data = request.POST
question = data['question']
template_type = data['template_type']
options = data['options']
owner_mail_id = data['owner_mail_id']
profile = data['profile']
q = Questions(question_id = 'fhf', question_text = question, template_type = template_type,
owner_mail_id = owner_mail_id, profile = profile)
q.save()
response = HttpResponse(json.dumps({
'status': 'success',
'data': data
}), content_type='application/json')
response['Access-Control-Allow-Origin'] = '*'
return response

def get_templates(request):
data = request.GET
Expand Down
Binary file modified whitewalkers/apis/views.pyc
Binary file not shown.
5 changes: 3 additions & 2 deletions whitewalkers/whitewalkers/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^fetch_user_profile$', views.fetch_user_profile, name = 'get_user_profile'),
url(r'^get_questions$', views.get_questions, name = 'get_questions'),
url(r'^fetch_user_profile$', views.fetch_user_profile, name = 'fetch_user_profile'),
url(r'^post_questions$', views.post_questions, name = 'post_questions'),
url(r'^get_questions_extensions$', views.get_questions_extensions, name = 'get_questions_extensions'),
url(r'^get_templates$', views.get_templates, name = 'get_templates'),
url(r'^get_response$', views.get_response, name = 'get_response')
]
Binary file modified whitewalkers/whitewalkers/urls.pyc
Binary file not shown.

0 comments on commit 35fcdc3

Please sign in to comment.