Skip to content

Commit

Permalink
Merge pull request #548 from rufener/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
rufener authored Jul 27, 2021
2 parents 40aa1c6 + 75f7347 commit cc24801
Show file tree
Hide file tree
Showing 14 changed files with 312 additions and 134 deletions.
18 changes: 4 additions & 14 deletions back/development.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use = egg:infolica

infolica_url_base = http://127.0.0.1:8080/infolica
infolica_mail =
admin_mail =
infolica_smtp =
infolica_balance_mail =
infolica_mail = /*TO COMPLETE*/
admin_mail = /*TO COMPLETE*/
infolica_smtp = /*TO COMPLETE*/
infolica_balance_mail = /*TO COMPLETE*/

pyramid.reload_templates = true
pyramid.debug_authorization = false
Expand Down Expand Up @@ -54,16 +54,6 @@ ldap_login_query_attributes= uid, givenName, sn, mail, telephoneNumber, mobile
# Le scope de la recherche (LEVEL, SUBTREE)
ldap_login_query_scope= SUBTREE

# L'attribut qui correspond au login d'un utilisateur LDAP
ldap_user_attribute_login= uid

# Les autres attributs d'un utilisateur LDAP
ldap_user_attribute_firstname= givenName
ldap_user_attribute_lastname= sn
ldap_user_attribute_telephone= telephoneNumber
ldap_user_attribute_mail= mail
ldap_user_attribute_mobile= mobile


###########################################################
# La configuration de la recherche des groupes dans LDAP
Expand Down
2 changes: 1 addition & 1 deletion back/infolica/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Operateur(Base):
entree = Column(Date, default=datetime.datetime.utcnow, nullable=False)
sortie = Column(Date)
mail = Column(Text)

last_notemaj_id = Column(BigInteger)

class Cadastre(Base):
__tablename__ = 'cadastre'
Expand Down
1 change: 1 addition & 0 deletions back/infolica/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ def includeme(config):
#Notes de mise à jour
config.add_route('notes_maj', '/infolica/api/notes_maj')
config.add_route('version', '/infolica/api/version')
config.add_route('operateur_notes_maj', '/infolica/api/operateur_notes_maj')
1 change: 1 addition & 0 deletions back/infolica/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_error(exc, request):
@view_config(route_name='controle_geometre', request_method='OPTIONS', renderer='json')
@view_config(route_name='controle_geometre_s', request_method='OPTIONS', renderer='json')
@view_config(route_name='save_document', request_method='OPTIONS', renderer='json')
@view_config(route_name='operateur_notes_maj', request_method='OPTIONS', renderer='json')
def options_response_view(request):
"""
Common OPTION RESPONSE
Expand Down
42 changes: 35 additions & 7 deletions back/infolica/views/notes_maj.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from infolica.exceptions.custom_error import CustomError
from infolica.models.constant import Constant
from infolica.models.models import NotesMAJ
from infolica.models.models import NotesMAJ, Operateur
from infolica.scripts.utils import Utils

from datetime import date, datetime
Expand All @@ -19,13 +19,14 @@ def notes_maj_view(request):
if not Utils.check_connected(request):
raise exc.HTTPForbidden()

active = request.params["active"] if "active" in request.params else "false"
lastNoteMaj_id = request.params ["lastNoteMaj_id"] if "lastNoteMaj_id" in request.params else None

query = request.dbsession.query(NotesMAJ)

if active == "true":
today = date.today()
query = query.filter(NotesMAJ.delai - today >= 0)
if not lastNoteMaj_id is None:
if lastNoteMaj_id == 'null':
lastNoteMaj_id = 0
query = query.filter(NotesMAJ.id > lastNoteMaj_id)

query = query.order_by(NotesMAJ.id.desc()).all()

Expand All @@ -39,12 +40,14 @@ def version_view(request):
"""
model_version = request.dbsession.query(NotesMAJ).order_by(NotesMAJ.version.desc()).first()
model_delai = request.dbsession.query(NotesMAJ).order_by(NotesMAJ.delai.desc()).first()
model_lastId = request.dbsession.query(NotesMAJ).order_by(NotesMAJ.id.desc()).first()

now = datetime.now()

version = {
'version': model_version.version,
'isNew': datetime.combine(model_delai.delai, datetime.min.time()) >= now
'isNew': datetime.combine(model_delai.delai, datetime.min.time()) >= now,
'lastId': model_lastId.id
}

