Skip to main content
Sign in
Snippets Groups Projects
Commit 182f7acb authored by Fawwaz Anugrah Wiradhika Dharmasatya's avatar Fawwaz Anugrah Wiradhika Dharmasatya
Browse files

feat: handle route annotation with nocheck

parent 56789384
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ class FileReader: ...@@ -25,6 +25,7 @@ class FileReader:
lines = source_code.readlines() lines = source_code.readlines()
i = 0 i = 0
while i < len(lines): while i < len(lines):
is_skipped = False
annotation_list = self.have_annotation(lines[i]) annotation_list = self.have_annotation(lines[i])
annotation = None if len(annotation_list)==0 else annotation_list[0] annotation = None if len(annotation_list)==0 else annotation_list[0]
if(annotation): if(annotation):
...@@ -33,8 +34,19 @@ class FileReader: ...@@ -33,8 +34,19 @@ class FileReader:
# skip fungsi ini # skip fungsi ini
# Cari tahu jenis yang di-excempt # Cari tahu jenis yang di-excempt
i+=1 i+=1
while re.search("\S*@.+",lines[i]): while not is_skipped and re.search("\S*@.+",lines[i]):
next_annotations = self.have_annotation(lines[i])
# print(next_annotations)
for annon in next_annotations:
if "@Routes" in annon:
# Skip fungsi ini
is_skipped = True
break
#TODO handle sisanya
i+=1 i+=1
if is_skipped:
# print("skip")
continue
# Kalau next line nya class, ya class, kalau def yg fungsi, selain itu type nya module # Kalau next line nya class, ya class, kalau def yg fungsi, selain itu type nya module
curr_node = None curr_node = None
if re.search("\S*class +",lines[i]): if re.search("\S*class +",lines[i]):
...@@ -69,6 +81,7 @@ class FileReader: ...@@ -69,6 +81,7 @@ class FileReader:
# Cari tahu jenis acl nya # Cari tahu jenis acl nya
i+=1 i+=1
while re.search("\S*@.+",lines[i]): while re.search("\S*@.+",lines[i]):
#TODO handle kalau ketemu yang lain
i+=1 i+=1
if re.search("\S*class +",lines[i]): if re.search("\S*class +",lines[i]):
# ACL nya kelas # ACL nya kelas
...@@ -100,8 +113,17 @@ class FileReader: ...@@ -100,8 +113,17 @@ class FileReader:
additional_context = re.sub(r"[\(\) ]","",match.group(0)).split(",") additional_context = re.sub(r"[\(\) ]","",match.group(0)).split(",")
# Cari tahu jenis rute nya # Cari tahu jenis rute nya
i+=1 i+=1
while re.search("\S*@.+",lines[i]): while not is_skipped and re.search("\S*@.+",lines[i]):
next_annotations = self.have_annotation(lines[i])
for annon in next_annotations:
if "@NoCheck" in annon:
# Skip fungsi ini
is_skipped = True
break
#TODO handle sisanya
i+=1 i+=1
if is_skipped:
continue
# Kalau next line nya class, ya class, kalau def yg fungsi, selain itu type nya module # Kalau next line nya class, ya class, kalau def yg fungsi, selain itu type nya module
if re.search("\S*class +",lines[i]): if re.search("\S*class +",lines[i]):
project_info.route_class.append(ElementContext(lines[i].strip().split(" ")[1],'class',file,additional_context)) project_info.route_class.append(ElementContext(lines[i].strip().split(" ")[1],'class',file,additional_context))
... ...
......
...@@ -11,6 +11,7 @@ Views.class_update_note:admin,user ...@@ -11,6 +11,7 @@ Views.class_update_note:admin,user
Views.class_delete_note:admin,user Views.class_delete_note:admin,user
Views.class_get_note:admin,user Views.class_get_note:admin,user
Views.class_get_logs: admin Views.class_get_logs: admin
logout: admin,user
=====DETAIL===== =====DETAIL=====
var:user::var:role; [admin:admin,user:user,none:guest] var:user::var:role; [admin:admin,user:user,none:guest]
lib:flask_login::login_required; admin,user lib:flask_login::login_required; admin,user
\ No newline at end of file
...@@ -2,6 +2,7 @@ from flask import Blueprint, render_template, request, flash, redirect, url_for ...@@ -2,6 +2,7 @@ from flask import Blueprint, render_template, request, flash, redirect, url_for
from .models import User from .models import User
from werkzeug.security import generate_password_hash, check_password_hash from werkzeug.security import generate_password_hash, check_password_hash
from . import db from . import db
#@ACL(login_required)
from flask_login import login_user, login_required, logout_user, current_user from flask_login import login_user, login_required, logout_user, current_user
...@@ -26,7 +27,7 @@ def login(): ...@@ -26,7 +27,7 @@ def login():
return render_template("login.html") return render_template("login.html")
#@Routes
@auth.route('/logout') @auth.route('/logout')
@login_required @login_required
def logout(): def logout():
... ...
......
...@@ -5,9 +5,8 @@ from .models import Note,Log ...@@ -5,9 +5,8 @@ from .models import Note,Log
from .db import db from .db import db
import json import json
from lib.RoleCheck import RoleCheck from lib.RoleCheck import RoleCheck
# @Routes
views = Blueprint('views', __name__)
views = Blueprint('views', __name__)
class Views(): class Views():
def __init__(self,a) -> None: def __init__(self,a) -> None:
self.a = a self.a = a
...@@ -26,7 +25,8 @@ class Views(): ...@@ -26,7 +25,8 @@ class Views():
flash('Note added!', category='success') flash('Note added!', category='success')
return render_template("home.html") return render_template("home.html")
# @NoCheck
# @Routes
@views.route('/update', methods=['POST']) @views.route('/update', methods=['POST'])
@login_required @login_required
def class_update_note(self): def class_update_note(self):
... ...
......
# @NoCheck
# @Routes # @Routes
from flask import Blueprint, render_template, request, flash, jsonify,abort from flask import Blueprint, render_template, request, flash, jsonify,abort
# @ACL(login_required) # @ACL(login_required)
... ...
......
...@@ -8,6 +8,31 @@ module: ...@@ -8,6 +8,31 @@ module:
- class > function (V) - class > function (V)
TODO TODO
- check kalau kelasnya disimpan di variabel (V) -> cuma kalau langsung manggil kelas - check kalau kelasnya disimpan di variabel (V) -> cuma kalau langsung manggil kelas ( 1 kali assignment, belum transitif)
- routes kena nocheck? - routes kena nocheck?
routes -> nocheck
function (V)
class: (V)
- function (V)
module: (V)
- function (V)
- class (V)
- class > function (V)
nocheck -> routes
function (V)
class:(V)
- function (V)
module: (V)
- function (V)
- class (V)
- class > function (V)
- acl sekaligus routes?
routes -> acl
acl -> routes
nocheck -> acl
acl -> nocheck
routes -> routes
nocheck -> nocheck
acl -> acl
- default gak cek __init__ (V) - default gak cek __init__ (V)
- routes dalam routes (module -> function)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment