-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from fga-gpp-mds/devel
US41-PrintPrescription
- Loading branch information
Showing
20 changed files
with
718 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Django | ||
from django import forms | ||
|
||
# Local Django | ||
from django.utils.translation import ugettext_lazy as _ | ||
from prescription import constants | ||
|
||
|
||
class PatternForm(forms.Form): | ||
name = forms.CharField(max_length=constants.MAX_LENGTH_NAME, | ||
widget=forms.TextInput(attrs={'class': 'form-control', | ||
'type': 'text', | ||
'placeholder': _('Nome de Modelo')})) | ||
|
||
clinic = forms.CharField(max_length=constants.MAX_LENGTH_CLINIC, | ||
widget=forms.TextInput(attrs={'class': 'form-control', | ||
'type': 'text', | ||
'placeholder': _('Clinica')})) | ||
|
||
header = forms.CharField(max_length=constants.MAX_LENGTH_HEADER, | ||
widget=forms.TextInput(attrs={'class': 'form-control', | ||
'type': 'text', | ||
'placeholder': _('Header')})) | ||
|
||
footer = forms.CharField(max_length=constants.MAX_LENGTH_FOOTER, | ||
widget=forms.TextInput(attrs={'class': 'form-control', | ||
'type': 'text', | ||
'placeholder': _('Footer')})) | ||
|
||
logo = forms.FileField(required=False) | ||
|
||
font = forms.ChoiceField(choices=constants.FONT_CHOICE) | ||
font_size = forms.ChoiceField(choices=constants.FONT_SIZE_CHOICE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Standard | ||
import os | ||
|
||
# Django | ||
from django.db import models | ||
|
||
# Django Local | ||
from user.models import User | ||
from chat.models.pathfile import UploadToPathAndRename | ||
from prescription import constants | ||
|
||
|
||
class Pattern(models.Model): | ||
""" | ||
Prescription PDF base model. | ||
""" | ||
name = models.CharField(max_length=constants.MAX_LENGTH_NAME) | ||
user_creator = models.ForeignKey(User, related_name="user_creator") | ||
|
||
font = models.CharField(choices=constants.FONT_CHOICE, max_length=100, default=constants.TIMES_ROMAN) | ||
font_size = models.CharField(choices=constants.FONT_SIZE_CHOICE, max_length=100, default=constants.TWELVE) | ||
|
||
clinic = models.CharField(max_length=constants.MAX_LENGTH_CLINIC) | ||
header = models.CharField(max_length=constants.MAX_LENGTH_HEADER) | ||
footer = models.CharField(max_length=constants.MAX_LENGTH_FOOTER) | ||
|
||
logo = models.FileField(upload_to=UploadToPathAndRename(os.path.join('logos', 'files')), blank=True, null=True) | ||
date = models.DateField(auto_now=True) |
88 changes: 88 additions & 0 deletions
88
medical_prescription/prescription/templates/create_prescription_model.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{% extends "dashboardHealthProfessional/template.html" %} | ||
|
||
{% block content %} | ||
{% load staticfiles %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
<!-- Panel --> | ||
|
||
{% csrf_token %} | ||
<div class = "col-sm-4 center-block center"> | ||
<form action='' method="POST" enctype="multipart/form-data"> | ||
|
||
{% csrf_token %} | ||
|
||
<font size="5"> | ||
<span class="label label-primary">{% trans "Nome do Modelo" %}</span> | ||
</font> | ||
{% for error in form.name.errors %} | ||
<div class="alert alert-danger" role="alert">{{ error }}</div> | ||
{% endfor %} | ||
{{ form.name }} | ||
|
||
<br> | ||
|
||
<font size="5"> | ||
<span class="label label-primary">{% trans "Clinica" %}</span> | ||
</font> | ||
{% for error in form.clinic.errors %} | ||
<div class="alert alert-danger" role="alert">{{ error }}</div> | ||
{% endfor %} | ||
{{ form.clinic }} | ||
|
||
<br> | ||
|
||
<font size="5"> | ||
<span class="label label-primary">{% trans "Header" %}</span> | ||
</font> | ||
{% for error in form.header.errors %} | ||
<div class="alert alert-danger" role="alert">{{ error }}</div> | ||
{% endfor %} | ||
{{ form.header }} | ||
|
||
<br> | ||
|
||
<font size="5"> | ||
<span class="label label-primary">{% trans "Footer" %}</span> | ||
</font> | ||
{% for error in form.footer.errors %} | ||
<div class="alert alert-danger" role="alert">{{ error }}</div> | ||
{% endfor %} | ||
{{ form.footer }} | ||
<br> | ||
|
||
|
||
<font size ="5"> | ||
<span class="label label-primary">{% trans "Fonte" %}</span> | ||
</font> | ||
{% for error in form.font.errors %} | ||
<div class="alert alert-danger" role="alert">{{ error }}</div> | ||
{% endfor %} | ||
{{ form.font }} | ||
<br> | ||
|
||
<font size="5"> | ||
<span class="label label-primary">{% trans "Tamanho da Fonte" %}</span> | ||
</font> | ||
{% for error in form.font_size.errors %} | ||
<div class="alert alert-danger" role="alert">{{ error }}</div> | ||
{% endfor %} | ||
{{ form.font_size }} | ||
<br> | ||
|
||
<font size="5"> | ||
<span class="label label-primary">{% trans "Logo" %}</span> | ||
</font> | ||
{% for error in form.logo.errors %} | ||
<div class="alert alert-danger" role="alert">{{ error }}</div> | ||
{% endfor %} | ||
{{ form.logo }} | ||
<br> | ||
|
||
<br><br> | ||
|
||
<button type ="submit" class = "btn btn-success">{% trans "Enviar" %}</button> | ||
</form> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
medical_prescription/prescription/test/test_form_createpattern.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from django.test import TestCase | ||
|
||
from prescription.models import Pattern | ||
from prescription.forms import PatternForm | ||
from prescription.views import CreatePatternView | ||
from user.models import User | ||
|
||
|
||
class TestFormCreatePattern(TestCase): | ||
def setUp(self): | ||
self.user = User() | ||
self.user.email = '[email protected]' | ||
self.user.save() | ||
|
||
self.name = "Pattern de teste" | ||
self.user_creator = self.user | ||
self.clinic = "clinica de teste" | ||
self.header = "header de teste" | ||
self.font = 'Helvetica' | ||
self.font_size = '12' | ||
self.footer = "footer de teste" | ||
|
||
def test_form_is_valid(self): | ||
form_data = { | ||
'name': self.name, | ||
'clinic': self.clinic, | ||
'font': 'Helvetica', | ||
'font_size': '12', | ||
'header': self.header, | ||
'footer': self.footer | ||
} | ||
|
||
form = PatternForm(data=form_data) | ||
self.assertTrue(form.is_valid()) |
51 changes: 51 additions & 0 deletions
51
medical_prescription/prescription/test/test_view_createpattern.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from django.test import TestCase | ||
from django.test.client import RequestFactory, Client | ||
|
||
from prescription.models import Pattern | ||
from prescription.views import CreatePatternView | ||
from user.models import HealthProfessional | ||
|
||
|
||
class TestCreatePattern(TestCase): | ||
def setUp(self): | ||
self.factory = RequestFactory() | ||
|
||
self.my_class = Pattern | ||
self.my_view = CreatePatternView() | ||
|
||
self.user = HealthProfessional() | ||
self.user.email = '[email protected]' | ||
self.user.save() | ||
|
||
self.name = "Pattern de teste" | ||
self.user_creator = self.user | ||
self.clinic = "clinica de teste" | ||
self.header = "header de teste" | ||
self.font = 'Helvetica' | ||
self.font_size = '12' | ||
self.footer = "footer de teste" | ||
|
||
def test_pattern_redirect_valid(self): | ||
data = { | ||
'name': self.name, | ||
'clinic': self.clinic, | ||
'font': 'Helvetica', | ||
'font_size': '12', | ||
'header': self.header, | ||
'footer': self.footer | ||
} | ||
|
||
request = self.factory.post('/', data) | ||
request.user = self.user | ||
|
||
response = CreatePatternView.as_view()(request) | ||
|
||
self.assertEqual(response.status_code, 302) | ||
|
||
def test_pattern_get(self): | ||
request = self.factory.get('/prescription/create_prescription_model/') | ||
request.user = self.user | ||
|
||
# Get the response | ||
response = self.my_view.get(request) | ||
self.assertEqual(response.status_code, 200) |
Oops, something went wrong.