return version
Expand Down Expand Up @@ -116,3 +119,28 @@ def notes_maj_delete_view(request):
request.dbsession.delete(model)

return Utils.get_data_save_response(Constant.SUCCESS_DELETE.format(NotesMAJ.__tablename__))


@view_config(route_name='operateur_notes_maj', request_method='PUT', renderer='json')
def operateur_notes_maj_update_view(request):
"""
Update last seen notes_maj in operateur
"""
# Check authorization
if not Utils.check_connected(request):
raise exc.HTTPForbidden()

# Get operateur_id
operateur_id = request.params['operateur_id'] if 'operateur_id' in request.params else None
last_notes_maj_id = request.params['last_notes_maj_id'] if 'last_notes_maj_id' in request.params else None

model = request.dbsession.query(Operateur).filter(Operateur.id == operateur_id).first()

# If result is empty
if not model:
raise CustomError(CustomError.RECORD_WITH_ID_NOT_FOUND.format(Operateur.__tablename__, operateur_id))

# Read params operateur
model.last_notemaj_id = last_notes_maj_id

return Utils.get_data_save_response(Constant.SUCCESS_SAVE.format(Operateur.__tablename__))
8 changes: 1 addition & 7 deletions back/production.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ ldap_login_query_attributes= /*TO COMPLETE*/
# Le scope de la recherche (LEVEL, SUBTREE)
ldap_login_query_scope= SUBTREE

# Les autres attributs d'un utilisateur LDAP
ldap_user_attribute_firstname= givenName
ldap_user_attribute_lastname= sn
ldap_user_attribute_telephone= telephoneNumber
ldap_user_attribute_mail= mail


###########################################################
# La configuration de la recherche des groupes dans LDAP
Expand Down Expand Up @@ -192,7 +186,7 @@ facture_type_facture_id = 1
client_cadastration_id = 2896

# Opérateurs à contacter pour les affaires urgentes
operateur_affaire_urgente = 9,15,21,35,39,45,59,60
operateur_affaire_urgente = 15,21,57,59,60

######################################################################################
# Accès dossiers
Expand Down
5 changes: 4 additions & 1 deletion front/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VUE_APP_API_URL="__url/to/api__"

PUBLIC_PATH = "/infolica"
VUE_APP_STATUS = "developpement"
VUE_APP_STATUS = "development"
VUE_APP_VERSION = "1.0"

#=====================================
Expand Down Expand Up @@ -88,6 +88,8 @@ VUE_APP_SERVICES_ENDPOINT = "/services/"
VUE_APP_FACTURE_ENDPOINT = "/factures/"
VUE_APP_EMOLUMENTS_ENDPOINT = "/emoluments"
VUE_APP_EMOLUMENTS_FACTURE_ENDPOINT = "/emolument_facture"
VUE_APP_EMOLUMENT_AFFAIRE_ENDPOINT = "/emolument_affaire"
VUE_APP_EMOLUMENT_ENDPOINT = "/emolument"

#Etapes de l'affaire
VUE_APP_ETAPES_INDEX_ENDPOINT = "/etapes_index/"
Expand Down Expand Up @@ -161,6 +163,7 @@ VUE_APP_RELPATH_DESIGNATIONS_ENDPOINT = "/A_Administratif/Désignations"
#Notes de mise à jour programme
VUE_APP_NOTESMAJ_ENDPOINT = "/notes_maj"
VUE_APP_VERSION_ENDPOINT = "/version"
VUE_APP_OPERATEUR_LASTNOTEMAJ_ENDPOINT = "/operateur_notes_maj"

