Переглянути джерело

Merge branch 'tr4ck3ur/various_fixes_2017' of JM2L/jm2l into master

master
JM2L 7 роки тому
committed by Gogs
джерело
коміт
a9f4dd1975
7 змінених файлів з 79 додано та 24 видалено
  1. +2
    -2
      jm2l/__init__.py
  2. +2
    -1
      jm2l/badge.py
  3. +20
    -4
      jm2l/models.py
  4. +7
    -3
      jm2l/templates/Participant/list_users.mako
  5. +22
    -3
      jm2l/templates/Profil/Profil.mako
  6. +1
    -1
      jm2l/templates/layout.mako
  7. +25
    -10
      jm2l/views.py

+ 2
- 2
jm2l/__init__.py Переглянути файл

@@ -126,8 +126,8 @@ def main(global_config, **settings):
config.add_route('action_salle', '/Salles/{action:(\w+)}/{salle_id:(\d+)}')
config.add_route('pict_salle', '/salle_picture/{salle_id:(\d+)}')

config.add_route('list_users', '/ListParticipant')
config.add_route('list_orga', '/ListOrga')
config.add_route('list_users', '/{year:\d+}/ListParticipant')
config.add_route('list_orga', '/{year:\d+}/ListOrga')

# HTML Routes - Public
config.add_route('home', '/{year:(\d+/)?}')


+ 2
- 1
jm2l/badge.py Переглянути файл

@@ -11,6 +11,7 @@ from reportlab.lib.units import mm
import qrcode
import subprocess
from .upload import MediaPath
from jm2l.const import CurrentYear
# Create PDF container
EXPIRATION_TIME = 300 # seconds
WIDTH = 85 * mm
@@ -32,7 +33,7 @@ def JM2L_Logo(canvas, Offset=(0,0)):
yearobject.setTextRenderMode(0)
yearobject.setTextOrigin(OffX+12 , OffY+35)
yearobject.setWordSpace(13)
yearobject.textLines("2 0 1 5")
yearobject.textLines(" ".join(str(CurrentYear)))
canvas.drawText(yearobject)

def Tiers_Logo(canvas, DispUser, StartPos=None, Offset=(0,0)):


+ 20
- 4
jm2l/models.py Переглянути файл

@@ -184,7 +184,13 @@ class User(Base):
return None

@property
def is_Intervenant(self, year=CurrentYear):
def is_Intervenant(self):
""" This property will return if User do an event on specified year """
return DBSession.query(Event).join(User_Event) \
.filter(User_Event.user_uid==self.uid) \
.filter(Event.for_year==CurrentYear).count()

def is_IntervenantOnYear(self, year=CurrentYear):
""" This property will return if User do an event on specified year """
return DBSession.query(Event).join(User_Event) \
.filter(User_Event.user_uid==self.uid) \
@@ -193,7 +199,14 @@ class User(Base):
@property
def is_crew(self, year=CurrentYear):
""" This property will return if User subscribe orga task on specified year """
return DBSession.query(User,Sejour.orga_part).outerjoin(Sejour).filter(User.uid == self.uid).one()[1]
orga_checked = DBSession.query(User, Sejour.orga_part)\
.outerjoin(Sejour) \
.filter(Sejour.for_year == year)\
.filter(User.uid == self.uid).first()
if orga_checked:
return orga_checked
else:
return False
def year_events(self, EventType='All', year=CurrentYear):
@@ -591,8 +604,11 @@ class Sejour(Base):
last_change = Column(DateTime, default=datetime.datetime.now)
@classmethod
def by_user(cls, uid):
return DBSession.query(cls).filter(cls.user_id == uid).first()
def by_user(cls, uid, year):
return DBSession.query(cls)\
.filter(cls.user_id == uid)\
.filter(cls.for_year == year)\
.first()

class Event(Base):
__tablename__ = 'events'


+ 7
- 3
jm2l/templates/Participant/list_users.mako Переглянути файл

@@ -23,8 +23,12 @@ now = datetime.datetime.now()
</tr>
</thead>
<tbody id="list">
% for u, s in Users:
<tr>
% for u, s in Users:
% if u.is_IntervenantOnYear(for_year):
<tr>
% else:
<tr style="color:lightgray">
% endif
<td style="text-align:center;">
<span class="data">${u.slug}</span>
<a href="/MesJM2L?user=${u.uid}">${u.nom} ${u.prenom}</a><br />
@@ -38,7 +42,7 @@ now = datetime.datetime.now()
<i class="icon-star"></i>
</a>
% endif
% if u.Staff==0:
% if u.is_IntervenantOnYear(for_year):
<a href="javascript:alert('${u.nom}, ${u.prenom}\nIntervenant');">
<i class="icon-user"></i>
</a>


