# Path: partners/models.py
# class Partner(models.Model):
# 	
# 	name = models.CharField(max_length=100)
# 	description = models.TextField()
# 	address = models.TextField()
# 	fone = models.CharField(max_length=12)
# 
# 	def save_patners(self, partner_name, partner_description, partner_address, partner_fone):
# 		partner = Partner(name=partner_name, description = partner_description, address = partner_address, fone = partner_fone)
# 		partner.save()
# 		
# 	
# 	def __str__(self):
#                 return self.name


from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.http import HttpResponse
from django.core.urlresolvers import reverse
from django.http import Http404
from .models import Partner
    if request.method == "GET":
        return render(request, 'partners/register.html')
    else:
        form = request.POST
        validate_form_data = validate_form(form)
        if len(validate_form_data) != 0 :
            return render (request,
                        'partners/register.html',
                        {'falhas': validate_form_data})
        else:
            name = form.get('name')
            description = form.get('description')
            address = form.get('address')
            fone = form.get('fone')
            partner = Partner()
            partner.save_patners(name, description, address, fone)
            return HttpResponseRedirect(reverse('partners:list'))

def validate_form(form):
    name = form.get('name')
    description = form.get('description')
    address = form.get('address')
    fone = form.get('fone')
    resultCheck = []
    name = check_name(name, 3)

    if len(name) != 0:
        resultCheck.append(name)

    description = check_description(description, 10)

# Path: partners/models.py
# class Partner(models.Model):
# 	
# 	name = models.CharField(max_length=100)
# 	description = models.TextField()
# 	address = models.TextField()
# 	fone = models.CharField(max_length=12)
# 
# 	def save_patners(self, partner_name, partner_description, partner_address, partner_fone):
# 		partner = Partner(name=partner_name, description = partner_description, address = partner_address, fone = partner_fone)
# 		partner.save()
# 		
# 	
# 	def __str__(self):
#                 return self.name


# Path: partners/views.py
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.http import HttpResponse
from django.core.urlresolvers import reverse
from django.http import Http404
from .models import Partner

    if request.method == "GET":
        return render(request, 'partners/register.html')
    else:
        form = request.POST
        validate_form_data = validate_form(form)
        if len(validate_form_data) != 0 :
            return render (request,
                        'partners/register.html',
                        {'falhas': validate_form_data})
        else:
            name = form.get('name')
            description = form.get('description')
            address = form.get('address')
            fone = form.get('fone')
            partner = Partner()
            partner.save_patners(name, description, address, fone)
            return HttpResponseRedirect(reverse('partners:list'))

def validate_form(form):
    name = form.get('name')
    description = form.get('description')
    address = form.get('address')
    fone = form.get('fone')
    resultCheck = []
    name = check_name(name, 3)

    if len(name) != 0:
        resultCheck.append(name)

    description = check_description(description, 10)

    if len(description) != 0: