Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenQuizz
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Weber Rodolphe
OpenQuizz
Commits
5bcc6504
You need to sign in or sign up before continuing.
Commit
5bcc6504
authored
Apr 27, 2021
by
jeremie.passerat@free.fr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changement de version directe ok
parent
3e6c9936
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
162 additions
and
58 deletions
+162
-58
.gitignore
.gitignore
+1
-0
Contenu1
Contenu1
+1
-1
Contenu2
Contenu2
+1
-1
Main.py
Main.py
+4
-0
Menu.py
Menu.py
+36
-21
Utils.py
Utils.py
+96
-25
UtilsGit.py
UtilsGit.py
+23
-10
No files found.
.gitignore
View file @
5bcc6504
__pycache__/
__pycache__/
venv/
venv/
.idea/
.idea/
dossierContenu*/
Contenu1
View file @
5bcc6504
Bonjour, je suis un contenu 1 dans sa version 52
Bonjour, je suis un contenu 1 dans sa version 1
\ No newline at end of file
Contenu2
View file @
5bcc6504
Bonjour, je suis un contenu 2 dans sa version 12
Bonjour, je suis un contenu 2 dans sa version 1
\ No newline at end of file
Main.py
View file @
5bcc6504
...
@@ -52,3 +52,7 @@ Menu()
...
@@ -52,3 +52,7 @@ Menu()
#print(Utils.getMaxIdEvaluations())
#print(Utils.getMaxIdEvaluations())
#print(Utils.getMaxIdContenusEnCours())
#print(Utils.getMaxIdContenusEnCours())
#print (Utils.getIdContenuAssocieAUnEnCours(1))
#print (Utils.getIdContenuAssocieAUnEnCours(1))
#from UtilsGit import UtilsGit
#UtilsGit.changerVersionCommit("/home/passerat/Stage/Squelette/dossierContenu1", "master")
Menu.py
View file @
5bcc6504
...
@@ -5,6 +5,7 @@ import os
...
@@ -5,6 +5,7 @@ import os
## Classe Menu
## Classe Menu
# Affichage principal de l'application du squelette
# Affichage principal de l'application du squelette
# Toutes les interactions utilisateur sont effectuées ici
# Toutes les interactions utilisateur sont effectuées ici
from
UtilsGit
import
UtilsGit
class
Menu
:
class
Menu
:
...
@@ -32,13 +33,14 @@ class Menu:
...
@@ -32,13 +33,14 @@ class Menu:
if
choix
==
'p'
:
if
choix
==
'p'
:
Utils
.
toutPeter
()
Utils
.
toutPeter
()
self
.
menuDeBase
()
self
.
menuDeBase
()
choix
=
Utils
.
switchAuteur
(
int
(
choix
))
if
choix
.
isdigit
():
choix
=
Utils
.
switchAuteur
(
int
(
choix
))
if
choix
!=
"Auteur inconnu"
:
if
choix
!=
"Auteur inconnu"
:
if
Utils
.
presenceUtilisateur
(
choix
):
if
Utils
.
presenceUtilisateur
(
choix
):
self
.
auteurEnCours
=
choix
self
.
auteurEnCours
=
choix
self
.
menuDesActions
()
self
.
menuDesActions
()
## Menu affiché une fois un compte valide sélectionné
## Menu affiché une fois un compte valide sélectionné
...
@@ -132,8 +134,6 @@ class Menu:
...
@@ -132,8 +134,6 @@ class Menu:
self
.
afficherContenus
(
questions
)
self
.
afficherContenus
(
questions
)
# 1. On charge les contenus "mis en favori" de la banque
# 1. On charge les contenus "mis en favori" de la banque
# print("Contenus mis en favori par l'auteur ", self.auteurEnCours, " : ",
# len(Utils.getFavoris(self.auteurEnCours)))
print
(
f
"Contenus mis en favori par l'auteur {self.auteurEnCours} : {len(Utils.getFavoris(self.auteurEnCours))}"
)
print
(
f
"Contenus mis en favori par l'auteur {self.auteurEnCours} : {len(Utils.getFavoris(self.auteurEnCours))}"
)
if
len
(
Utils
.
getFavoris
(
self
.
auteurEnCours
)):
if
len
(
Utils
.
getFavoris
(
self
.
auteurEnCours
)):
...
@@ -183,11 +183,6 @@ class Menu:
...
@@ -183,11 +183,6 @@ class Menu:
print
(
"nom :"
,
elt
[
"fichier"
],
" - v"
,
elt
[
"versionEnCours"
][
"numero"
],
" - du"
,
print
(
"nom :"
,
elt
[
"fichier"
],
" - v"
,
elt
[
"versionEnCours"
][
"numero"
],
" - du"
,
elt
[
"versionEnCours"
][
"date"
])
elt
[
"versionEnCours"
][
"date"
])
"""
La deuxième est pour les contenus de la banque. Certains champs supplémentaires apparaissent
(On verra + tard si une mutualisation de code est jouable)
"""
## Fonction d'affichage des contenus 'banque'
## Fonction d'affichage des contenus 'banque'
def
afficherContenusBanque
(
self
,
contenu
):
def
afficherContenusBanque
(
self
,
contenu
):
...
@@ -419,34 +414,54 @@ class Menu:
...
@@ -419,34 +414,54 @@ class Menu:
action
=
choix
[
len
(
choix
)
-
1
:]
action
=
choix
[
len
(
choix
)
-
1
:]
print
(
"id :"
,
id
)
print
(
"id :"
,
id
)
print
(
"id type :"
,
type
(
id
))
print
(
"action :"
,
action
)
print
(
"action :"
,
action
)
print
(
"action c :"
,
action
==
'c'
)
idContenu
=
Utils
.
getIdContenuAssocieAUnEnCours
(
int
(
id
))
print
(
"id contenu associé : "
,
idContenu
)
# affiche le contenu courant du fichier
# affiche le contenu courant du fichier
if
action
==
'c'
:
if
action
==
'c'
:
Utils
.
changerVersion
(
int
(
id
),
self
.
auteurEnCours
,
"version"
)
print
(
"je suis dans action c"
)
print
(
Utils
.
getIdContenuAssocieAUnEnCours
(
int
(
id
)))
Utils
.
affichage
(
Utils
.
getFichierContenu
(
Utils
.
getIdContenuAssocieAUnEnCours
(
int
(
id
))))
Utils
.
changerVersion
(
idContenu
,
0
,
Utils
.
getBrancheContenuEnCours
(
idContenu
))
#exit(0)
Utils
.
affichage
(
Utils
.
getCheminDuContenu
(
idContenu
))
#print("Uoi")
elif
action
==
'm'
:
elif
action
==
'm'
:
Utils
.
changerVersion
(
i
nt
(
id
),
self
.
auteurEnCours
,
"version"
)
Utils
.
changerVersion
(
i
dContenu
,
0
,
Utils
.
getBrancheContenuEnCours
(
idContenu
)
)
Utils
.
modifierContenu
(
Utils
.
getIdContenuAssocieAUnEnCours
(
int
(
id
))
,
self
.
auteurEnCours
,
True
)
Utils
.
modifierContenu
(
idContenu
,
self
.
auteurEnCours
,
True
)
Utils
.
affichage
(
Utils
.
get
FichierContenu
(
Utils
.
getIdContenuAssocieAUnEnCours
(
int
(
id
))
))
Utils
.
affichage
(
Utils
.
get
CheminDuContenu
(
idContenu
))
elif
action
==
's'
:
elif
action
==
's'
:
Utils
.
supprimerContenuEnCours
(
int
(
id
))
Utils
.
supprimerContenuEnCours
(
int
(
id
))
elif
action
==
'v'
:
elif
action
==
'v'
:
self
.
validerModification
(
int
(
id
))
self
.
validerModification
(
int
(
id
))
elif
action
==
'n'
:
elif
action
==
'n'
:
Utils
.
ajouterContenu
(
Utils
.
getFichierContenu
(
Utils
.
getIdContenuAssocieAUnEnCours
(
int
(
id
))),
chemin
=
Utils
.
getCheminDuContenu
(
Utils
.
getIdContenuAssocieAUnEnCours
(
int
(
id
)))
self
.
auteurEnCours
)
Utils
.
creerNouveauContenu
(
chemin
,
self
.
auteurEnCours
,
id
)
self
.
consulterPanier
()
elif
action
==
'q'
:
elif
action
==
'q'
:
self
.
menuDesActions
()
self
.
menuDesActions
()
## changement de version d'un contenu OU demande de publication à l'auteur d'origine
## changement de version d'un contenu OU demande de publication à l'auteur d'origine
def
validerModification
(
self
,
idContenuEnCours
):
def
validerModification
(
self
,
idContenuEnCours
):
# on récupère l'auteur et l'id du contenu "de base" associé à la modif
auteur
=
Utils
.
getAuteurContenuEnCours
(
idContenuEnCours
)
auteur
=
Utils
.
getAuteurContenuEnCours
(
idContenuEnCours
)
idContenu
=
Utils
.
getIdContenuAssocieAUnEnCours
(
idContenuEnCours
)
branche
=
Utils
.
getBrancheContenuEnCours
(
idContenuEnCours
)
if
auteur
==
self
.
auteurEnCours
:
if
auteur
==
self
.
auteurEnCours
:
print
(
"Modification directe d'un auteur"
)
print
(
"Modification directe d'un auteur"
)
chemin
=
Utils
.
getCheminDuContenu
(
idContenu
)
Utils
.
majContenu
(
chemin
,
idContenu
,
branche
)
else
:
else
:
print
(
"Modification indirecte -> demande de publication"
)
print
(
"Modification indirecte -> demande de publication"
)
print
(
"Je demande à l'auteur "
,
auteur
,
"de valider ma demande de proposition"
)
#self.consulterEnCours()
#self.consulterEnCours()
Utils.py
View file @
5bcc6504
This diff is collapsed.
Click to expand it.
UtilsGit.py
View file @
5bcc6504
...
@@ -12,29 +12,28 @@ class UtilsGit:
...
@@ -12,29 +12,28 @@ class UtilsGit:
texte
=
texte
.
strip
()
texte
=
texte
.
strip
()
return
int
(
texte
[
-
1
])
+
1
return
int
(
texte
[
-
1
])
+
1
## commit d'un fichier (branche principale)
## commit d'un fichier (branche principale)
# @param cheminFichier le chemin du fichier
# @param cheminFichier le chemin du fichier
# @param texteCommit le texte associé au commit
# @param texteCommit le texte associé au commit
# @return le hash du commit
# @return le hash du commit
@
staticmethod
@
staticmethod
def
commit
(
cheminFichier
,
texteCommit
):
def
commit
(
cheminFichier
,
nomFichier
,
texteCommit
):
repo
=
Repo
.
init
(
cheminFichier
)
repo
=
Repo
.
init
(
cheminFichier
)
print
(
"le richier à add est : "
,
cheminFichier
)
# Il faudra faire une extraction du nom du fichier a partir du chemin
# Il faudra faire une extraction du nom du fichier a partir du chemin
repo
.
index
.
add
([
chemin
Fichier
])
repo
.
index
.
add
([
nom
Fichier
])
repo
.
index
.
commit
(
texteCommit
)
repo
.
index
.
commit
(
texteCommit
)
return
repo
.
head
.
object
.
hexsha
return
repo
.
head
.
object
.
hexsha
## commit d'un fichier (branche principale)
## commit d'un fichier (branche principale)
# @param cheminFichier le chemin du fichier
# @param cheminFichier le chemin du fichier
# @param texteCommit le texte associé au commit
# @param texteCommit le texte associé au commit
# @return le hash du commit
# @return le hash du commit
@
staticmethod
@
staticmethod
def
embranchement
(
cheminFichier
,
nomBranche
):
def
embranchement
(
cheminFichier
,
nomBranche
):
# a voir pour améliorer le Repo.init à chaque fois
# a voir pour améliorer le Repo.init à chaque fois
repo
=
Repo
.
init
(
cheminFichier
)
repo
=
Repo
.
init
(
cheminFichier
)
repo
.
create_head
(
nomBranche
,
'HEAD'
)
repo
.
create_head
(
nomBranche
,
'HEAD'
)
...
@@ -45,21 +44,35 @@ class UtilsGit:
...
@@ -45,21 +44,35 @@ class UtilsGit:
@
staticmethod
@
staticmethod
def
changerVersionCommit
(
chemin
,
commit
):
def
changerVersionCommit
(
chemin
,
commit
):
repo
=
Repo
.
init
(
chemin
)
repo
=
Repo
.
init
(
chemin
)
repo
.
head
.
reference
=
repo
.
commit
(
commit
)
# repo.head.reference = repo.commit(commit)
repo
.
head
.
reset
(
index
=
True
,
working_tree
=
True
)
# repo.head.reset(index=True, working_tree=True)
repo
.
git
.
checkout
(
"c785462dfd454045798baedb11d1674837733962"
)
## changer la version actuelle (avec une base branche):
## changer la version actuelle (avec une base branche):
# @param chemin chemin du repertoire git
# @param chemin chemin du repertoire git
# @param nombranche branche contenant la branche avec le contenu désiré
# @param nombranche branche contenant la branche avec le contenu désiré
@
staticmethod
@
staticmethod
def
changerVersionBranche
(
chemin
,
branche
):
def
changerVersionBranche
(
chemin
,
branche
):
# print("On a parcouru le chemin : ", chemin, " sur la branche :", branche)
repo
=
Repo
.
init
(
chemin
)
repo
=
Repo
.
init
(
chemin
)
repo
.
head
.
reference
=
branche
repo
.
git
.
checkout
(
branche
)
repo
.
head
.
reset
(
index
=
True
,
working_tree
=
True
)
#
repo.head.reset(index=True, working_tree=True)
## valider une nouvelle version courante d'un contenu - Un peu plus compliqué à faire.
## valider une nouvelle version courante d'un contenu - Un peu plus compliqué à faire.
# @param chemin chemin du repertoire git
# @param chemin chemin du repertoire git
# @param nombranche branche contenant le contenu temporaire à repasser en principal
# @param nombranche branche contenant le contenu temporaire à repasser en principal
@
staticmethod
@
staticmethod
def
mergeVersion
(
chemin
,
nombranche
):
def
mergeVersion
(
chemin
,
nombranche
):
pass
# "objectif : fusionner main et en_cours"
repo
=
Repo
.
init
(
chemin
)
master
=
repo
.
branches
[
'master'
]
enCours
=
repo
.
branches
[
nombranche
]
# merge des deux branches
base
=
repo
.
merge_base
(
enCours
,
master
)
repo
.
index
.
merge_tree
(
master
,
base
=
base
)
# on commit le merge
repo
.
index
.
commit
(
'Mise à jour de la branche principale'
,
parent_commits
=
(
enCours
.
commit
,
master
.
commit
))
return
repo
.
head
.
object
.
hexsha
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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