+ 22
- 3
jm2l/templates/Profil/Profil.mako Переглянути файл

@@ -4,15 +4,21 @@

##<form id="ProfilForm" action="javascript:DoPost('/2015/modal/Place/${form.place_id.data}');">
% if uprofil!=request.user and request.user.uid==1:
<form id="ProfilForm" action="/MesJM2L?user=${uprofil.uid}" method="POST">
<form id="ProfilForm" action="#" method="POST">
% else:
<form id="ProfilForm" action="/MesJM2L" method="POST">
% endif

<div class="row-fluid">
<div class="span8">
% if uprofil!=request.user and request.user.Staff==1:
<a href="/sign/jm2l/${uprofil.my_hash}">Se connecter "en tant que" ${uprofil.nom} ${uprofil.prenom}</a> -
<a href="/user/${uprofil.slug}">Son profil public</a><br>
% else:
<a href="/sign/jm2l/${uprofil.my_hash}">Mon lien de connection</a> -
<a href="/user/${request.user.slug}">Mon profil public</a><br>
% endif

<h3>${profil_form.prenom.data} ${profil_form.nom.data}</h3>
<%
DicFormA = {
@@ -69,10 +75,14 @@ DicForm2 = {
<dl>
<dt>SSID</dt>
<dd>Unice-HotSpot</dd>
<dt>Votre utilisateur:</dt>
<!--
<dt>Votre utilisateur:</dt>
<dd>${uprofil.wifi_user}</dd>
<dt>Le mot de passe:</dt>
<dd>${uprofil.wifi_pass}</dd>
-->
<dt>Vos identifiants:</dt>
<dd>Nous n'avons pas encore l'information</dd>
</dl>
<a href="https://wifi.unice.fr/">Plus de détails ...</a>
</div>
@@ -158,7 +168,9 @@ ${helpers.DisplayRespForm(profil_form, DicFormB)}
<tfoot>
<tr>
<td colspan="5" style="text-align:center;line-height: 3em;">
<span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Je fais partie de ...</span>
% if uprofil==request.user:
<span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Je fais partie de ...</span>
% endif
</td>
</tr>
</tfoot>
@@ -167,7 +179,14 @@ ${helpers.DisplayRespForm(profil_form, DicFormB)}
</fieldset>

<div class="span2 offset5">
% if uprofil!=request.user and request.user.Staff==1:
En tant que Staff des JM2L, <br />
Je me connecte "en tant que" <br />
<a href="/sign/jm2l/${uprofil.my_hash}"> ${uprofil.nom} ${uprofil.prenom}</a><br />
pour modifier sa fiche ...
% else:
<input class="btn btn-primary" type="submit" value="Enregistrer !" />
% endif
</div>
</form>



+ 1
- 1
jm2l/templates/layout.mako Переглянути файл

@@ -126,7 +126,7 @@ ${helpers.uploader_js()}
% if request.user:
% if request.user.Staff:
<li><a href="/${DisplayYear}/Staff">Partie Staff</a></li>
<li><a href="/ListParticipant">Gérer les intervenants</a></li>
<li><a href="/${DisplayYear}/ListParticipant">Gérer les intervenants</a></li>
<li><a href="/ListSalles">Gérer les salles</a></li>
<li><a href="/entities">Gérer les entités</a></li>
<li><a href="/${DisplayYear}/ListOrga">Participations à l'orga</a></li>


+ 25
- 10
jm2l/views.py Переглянути файл

@@ -13,6 +13,7 @@ from .forms import *
from .models import *
from .helpers import Orga_helpers
from sqlalchemy import func, or_, text, and_
from sqlalchemy.orm import aliased
from os import path, makedirs, listdir
# Usefull tools
from slugify import slugify
@@ -105,13 +106,13 @@ def ICal_Progamme_Dyn_Request(request):
event = Evt()
event['uid'] = "%d/%d" % ( year, 100 )
event.add('summary', "Les stands JM2L 2015" )
event.add('summary', "Les stands JM2L %s" % year )
event.add('dtstart', datetime.datetime.now().replace(tzinfo=tz, hour=10, minute=00 ) )
event.add('dtend', datetime.datetime.now().replace(tzinfo=tz, hour=18, minute=00 ) )
event.add('created', datetime.datetime.now().replace(tzinfo=tz, hour=10, minute=00 ) )
event.add('description', "https://www.youtube.com/watch?v=91X65eEKxvU&t=6s" )
event.add('location', "http://jm2l.linux-azur.org/img/325.gif" )
event.add('url', "http://jm2l.linux-azur.org/2015/le-programme" )
event.add('url', "http://jm2l.linux-azur.org/%s/le-programme" % CurrentYear)
event.add('priority', 5)
cal.add_component(event)

@@ -814,7 +815,7 @@ def miam(request):
miam_form = MiamForm(request.POST, request.user, meta={'csrf_context': request.session})
if request.method == 'POST' and miam_form.validate():
FicheSejour = Sejour.by_user(request.user.uid)
FicheSejour = Sejour.by_user(request.user.uid, CurrentYear)
if FicheSejour:
Update=True
else:
@@ -846,7 +847,7 @@ def sejour(request):
# Don't answer to users that aren't logged
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
if request.method == 'POST':
FicheSejour = Sejour.by_user(request.user.uid)
FicheSejour = Sejour.by_user(request.user.uid, CurrentYear)
if FicheSejour:
Update=True
else:
@@ -895,7 +896,7 @@ def orga(request):
# Don't answer to users that aren't logged
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
if request.method == 'POST':
FicheSejour = Sejour.by_user(request.user.uid)
FicheSejour = Sejour.by_user(request.user.uid, CurrentYear)
UpdateOrga=False
if FicheSejour:
Update=True
@@ -951,13 +952,23 @@ def vote_logo(request):

@view_config(route_name='list_users', renderer="jm2l:templates/Participant/list_users.mako")
def list_users(request):
for_year = int(request.matchdict.get('year', CurrentYear))
if request.user is None:
# Don't answer to users that aren't logged
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
if not request.user.Staff:
raise HTTPForbidden(u'Vous n\'avez pas l\'autorité suffisante pour effectuer cette action.')
Data = DBSession.query(User, Sejour).outerjoin(Sejour).all()
Repas = DBSession.query(Sejour.repas).all()

stmt = (DBSession.query(Sejour).filter(Sejour.for_year==for_year)).subquery()
adalias = aliased(Sejour, stmt)
Data = DBSession.query(User, adalias ) \
.outerjoin(adalias)\
.all()

Repas = DBSession.query(Sejour.repas) \
.filter(Sejour.for_year == for_year ) \
.all()

DicRepas = {"Ven":0, "Midi":0, "Soir":0}
for r in Repas:
if r[0] is None:
@@ -965,16 +976,20 @@ def list_users(request):
if (r[0] & 1 == 1): DicRepas["Ven"]+=1
if (r[0] & 2 == 2): DicRepas["Midi"]+=1
if (r[0] & 4 == 4): DicRepas["Soir"]+=1
return { 'Users':Data, 'UserEvent' : User_Event, "DicRepas":DicRepas }
return { 'Users':Data, 'UserEvent' : User_Event, "DicRepas":DicRepas, "for_year": for_year }

@view_config(route_name='list_orga', renderer="jm2l:templates/Participant/list_orga.mako")
def list_orga(request):
for_year = int(request.matchdict.get('year', CurrentYear))
if request.user is None:
# Don't answer to users that aren't logged
raise HTTPForbidden(u'Vous devez vous identifier pour obtenir une réponse.')
if not request.user.Staff:
raise HTTPForbidden(u'Vous n\'avez pas l\'autorité suffisante pour effectuer cette action.')
Data = DBSession.query(User, Sejour).outerjoin(Sejour).all()
Data = DBSession.query(User, Sejour)\
.outerjoin(Sejour)\
.filter(Sejour.for_year == for_year)\
.all()
return { 'Users':Data }

@view_config(route_name='jm2l', renderer="jm2l:templates/jm2l.mako")
@@ -1002,7 +1017,7 @@ def jm2l_page(request):
# Feed FicheSejour if any
FicheSejour = Sejour.by_user(profil.uid)
FicheSejour = Sejour.by_user(profil.uid, CurrentYear)
if FicheSejour:
if FicheSejour.repas is not None:
for num, item in enumerate(['RepasVendredi', 'RepasSamediMidi', 'RepasSamediSoir']):


Завантаження…
Відмінити
Зберегти