aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--server/views.py22
-rw-r--r--version.txt2
2 files changed, 19 insertions, 5 deletions
diff --git a/server/views.py b/server/views.py
index a54c588..7643bee 100644
--- a/server/views.py
+++ b/server/views.py
@@ -123,10 +123,9 @@ def uapprove(request):
# parse text to array
data = request.POST["codes"]
- data = data.split("\n")
+ data = split_codes(data)
# check if format is right
for i in range(len(data)):
- data[i] = data[i].replace("\r", "")
if not data[i].startswith("U"):
data[i] = data[i] + " - Formato errato"
elif not data[i][1:].isdigit():
@@ -159,6 +158,22 @@ def uapprove(request):
return render(request, 'server/approve_user.html', context)
+def split_codes(str):
+ out = []
+ buffer = ""
+ for i in str:
+ if i.isdigit() or i == "U":
+ buffer += i
+ continue
+
+ if i == "\n":
+ out.append(buffer)
+ buffer = ""
+
+ if buffer != "":
+ out.append(buffer)
+
+ return out
@user_passes_test(isStaff)
def docapprove(request):
@@ -174,8 +189,7 @@ def docapprove(request):
if request.method == "POST":
# parse text in array
data = request.POST["codes"]
- data.replace("\r", "")
- data = data.split("\n")
+ data = split_codes(data)
# check if code valid
for i in range(len(data)):
if not data[i].isdigit():
diff --git a/version.txt b/version.txt
index bf156bd..83dd6d8 100644
--- a/version.txt
+++ b/version.txt
@@ -1,2 +1,2 @@
version=0.5
-rev=35
+rev=36