#=====================================
#======== FORMATS DATES ========
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ export default {
numeros_references_card: [
this.typesAffaires_conf.cadastration,
this.typesAffaires_conf.pcop,
this.typesAffaires_conf.ppe,
this.typesAffaires_conf.mat_diff,
this.typesAffaires_conf.revision_abornement,
Expand Down
3 changes: 1 addition & 2 deletions front/src/components/Header/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export default {
*/
openNotesMAJ() {
this.$root.$emit("openNotesMAJ");
}
},
},
mounted: function(){
Expand Down
163 changes: 92 additions & 71 deletions front/src/components/Login/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<script>
import {handleException} from '@/services/exceptionsHandler';
import {checkPermission, setCurrentUserFunctions} from '@/services/helper';
import {setCurrentUserFunctions} from '@/services/helper';
export default {
name: 'Login',
Expand All @@ -16,85 +16,106 @@ export default {
},
methods:{
/**
* Login
*/
async doLogin () {
this.showProgess = true;
var formData = new FormData();
formData.append("login", this.$refs.username.value);
formData.append("password", this.$refs.userpass.value);
/**
* Login
*/
async doLogin () {
this.showProgess = true;
var formData = new FormData();
formData.append("login", this.$refs.username.value);
formData.append("password", this.$refs.userpass.value);
this.$http.post(
process.env.VUE_APP_API_URL + process.env.VUE_APP_LOGIN_ENDPOINT,
formData,
{
withCredentials: true,
headers: {"Accept": "application/json"}
}
)
.then(response =>{
if(response && response.data && response.data.id){
this.processLogin(response.data);
this.$router.push({ name: "Cockpit"});
} else {
this.showProgess = false;
this.$refs.userpass.value = "";
this.$root.$emit("ShowError", "Le nom d'utilisateur ou le mot de passe est incorrect")
}
})
//Error
.catch(err => {
this.showProgess = false;
handleException(err, this);
})
},
/**
* Logout
*/
async doLogout () {
this.$http.get(
process.env.VUE_APP_API_URL + process.env.VUE_APP_LOGOUT_ENDPOINT,
{
withCredentials: true,
headers: {"Accept": "application/json"}
}
)
.then(() =>{
localStorage.removeItem('infolica_user');
})
//Error
.catch(err => {
handleException(err, this);
})
},
this.$http.post(
process.env.VUE_APP_API_URL + process.env.VUE_APP_LOGIN_ENDPOINT,
formData,
{
withCredentials: true,
headers: {"Accept": "application/json"}
}
)
.then(response =>{
if(response && response.data && response.data.id){
this.processLogin(response.data);
this.$router.push({ name: "Cockpit"});
} else {
this.showProgess = false;
this.$refs.userpass.value = "";
this.$root.$emit("ShowError", "Le nom d'utilisateur ou le mot de passe est incorrect")
}
})
//Error
.catch(err => {
this.showProgess = false;
handleException(err, this);
})
},
/**
* Logout
*/
async doLogout () {
this.$http.get(
process.env.VUE_APP_API_URL + process.env.VUE_APP_LOGOUT_ENDPOINT,
{
withCredentials: true,
headers: {"Accept": "application/json"}
}
)
.then(() =>{
localStorage.removeItem('infolica_user');
})
//Error
.catch(err => {
handleException(err, this);
})
},
/**
* Process login
*/
processLogin (data) {
localStorage.setItem('infolica_user', JSON.stringify(data));
setCurrentUserFunctions().then(() => {
this.$root.$emit("notesMaj_hasAdminRights");
});
this.$root.$emit('infolica_user_logged_in', data);
},
/**
* Process login
*/
processLogin (data) {
localStorage.setItem('infolica_user', JSON.stringify(data));
setCurrentUserFunctions().then(() => {
this.$root.$emit("notesMaj_hasAdminRights", checkPermission(process.env.VUE_APP_FONCTION_ADMIN));
});
this.$root.$emit('infolica_user_logged_in', data);
},
/**
* Process logout
*/
processLogout () {
localStorage.setItem('infolica_user', null);
this.$root.$emit('notesMaj_set_default_params');
this.$root.$emit('infolica_user_logged_out');
/**
* Process logout
*/
processLogout () {
localStorage.setItem('infolica_user', null);
this.$root.$emit('infolica_user_logged_out');
if(this.$router && this.$router.currentRoute && this.$router.currentRoute.name != 'Login')
this.$router.push({ name: "Login"});
},
if(this.$router && this.$router.currentRoute && this.$router.currentRoute.name != 'Login')
this.$router.push({ name: "Login"});
/**
* get version of Infolica
*/
async getVersion() {
this.$http.get(
process.env.VUE_APP_API_URL + process.env.VUE_APP_VERSION_ENDPOINT,
{
withCredentials: true,
headers: {"Accept": "application/json"}
}
).then(response => {
if (response && response.data) {
this.$root.$emit("checkVersion", response.data.version, false);
}
}).catch(err => handleException(err));
},
},
mounted: function(){
this.getVersion();
//Logout
this.$root.$on("infolica_user_logout", () => {
this.doLogout();
Expand Down
1 change: 0 additions & 1 deletion front/src/components/Main/main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.main{
height: calc(100% - 60px);
width: 100%;
float: left;
padding: 0px 10px 10px 10px;
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/Main/main.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="main">
<div class="main" id="main">
<router-view />
</div>
Loading

0 comments on commit cc24801

Please sign in to comment.