feat: Add test HTTP endpoint and corresponding view; enhance login template with cookie handling

1 parent 5be791f2
......@@ -81,5 +81,5 @@ base-user-area-add,/user/area/add,base,user_area,,,,admin,base-user-area,User-ar
base-user-area-edit,/user/area/{id}/edit,base,user_area,,,,admin,base-user-area,User-area Edit,1,0,,,form6.pt,
base-user-area-view,/user/area/{id}/view,base,user_area,,,,admin,base-user-area,User-area View,1,0,,,form6.pt,
base-user-area-delete,/user/area/{id}/delete,base,user_area,,,,admin,base-user-area,User-area Delete,1,0,,,form6.pt,
base-test,/test,base,web_test_http,,view_add,,,,Test HTTP,1,0,,,test.pt
from email.utils import parseaddr
import logging
import os
from datetime import datetime
from cgi import FieldStorage
from email.utils import parseaddr
from webob.multidict import MultiDict
from opensipkd.tools.captcha import img_captcha
import colander
from datatables import ColumnDT
......@@ -14,6 +13,7 @@ from pyramid.httpexceptions import HTTPFound, HTTPNotFound
from sqlalchemy import Table
# from opensipkd.base.views.upload import tmpstore
from opensipkd.tools.captcha import img_captcha
from opensipkd.tools import dmy, get_settings, get_ext, \
date_from_str, get_random_string, Upload, InvalidExtension, mem_tmp_store
from opensipkd.tools.buttons import (
......
......@@ -70,6 +70,13 @@
<!-- </ul> -->
<!-- </div> -->
<div class="navbar-collapse collapse" tal:condition="not request.user">
<ul class="nav navbar-nav navbar-right" style="margin-right:0px;">
<li>
<a href="${request.route_url('base-login')}">Login</a>
</li>
</ul>
</div>
<div class="navbar-collapse collapse" tal:condition="request.user">
<!-- Define Tombol Navigator -->
<div metal:define-slot="navs"></div>
......@@ -122,6 +129,7 @@
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
......
......@@ -155,7 +155,7 @@
const value = document.cookie;
const parts = value.split(`g_state=`);
if (parts.length === 2) {
document.cookie = document.cookie + ";max-age=0";
document.cookie = "max-age=0";
}
}
......
<html>
<head>
<title>Test HTTP</title>
</head>
<body>
<h1>Test HTTP Endpoint</h1>
<p>This is a test endpoint to verify that the HTTP server is functioning correctly.</p>
<p>If you can see this page, the server is up and running!</p>
<div tal:content="structure form"></div>
</body>
</html>
\ No newline at end of file
import colander
from pyramid.httpexceptions import HTTPFound
from deform.exception import ValidationFailure
from . import base_views
class ViewSchema(colander.Schema):
id = colander.SchemaNode(
colander.Int(),
title="ID",
description="Unique identifier for the test.",
)
class Views(base_views.BaseView):
""" Test HTTP View """
def __init__(self, request):
super(Views, self).__init__(request)
self.add_schema = ViewSchema
def view_test(self):
form = self.get_form(self.add_schema)
# if self.req.POST:
# return HTTPFound(location=self.req.route_url('base-test'))
return {'form': form.render()}
def next_add(self, form, **kwargs):
return super().next_add(form, **kwargs)
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!