Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dimitri Nicolas
AI23 - Projet
Commits
73c7460a
Commit
73c7460a
authored
Jun 23, 2021
by
Dimitri Nicolas
Browse files
Requests added
parent
09334a60
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/AdherentDataMapper.py
View file @
73c7460a
...
...
@@ -13,7 +13,9 @@ class AdherentDataMapper(DataMapper):
except
Exception
as
err
:
print
(
err
)
finally
:
conn
.
close
()
connection
.
close
()
def
getPrets
(
self
,
login
):
connection
=
self
.
connect
()
try
:
...
...
@@ -25,7 +27,6 @@ class AdherentDataMapper(DataMapper):
except
Exception
as
err
:
print
(
err
)
finally
:
conn
.
close
()
conn
ection
.
close
()
datamapper
=
AdherentDataMapper
()
datamapper
.
selectAdherents
()
\ No newline at end of file
datamapper
=
AdherentDataMapper
()
\ No newline at end of file
src/DataMapper.py
View file @
73c7460a
...
...
@@ -19,8 +19,4 @@ class DataMapper:
password
=
self
.
password
)
except
psycopg2
.
OperationalError
:
print
(
"Database connection error "
)
return
res
dataMapper
=
DataMapper
()
conn
=
dataMapper
.
connect
()
print
(
type
(
conn
))
\ No newline at end of file
return
res
\ No newline at end of file
src/SanctionDataMapper.py
0 → 100644
View file @
73c7460a
from
datetime
import
date
from
enum
import
Enum
import
psycopg2
from
DataMapper
import
DataMapper
class
SanctionDataMapper
(
DataMapper
):
def
blacklister
(
self
,
login
):
connection
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
connection
.
cursor
()
cursor
.
execute
(
f
"UPDATE adherent SET blacklisted = TRUE WHERE login = '
{
login
}
'"
)
connection
.
commit
()
except
Exception
as
err
:
print
(
err
)
finally
:
connection
.
close
()
def
getSanctions
(
self
):
connection
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
connection
.
cursor
()
cursor
.
execute
(
f
"SELECT sanctionid, adherent, datesanction, encours FROM sanction"
)
return
cursor
.
fetchall
()
except
Exception
as
err
:
print
(
err
)
finally
:
connection
.
close
()
dataMapper
=
SanctionDataMapper
()
\ No newline at end of file
src/UserDataMapper.py
View file @
73c7460a
from
datetime
import
date
from
enum
import
Enum
import
psycopg2
...
...
@@ -10,6 +11,47 @@ class Roles(Enum):
PERSONNEL
=
2
class
UserDataMapper
(
DataMapper
):
def
ajouterAdherent
(
self
,
login
:
str
,
numcarte
:
str
,
datenaissance
:
date
,
numtel
:
str
):
connection
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
connection
.
cursor
()
cursor
.
execute
(
f
"INSERT INTO adherent(login, numcarte, datenaissance, numtel, dateadhesion, blacklisted)"
f
"VALUES ('
{
login
}
', '
{
numcarte
}
', '
{
datenaissance
}
', '
{
numtel
}
', CURRENT_TIMESTAMP, FALSE)"
)
connection
.
commit
()
except
Exception
as
err
:
print
(
err
)
finally
:
connection
.
close
()
def
deleteAdherent
(
self
,
login
:
str
):
connection
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
connection
.
cursor
()
cursor
.
execute
(
f
"DELETE FROM adherent WHERE login = '
{
login
}
'"
)
connection
.
commit
()
except
Exception
as
err
:
print
(
err
)
finally
:
connection
.
close
()
def
ajouterPersonnel
(
self
,
login
:
str
):
connection
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
connection
.
cursor
()
cursor
.
execute
(
f
"INSERT INTO personnel(login) VALUES ('
{
login
}
')"
)
connection
.
commit
()
except
Exception
as
err
:
print
(
err
)
finally
:
connection
.
close
()
def
deletePersonnel
(
self
,
login
:
str
):
connection
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
connection
.
cursor
()
cursor
.
execute
(
f
"DELETE FROM personnel WHERE login = '
{
login
}
'"
)
connection
.
commit
()
except
Exception
as
err
:
print
(
err
)
finally
:
connection
.
close
()
def
checkUser
(
self
,
login
:
str
,
password
:
str
)
->
Roles
:
connection
=
self
.
connect
()
try
:
...
...
@@ -36,5 +78,6 @@ class UserDataMapper(DataMapper):
dataMapper
=
UserDataMapper
()
role
=
dataMapper
.
checkUser
(
"lbernard"
,
"47FEADQ665D788"
)
print
(
role
)
\ No newline at end of file
dataMapper
.
deleteAdherent
(
"blussier"
)
dataMapper
.
deletePersonnel
(
"hlefebvre"
)
print
(
dataMapper
.
checkUser
(
"hlefebvre"
,
"1888ZFDSDSQD5Q"
))
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment