Example #1
0
def system_message_add(request,template="admin/system_message/add.tpl"):
    if request.method == "GET":
        return render_response(template)
    elif request.method == "POST":
        form = SystemMessageForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data['title']
            mtype = form.cleaned_data['type']
            content = form.cleaned_data['content']
            create_time = time_util.get_now_second()
            status = form.cleaned_data['status']
            try:
                system_message = SystemMessage.objects.create(title=title,type=mtype,
                                                  content=content,status=status,
                                                  create_time=create_time)
                system_message.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'system_message_add'}).close();</script>")
Example #2
0
def system_message_edit(request,system_message_id=0,template="admin/system_message/edit.tpl"):
    system_message = SystemMessage.get_by_id(system_message_id)
    if request.method == "GET":
        return render_response(template,system_message=system_message)
    elif request.method == "POST":
        form = SystemMessageForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data['title']
            mtype = form.cleaned_data['type']
            content = form.cleaned_data['content']
            status = form.cleaned_data['status']
            try:
                system_message.title = title
                system_message.type = mtype
                system_message.content = content
                system_message.status = status
#                 system_message.update_time = datetime.datetime.now()
                system_message.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'system_message_edit'}).close();</script>")