Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# MRSS
Medical Registration Recommendaion System
# MRRS

A Medical Registration Recommendaion System

## Description

Now I only implement the front-end. If you type something in the search box,
the web will return a table with results. A naive project @_@

## Installation

### 1. Django

```sh
sudo pip install django
```

### 2. PostgreSQL

#### 2.1 [Install PostgreSQL](https://bibaijin.github.io/homepage/technology/postgresql.md)

#### 2.2 Create table
```sh
su -i -u postgres
create MRRS_DB
```

#### 2.3 Python's interface library with PostgreSQL

```sh
sudo pacman -S python-psycopg2
```

### 3. Other python library

```sh
cd MRRS/front-end
sudo pip install pip.txt
```

## Run

```sh
cd MRRS/front-end
python manage.py migrate # create new table
python manage.py runserver
```

## Visit the website

Open `http://127.0.0.1:8000/search_engine` in a browser.
Empty file.
115 changes: 115 additions & 0 deletions front-end/MRRS_Website/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""
Django settings for MRRS_Website project.

Generated by 'django-admin startproject' using Django 1.8.2.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'm=xi)w#__l-@85a22qsmyu=196x^4q+@zcq=t-hyfej$^=vj@='

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'sorting_bootstrap',
'django_tables2',
'search_engine',
'register',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'MRRS_Website.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# 'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
],
},
},
]

WSGI_APPLICATION = 'MRRS_Website.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'MRRS_DB',
'USER': 'bibaijin',
'PASSWORD': 'kl090503',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'

CRISPY_TEMPLATE_PACK = 'bootstrap3'
22 changes: 22 additions & 0 deletions front-end/MRRS_Website/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""MRRS_Website URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^search_engine/', include('search_engine.urls')),
url(r'^admin/', include(admin.site.urls)),
]
16 changes: 16 additions & 0 deletions front-end/MRRS_Website/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for MRRS_Website project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MRRS_Website.settings")

application = get_wsgi_application()
10 changes: 10 additions & 0 deletions front-end/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python2
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MRRS_Website.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
3 changes: 3 additions & 0 deletions front-end/pip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
django-crispy-forms = 1.5.2
django-sorting-bootstrap = 1.1
django-tables2 = 1.0.4
Empty file added front-end/register/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions front-end/register/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Empty file.
3 changes: 3 additions & 0 deletions front-end/register/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions front-end/register/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions front-end/register/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
Empty file.
22 changes: 22 additions & 0 deletions front-end/search_engine/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django.contrib import admin

# Register your models here.

from .models import SearchWord, Recommendation

class RecommendationInline(admin.TabularInline):
model = Recommendation
extra = 5

class SearchWordAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['search_word_text']}),
('Date Information', {'fields': ['search_date'],
'classes': ['collapse']}),
]
inlines = [RecommendationInline]
list_display = ('search_word_text', 'search_date')
list_filter = ['search_date']
search_fields = ['search_word_text']

admin.site.register(SearchWord, SearchWordAdmin)
25 changes: 25 additions & 0 deletions front-end/search_engine/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, Field
from crispy_forms.bootstrap import FieldWithButtons, StrictButton

class SearchWordForm(forms.Form):
search_word = forms.CharField(
label = "search word",
max_length = 200,
required = True,
widget = forms.TextInput(attrs={'placeholder':"Please input some symptom ..."}),
)

def __init__(self, *args, **kwargs):
super(SearchWordForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'searchWordFormId'
self.helper.form_method = 'get'
self.helper.form_action = '/search_engine/get_recommendation/'
# self.helper.form_action = '/search_engine/results/'
self.helper.layout = Layout(
# Field('search_word', placeholder="Please ..."),
FieldWithButtons('search_word', StrictButton('<span class="glyphicon glyphicon-search"></span>', type='submit', css_class='btn-default')),
)
self.helper.form_show_labels = False
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions front-end/search_engine/management/commands/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.core.management.base import BaseCommand, CommandError
from search_engine.models import SearchWord

class Command(BaseCommand):
help = 'test cooperation with other programms'

def handle(self, *args, **options):
f
43 changes: 43 additions & 0 deletions front-end/search_engine/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.CreateModel(
name='Recommendation',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('recommendation_text', models.CharField(max_length=200)),
('rank', models.IntegerField()),
],
),
migrations.CreateModel(
name='SearchWord',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('search_word_text', models.CharField(max_length=200)),
],
),
migrations.CreateModel(
name='SourceUrl',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('source_url', models.CharField(max_length=200)),
('pub_date', models.DateField()),
('location', models.CharField(max_length=200)),
('recommendation', models.ForeignKey(to='search_engine.Recommendation')),
],
),
migrations.AddField(
model_name='recommendation',
name='search_word',
field=models.ForeignKey(to='search_engine.SearchWord'),
),
]
26 changes: 26 additions & 0 deletions front-end/search_engine/migrations/0002_auto_20150607_1411.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import datetime


class Migration(migrations.Migration):

dependencies = [
('search_engine', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
],
),
migrations.AddField(
model_name='searchword',
name='search_date',
field=models.DateField(default=datetime.date.today, verbose_name=b'search date'),
),
]
19 changes: 19 additions & 0 deletions front-end/search_engine/migrations/0003_auto_20150607_1428.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('search_engine', '0002_auto_20150607_1411'),
]

operations = [
migrations.AlterField(
model_name='sourceurl',
name='pub_date',
field=models.DateField(verbose_name=b'search date'),
),
]
Loading