Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature for viewing, creating and editing answers #31

Merged
merged 3 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 236 additions & 0 deletions docs/OSP.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,242 @@
}
],
"protocolProfileBehavior": {}
},
{
"name": "Answers",
"item": [
{
"name": "List answers for a specific form and specific user",
"event": [
{
"listen": "test",
"script": {
"id": "b7f93d2c-9352-49fa-b97a-c9299fc0e631",
"exec": [
"if (pm.request.method === 'POST') {",
" pm.test(\"Status code\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([201, 400]);",
" }) ",
"}",
"if (pm.request.method === 'GET') {",
" pm.test(\"Status code\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([200]);",
" })",
"}",
"pm.test(\"Content-Type is present\", function () {",
" pm.response.to.have.header(\"Content-Type\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true,
"disabledSystemHeaders": {
"content-type": true
}
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTk2OTc4NDIxLCJqdGkiOiI0ZmEwMjQ2OWM0ZWE0YTFmOTA5ZWZhZjE2MzlmOGJiZSIsInVzZXJfaWQiOjF9.MRAbEnbr3VAYUyykLPX96W-U_g8hVp2WxFWGAM3zgnc",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://localhost:8000/api/answers/?form_id=47",
"protocol": "http",
"host": [
"localhost"
],
"port": "8000",
"path": [
"api",
"answers",
""
],
"query": [
{
"key": "form_id",
"value": "47"
}
]
}
},
"response": []
},
{
"name": "Add answers",
"event": [
{
"listen": "test",
"script": {
"id": "b7f93d2c-9352-49fa-b97a-c9299fc0e631",
"exec": [
"if (pm.request.method === 'POST') {",
" pm.test(\"Status code\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([201, 400]);",
" }) ",
"}",
"if (pm.request.method === 'GET') {",
" pm.test(\"Status code\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([200]);",
" })",
"}",
"pm.test(\"Content-Type is present\", function () {",
" pm.response.to.have.header(\"Content-Type\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"content-type": true
}
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTk2OTc4NDIxLCJqdGkiOiI0ZmEwMjQ2OWM0ZWE0YTFmOTA5ZWZhZjE2MzlmOGJiZSIsInVzZXJfaWQiOjF9.MRAbEnbr3VAYUyykLPX96W-U_g8hVp2WxFWGAM3zgnc",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"form\": 48,\n \"answers\": [{\n \"question\": 10,\n \"value\": \"newdfgdgf\"\n }]\n}"
},
"url": {
"raw": "http://localhost:8000/api/feedback/",
"protocol": "http",
"host": [
"localhost"
],
"port": "8000",
"path": [
"api",
"feedback",
""
]
}
},
"response": []
}
],
"protocolProfileBehavior": {}
},
{
"name": "Form Feedback",
"item": [
{
"name": "Get list of form feedback",
"event": [
{
"listen": "test",
"script": {
"id": "b7f93d2c-9352-49fa-b97a-c9299fc0e631",
"exec": [
"if (pm.request.method === 'POST') {",
" pm.test(\"Status code\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([201, 400]);",
" }) ",
"}",
"if (pm.request.method === 'GET') {",
" pm.test(\"Status code\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([200]);",
" })",
"}",
"pm.test(\"Content-Type is present\", function () {",
" pm.response.to.have.header(\"Content-Type\");",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true,
"disabledSystemHeaders": {
"content-type": true
}
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTk2OTc4NDIxLCJqdGkiOiI0ZmEwMjQ2OWM0ZWE0YTFmOTA5ZWZhZjE2MzlmOGJiZSIsInVzZXJfaWQiOjF9.MRAbEnbr3VAYUyykLPX96W-U_g8hVp2WxFWGAM3zgnc",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"form\": 48,\n \"answers\": [{\n \"question\": 10,\n \"value\": \"newdfgdgf\"\n }]\n}"
},
"url": {
"raw": "http://localhost:8000/api/feedback/?form_id=48",
"protocol": "http",
"host": [
"localhost"
],
"port": "8000",
"path": [
"api",
"feedback",
""
],
"query": [
{
"key": "form_id",
"value": "48"
}
]
}
},
"response": []
}
],
"protocolProfileBehavior": {}
}
],
"event": [
Expand Down
8 changes: 6 additions & 2 deletions osp/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
from osp.models import (
UserInformation, Form, Question, Choice,
Checkbox, Dropdown, Paragraph, ShortAnswer,
Date, Time, FileUpload
Date, Time, FileUpload, Answer, ChoiceValue,
CheckboxValue, DropdownValue, ParagraphValue, ShortAnswerValue,
DateValue, TimeValue, FileUploadValue, FormFeedback
)

models = [
UserInformation, Form, Question, Choice,
Checkbox, Dropdown, Paragraph, ShortAnswer,
Date, Time, FileUpload
Date, Time, FileUpload, Answer, ChoiceValue,
CheckboxValue, DropdownValue, ParagraphValue, ShortAnswerValue,
DateValue, TimeValue, FileUploadValue, FormFeedback
]

admin.site.register(models)
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Generated by Django 3.0.7 on 2020-07-23 14:21

from django.conf import settings
import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('osp', '0010_auto_20200713_1843'),
]

operations = [
migrations.CreateModel(
name='Answer',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_on', models.DateTimeField(auto_now_add=True)),
('updated_on', models.DateTimeField(auto_now=True)),
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='osp.Question')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='CheckboxValue',
fields=[
('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='osp.Answer')),
('value', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=255), size=None)),
],
options={
'abstract': False,
},
bases=('osp.answer',),
),
migrations.CreateModel(
name='ChoiceValue',
fields=[
('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='osp.Answer')),
('value', models.CharField(max_length=255)),
],
options={
'abstract': False,
},
bases=('osp.answer',),
),
migrations.CreateModel(
name='DateValue',
fields=[
('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='osp.Answer')),
('value', models.DateField(default=django.utils.timezone.now)),
],
options={
'abstract': False,
},
bases=('osp.answer',),
),
migrations.CreateModel(
name='DropdownValue',
fields=[
('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='osp.Answer')),
('value', models.CharField(max_length=255)),
],
options={
'abstract': False,
},
bases=('osp.answer',),
),
migrations.CreateModel(
name='FileUploadValue',
fields=[
('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='osp.Answer')),
('value', models.TextField()),
],
options={
'abstract': False,
},
bases=('osp.answer',),
),
migrations.CreateModel(
name='ParagraphValue',
fields=[
('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='osp.Answer')),
('value', models.TextField()),
],
options={
'abstract': False,
},
bases=('osp.answer',),
),
migrations.CreateModel(
name='ShortAnswerValue',
fields=[
('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='osp.Answer')),
('value', models.CharField(max_length=255)),
],
options={
'abstract': False,
},
bases=('osp.answer',),
),
migrations.CreateModel(
name='TimeValue',
fields=[
('answer_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='osp.Answer')),
('value', models.TimeField(default=django.utils.timezone.now)),
],
options={
'abstract': False,
},
bases=('osp.answer',),
),
migrations.CreateModel(
name='FormFeedback',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('acceptance_status', models.CharField(choices=[('accepted', 'Accepted'), ('rejected', 'Rejected'), ('waitlisted', 'Waitlisted'), ('pending', 'Pending')], default='pending', max_length=10)),
('answers', models.ManyToManyField(blank=True, default=None, related_name='form_answers', to='osp.Answer')),
('form', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='osp.Form')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
Loading