Giter Site home page Giter Site logo

dynamic-model-fields's Introduction

Dynamic Model Fields

Build Status Coverage Status

This project enables insurers to create risk types with custom fields of different types, For example Name, Address, Age, and so on. It is built using Python/Django and hosted using heroku. Check the hotsed app here.

Solution approach

In order to enable insurers add their custom fields with relevant field type when creating a risk type, This project creates three models FieldType, Field and RiskType. The Field model relates to the FieldType and RiskType with a Many-To-Many relationship. The available views enable a user to create risk types with a list of fields and the fields must refer to a field-type. A field type has a name and options if it's of select type. You can find a class diagram here.

Example of post data when creating a risk type:

POST api/v1/risk-type/:

{
	"name": "Prize Policy",
	"description": "This is my description feild which can not be empty",
	"fields": [{
		"name": "first name",
		"field_type": "6611f2ca-3569-4f54-a50a-f9be73cdd3ab" # FieldType Id
	},
	{
		"name": "Age",
		"field_type": "4511f2ca-3569-4f54-a50a-f9be73cdd3a9" # FieldType Id
	}
	]	
}

Setup

Before we start make sure you have the PostgreSQL installed on your machine.

Clone the repository with:

$ git clone https://github.com/marthamareal/dynamic-model-fields.git
$ cd dynamic-model-fields

Create and activate a virtual enviroment with:

$ virtualenv -p python3 venv
$ source venv/bin/activate

setup database

- create database called `britecore`

Rename the .env.sample file to .env and modify the variables with your credentials. Source the variables with

$ source .env

Install dependencies with:

$ pip install -r requirements.txt

Apply migrations and run the server:

$ python manage.py migrate
$ python manage.py loaddevelopmentdata
$ python manage.py runserver

Tests

To test the app:

$ python manage.py test

with coverage:

$ coverage run --source='.' ./manage.py test

The following are the activities that can be performed in the application.

- Create a Risk type
- List Risk types
- Retieve a single Risk type
- Update and delete a Risk type
- List Field types

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.