#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
# Author: Pegasus Wang (pegasuswang@qq.com, http://ningning.today)

# Description: Android backend views and frontend show.

"""
from django.shortcuts import render
from django.http import HttpResponse
from models import Student, Question, Notification


def login(request):
    name = request.POST.get(u'usernum')
    password = request.POST.get(u'paswd')
    flag = u'1'
    if Student.objects.get(stu_id=name):
        flag = u'1'
    else:
        flag = u'-1'
    return HttpResponse(flag, content_type=u'text/html;charset=utf-8', status=200)

@@ -168,10 +168,16 @@
 show
+ views
 .%0A
-
 %0A%22%22%22
@@ -323,16 +323,61 @@
 quest):%0A
+    %22%22%22process android LoginActivity post%22%22%22%0A
     name
@@ -632,17 +632,833 @@
 -8',
- status=200)
+%0A                        status=200)%0A%0A%0Adef register(request):%0A    %22%22%22process android RegisterActivity post%22%22%22%0A    stu_id = request.POST.get(u'usernum')%0A    name = request.POST.get(u'username')%0A    password = request.POST.get(u'pswd')%0A    if Student.object.get(stu_id=stu_id):%0A        # if user_exist, return success but do not modify database%0A        return HttpResponse('user_exist', content_type=u'text/html;charset=utf-8',%0A                            status=200)%0A    else:%0A        # create new stuent user%0A        Student.objects.create(stu_id=stu_id, name=name, password=password)%0A        return HttpResponse('reg_success', content_type=u'text/html;charset=utf-8',%0A                            status=200)%0A%0A%0Adef res_notice(request):%0A    # TODO%0A%0A%0Adef show_questin(request):%0A    # TODO%0A%0A%0Adef upload_answer(request):%0A    # TODO%0A
 %0A

add register views