예제 #1
0
파일: forms.py 프로젝트: skwzrd/Lamendo
    def __init__(
        self,
        request,
        form_text_name=None,
        form_img_name=None,
        require_text=True,
        validate_text=True,
        require_img=True,
    ):
        self.valid = True
        self.invalid_message = None

        self.request = request
        self.text_name = form_text_name
        self.img_name = form_img_name
        self.require_text = require_text
        self.require_img = require_img
        self.validate_text = validate_text

        self.ip = get_ip_from_request(self.request)
        self.text = request.form.get(form_text_name, None)
        self.img = make_img_from_request(request, form_img_name)
        self.user = get_username()

        self.event = get_event(self.ip)
        push_event(self.ip, event=self.event)

        self.set_is_valid()
예제 #2
0
def view_event(request, event_id):
    event_id = int(event_id)
    try:
        event = Event.objects.get(pk=event_id)
    except Event.DoesNotExist:
        raise Http404
    return render_to_response ('tote/event_'+event.state+".html", api.get_event(request.user, event),  context_instance=RequestContext(request))
예제 #3
0
def announce_results(request, event_id):
    event_id = int(event_id)
    event = None
    try:
        event = Event.objects.get(pk=event_id)
    except Event.DoesNotExist:
        raise Http404
    if request.method == 'GET':
        return render_to_response("tote/announce_results.html",api.get_event(request.user, event), context_instance=RequestContext(request))
    elif request.method == 'POST':
        api.announce_results(event, loads(request.POST["jsonData"])["event"])
        return redirect('tote.views.view_event', event_id)
예제 #4
0
    def do_POST(self):
        global resp
        ctype, pdict = cgi.parse_header(
            self.get_header('Content-Type', self.headers))
        # refuse to receive non-json content
        if ctype != 'application/json':
            self.send_response(400)
            self.end_headers()
            return

        # read the message and convert it into a python dictionary
        length = int(self.get_header('Content-Length', self.headers))
        message = json.loads(self.rfile.read(length))
        # use api.py
        if message["method"] == "getInfoUser":
            resp = get_info_user(message['access_token'])
        if message["method"] == "getEvent":
            resp = get_event(message["category"])
        if message["method"] == "writeEvent":
            resp = write_event(message["event"])
        print("Resp From The Server:", resp)
        # send the message back
        self._set_headers()
        self.wfile.write(json.dumps(resp).encode("UTF-8"))