Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
account_init_cleanup
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mitchell Moore
account_init_cleanup
Commits
394ca269
Commit
394ca269
authored
5 years ago
by
Mitchell Moore
Browse files
Options
Downloads
Patches
Plain Diff
Create directory and pass username variable
parent
912da48a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/__init__.py
+0
-42
0 additions, 42 deletions
app/__init__.py
app/static/scripts/function.js
+2
-1
2 additions, 1 deletion
app/static/scripts/function.js
app/templates/auth/SignUp.html
+4
-8
4 additions, 8 deletions
app/templates/auth/SignUp.html
run.py
+25
-0
25 additions, 0 deletions
run.py
with
31 additions
and
51 deletions
app/__init__.py
+
0
−
42
View file @
394ca269
...
...
@@ -18,7 +18,6 @@ from flask_socketio import SocketIO
# global declarations
def
create_app
(
config_name
):
app
=
Flask
(
__name__
)
# initialization of the flask app
Bootstrap
(
app
)
# allowing app to use bootstrap
...
...
@@ -36,48 +35,7 @@ def create_app(config_name):
return
render_template
(
'
auth/SignUp.html
'
,
user
=
username
)
@app.route
(
'
/request_sent/<username>
'
)
def
request_sent
(
username
):
fullname
=
session
.
get
(
'
fullname
'
,
None
)
reason
=
session
.
get
(
'
reason
'
,
None
)
global
return_url
global
time_stamp
print
(
username
,
fullname
,
return_url
,
file
=
sys
.
stdout
)
# Deliver arguments to script. (for local vagrant implementation)
tempString
=
'
ssh ohpc
"
sudo /opt/ohpc_user_create/user_create
'
+
username
+
"
"
+
fullname
+
'"'
print
(
tempString
,
file
=
sys
.
stdout
)
try
:
# function to write out a flatdb with the name of the file being a timestamp and the content
# of the file beieng blazerID the user submitted from the flask form (fullname)
time_stamp
=
time
.
strftime
(
"
%m-%d-%Y_%H:%M:%S
"
)
directory
=
"
flat_db/
"
complete_file_name
=
os
.
path
.
join
(
directory
,
time_stamp
+
"
_
"
+
username
+
"
.txt
"
)
if
not
os
.
path
.
exists
(
directory
):
os
.
makedirs
(
directory
)
file
=
open
(
complete_file_name
,
"
w
"
)
# create time stamped file to be queued
file
.
write
(
fullname
+
"
\n
"
)
file
.
write
(
reason
)
file
.
close
()
return
render_template
(
"
auth/request_received.html
"
)
# Todo: replace template with redirect
# return redirect(return_url, 302)
except
Exception
as
e
:
print
(
e
)
flash
(
"
Registration Failed. Please try again.
"
)
# show error message upon failure
return
redirect
(
url_for
(
'
index
'
))
# misc page error catching
@app.errorhandler
(
403
)
def
forbidden
(
error
):
return
render_template
(
'
errors/403.html
'
,
title
=
'
Forbidden
'
),
403
...
...
This diff is collapsed.
Click to expand it.
app/static/scripts/function.js
+
2
−
1
View file @
394ca269
...
...
@@ -19,6 +19,7 @@ function displayloading() {
function
socketIO
()
{
socket
.
emit
(
'
user data
'
,
{
fullname
:
document
.
getElementById
(
"
fullname
"
).
value
,
reason
:
document
.
getElementById
(
"
reason
"
).
value
reason
:
document
.
getElementById
(
"
reason
"
).
value
,
username
:
document
.
getElementById
(
"
username
"
).
innerText
})
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/templates/auth/SignUp.html
+
4
−
8
View file @
394ca269
...
...
@@ -15,16 +15,12 @@
}
)
socket
.
on
(
'
creating account
'
,
function
(
msg
)
{
d
ocument
.
getElementById
(
"
test
"
).
innerHTML
=
"
Account is being Created!
"
;
d
isplayloading
()
;
})
socket
.
on
(
'
create response
'
,
function
(
msg
)
{
console
.
log
(
msg
)
if
(
typeof
msg
.
user_name
!==
'
undefined
'
)
{
$
(
'
h3
'
).
remove
()
$
(
'
div.message_holder
'
).
append
(
'
<div><b style="color: #002">
'
+
msg
.
user_name
+
'
</b> created. WELCOME</div>
'
)
}
socket
.
on
(
'
account created
'
,
function
(
msg
)
{
document
.
getElementById
(
"
test
"
).
innerHTML
=
"
Account Created!
"
;
})
...
...
@@ -82,7 +78,7 @@
</a>
</div>
<h2>
Hello, {{ user }}!
</h2>
<h2>
Hello,
<span
id=
"username"
>
{{ user }}
</span>
!
</h2>
<div
id=
"test"
>
<form
action=
"."
method=
"post"
onsubmit=
""
>
<div
class=
"signUpContainer"
>
...
...
This diff is collapsed.
Click to expand it.
run.py
+
25
−
0
View file @
394ca269
...
...
@@ -5,6 +5,7 @@ import time
from
app
import
create_app
from
flask_socketio
import
SocketIO
from
flask
import
flash
config_name
=
os
.
getenv
(
'
FLASK_CONFIG
'
)
app
=
create_app
(
config_name
)
...
...
@@ -26,6 +27,30 @@ def confirm(json, methods=['GET', 'POST']):
print
(
str
(
json
))
socketio
.
emit
(
"
creating account
"
)
try
:
fullname
=
json
[
"
fullname
"
]
reason
=
json
[
"
reason
"
]
username
=
json
[
"
username
"
]
failure
=
json
[
"
failure
"
]
time_stamp
=
time
.
strftime
(
"
%m-%d-%Y_%H:%M:%S
"
)
directory
=
"
flat_db/
"
complete_file_name
=
os
.
path
.
join
(
directory
,
time_stamp
+
"
_
"
+
username
+
"
.txt
"
)
if
not
os
.
path
.
exists
(
directory
):
os
.
makedirs
(
directory
)
file
=
open
(
complete_file_name
,
"
w
"
)
# create time stamped file to be queued
file
.
write
(
fullname
+
"
\n
"
)
file
.
write
(
reason
)
file
.
close
()
except
Exception
as
e
:
# print(e)
flash
(
"
Registration Failed. Please try again.
"
)
# show error message upon failure
@socketio.on
(
'
my event
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment