Example #1
0
def new_contact(request):
    saving = False
    form = NewContactForm(request.POST or None, request.FILES)
    if form.is_valid():
        contact = Contact()
        contact.name = form.cleaned_data["name"]
        contact.address = form.cleaned_data["address"]
        contact.photo = form.cleaned_data["photo"]
        contact.save()
        saving = True

    return render(request, 'blog/new_contact.html', {
        'form': form,
        'saving': saving
    })
Example #2
0
    def post(self, request, *args, **kwargs):
        if value_judge(request, 'name', 'phone', 'email', 'position',
                       'address') is not True:
            return self.response({
                'code': API_1_CONTACT_FAIL,
                'data': request.data
            })
        else:
            contact = Contact()
            contact.name = request.data['name']
            contact.phone = request.data['phone']
            contact.email = request.data['email']
            contact.position = request.data['position']
            contact.company = request.data['company']
            contact.address = request.data['address']
            contact.save()

            import datetime
            print(datetime.datetime.now())

            return self.response({'code': 0, 'data': request.data})