Sfoglia il codice sorgente

Added mail handling

removed tests routes for production
master
tr4ck3ur des JM2L 9 anni fa
parent
commit
fda1b5cf1a
9 ha cambiato i file con 109 aggiunte e 55 eliminazioni
  1. +22
    -4
      README.txt
  2. +4
    -0
      development.ini
  3. +3
    -19
      jm2l/__init__.py
  4. +5
    -1
      jm2l/auth.py
  5. +28
    -28
      jm2l/models.py
  6. +39
    -1
      jm2l/templates/NewIndex.mako
  7. +1
    -1
      jm2l/templates/Profil/Profil.mako
  8. +4
    -0
      production.ini
  9. +3
    -1
      setup.py

+ 22
- 4
README.txt Vedi File

@@ -4,11 +4,29 @@ JM2L README
Getting Started
---------------

- cd <directory containing this file>
Let's install JM2L event website :

- $VENV/bin/python setup.py develop
First we create a virtualenv

- $VENV/bin/initialize_JM2L_db development.ini
virtualenv --no-site-packages jm2l_venv
source jm2l_venv/bin/activate

- $VENV/bin/pserve development.ini
git clone http://git.style-python.fr/jm2l/

cd jm2l

python setup.py develop

initialize_JM2L_db development.ini

pserve development.ini

If no error occurs, the webserver should be available on http://localhost:8080/


source jm2l_venv/bin/activate
cd jm2l
pserve development.ini

Enjoy !

+ 4
- 0
development.ini Vedi File

@@ -6,12 +6,16 @@
[app:main]
use = egg:JM2L

mail.host = localhost
mail.port = 25

pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid.includes =
pyramid_mailer.testing
pyramid_debugtoolbar
pyramid_tm
pyramid_mako


+ 3
- 19
jm2l/__init__.py Vedi File

@@ -7,6 +7,7 @@ from sqlalchemy import engine_from_config
from pyramid.renderers import render_to_response
from .models import DBSession, get_user
from .security import EntryFactory, groupfinder
from pyramid_mailer import mailer_factory_from_settings
import locale

def main(global_config, **settings):
@@ -28,6 +29,7 @@ def main(global_config, **settings):
authentication_policy=authentication_policy,
authorization_policy=authorization_policy
)
config.registry['mailer'] = mailer_factory_from_settings(settings)
config.add_renderer('json', JSON(indent=4))
config.add_renderer('jsonp', JSONP(param_name='callback'))
config.set_session_factory(my_session_factory)
@@ -38,9 +40,7 @@ def main(global_config, **settings):
config.add_static_view('js', 'static/js', cache_max_age=3600)
config.add_static_view('vendor', 'static/vendor', cache_max_age=3600)
config.add_static_view('upload', 'upload', cache_max_age=3600)
config.add_route('tester', '/tester')

# ICal Routes
config.add_route('progr_iCal', '/{year:\d+}/JM2L.ics')
@@ -99,25 +99,9 @@ def main(global_config, **settings):
config.add_route('bymail', '/sign/jm2l/{hash}')
# Handle Multimedia and Uploads
config.add_route('media_uploadform', '/test2')
config.add_route('media_view', '/image/{media_table:\w+}/{uid:\d+}/{name:.+}')
config.add_route('media_upload', '/uploader/{media_table:\w+}/{uid:\d+}/proceed{sep:/*}{name:.*}')

# To Trash routes
config.add_route('test', '/test')
config.add_route('test2', '/toast{sep:/*}{uid:(\d+)?}')

#config.add_route('link_user_entity', '/entity/{uid:(\d+)}/{year:\d+}/user/{user_id:(\d+)}')
#config.add_route('link_role_entity', '/entity/{uid:(\d+)}/{year:\d+}/role/{role_id:(\d+)}')

config.add_route('IntAdd', '/IntAdd/{modtype:\w+}')
config.add_route('IntProp', '/IntProp/{modtype:\w+}')

config.add_route('blog', '/blog/{id:\d+}/{slug}')
config.add_route('blog_action', '/blog/{action}',
factory='jm2l.security.EntryFactory')

config.scan()
return config.make_wsgi_app()



+ 5
- 1
jm2l/auth.py Vedi File

@@ -2,7 +2,7 @@
from pyramid.view import view_config
from pyramid.security import remember, forget
from pyramid.httpexceptions import HTTPFound
from .models import User
from .models import User, DBSession

@view_config(route_name='auth', match_param="action=login", renderer="jm2l:templates/login.mako")
def login(request):
@@ -13,6 +13,8 @@ def bymail(request):
myhash = request.matchdict.get('hash', "")
user = User.by_hash(myhash)
if user:
user.last_logged=datetime.datetime.now()
DBSession.merge(user)
headers = remember(request, user.uid)
return HTTPFound(location=request.route_url('jm2l'),
headers=headers)
@@ -29,6 +31,8 @@ def sign_in_out(request):
if username:
user = User.by_name(username)
if user and user.verify_password(request.POST.get('password')):
user.last_logged=datetime.datetime.now()
DBSession.merge(user)
headers = remember(request, user.uid)
return HTTPFound(location=request.route_url('jm2l'),
headers=headers)


+ 28
- 28
jm2l/models.py Vedi File

@@ -87,10 +87,10 @@ class JM2L_Year(Base):
description = Column(UnicodeText)
doss_presse = Column(UnicodeText)
state = Column(Enum('Archived', 'Cancelled', 'Ongoing'))
start_time = Column(DateTime, default=datetime.datetime.utcnow)
end_time = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
start_time = Column(DateTime, default=datetime.datetime.now)
end_time = Column(DateTime, default=datetime.datetime.now)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)
@property
def AvailableTimeSlots(self, TimeStep=30):
@@ -121,9 +121,9 @@ class User(Base):
fonction = Column(Unicode(80))
website = Column(Unicode(100))
phone = Column(Unicode(10))
created = Column(DateTime, default=datetime.datetime.utcnow)
last_logged = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
last_logged = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)
active = Column(Integer, default=1)
bio = Column(UnicodeText)
gpg_key = Column(UnicodeText)
@@ -231,8 +231,8 @@ class Tiers(Base):
description = Column(UnicodeText)
website = Column(Unicode(100))
tiers_type = Column(Integer, ForeignKey('tiers_opt.uid'), default=1)
created = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)
# relations
ent_type = relationship('TiersOpt')
#members = relationship('User', secondary='user_tiers_link' )
@@ -307,7 +307,7 @@ class Media(Base):
height = Column(Integer)
length = Column(Integer)
filename = Column(UnicodeText)
created = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
@property
def get_path(self):
@@ -334,8 +334,8 @@ class Salles(Base):
name = Column(Unicode(40))
place_type = Column(Enum('Conference', 'Stand', 'Ateliers', 'Autres'))
description = Column(UnicodeText) # Description du matériel disponible
created = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)

@classmethod
def by_id(cls, uid):
@@ -358,8 +358,8 @@ class Place(Base):
website = Column(Unicode(100))
description = Column(UnicodeText)
created_by = Column(Integer, ForeignKey('users.user_id'))
created = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)

@classmethod
def by_id(cls, uid):
@@ -389,8 +389,8 @@ class Itineraire(Base):
tr_avion = Column(Boolean, default=False)
description = Column(UnicodeText)
created_by = Column(Integer, ForeignKey('users.user_id')) # User link
created = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)
# relations
start = relationship(Place, foreign_keys=[start_place])
arrival = relationship(Place, foreign_keys=[arrival_place])
@@ -413,8 +413,8 @@ class Exchange(Base):
# Users
asker_id = Column(Integer, ForeignKey('users.uid')) # User link
provider_id = Column(Integer, ForeignKey('users.uid')) # User link
start_time = Column(DateTime, default=datetime.datetime.utcnow)
end_time = Column(DateTime, default=datetime.datetime.utcnow)
start_time = Column(DateTime, default=datetime.datetime.now)
end_time = Column(DateTime, default=datetime.datetime.now)
# Co-voiturage
itin_id = Column(Integer, ForeignKey('itineraire.itin_id')) # Itineraire link
# Hebergement
@@ -424,8 +424,8 @@ class Exchange(Base):
description = Column(UnicodeText)
pictures = Column(Unicode(80))
created_by = Column(Integer) # User link
created = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)
# relations
Category = relationship(Exchange_Cat, backref="exchanges")
Itin = relationship(Itineraire, backref="exchanged")
@@ -517,8 +517,8 @@ class Sejour(Base):
arrival_place = Column(Integer, ForeignKey('place.place_id')) # Place link
depart_time = Column(DateTime)
depart_place = Column(Integer, ForeignKey('place.place_id')) # Place link
created = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)

class Event(Base):
__tablename__ = 'events'
@@ -529,11 +529,11 @@ class Event(Base):
name = Column(Unicode(100), nullable=False)
slug = Column(Unicode(100))
event_type = Column(Enum('Stand', 'Table ronde', 'Atelier', 'Concert', 'Conference', 'Repas'))
start_time = Column(DateTime, default=datetime.datetime.utcnow)
end_time = Column(DateTime, default=datetime.datetime.utcnow)
start_time = Column(DateTime, default=datetime.datetime.now)
end_time = Column(DateTime, default=datetime.datetime.now)
description = Column(UnicodeText)
created = Column(DateTime, default=datetime.datetime.utcnow)
last_change = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
last_change = Column(DateTime, default=datetime.datetime.now)
intervenants = relationship(User,
secondary='user_event_link',
backref=backref('participate', uselist=False),
@@ -581,8 +581,8 @@ class Entry(Base):
active = Column(Integer, default=True)
title = Column(Unicode(255), unique=True, nullable=False)
body = Column(UnicodeText, default=u'')
created = Column(DateTime, default=datetime.datetime.utcnow)
edited = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
edited = Column(DateTime, default=datetime.datetime.now)
@classmethod
def all(cls):


+ 39
- 1
jm2l/templates/NewIndex.mako Vedi File

@@ -11,4 +11,42 @@
<!-- The default timeline stylesheet -->
<link rel="stylesheet" href="/vendor/timeline/css/timeline.css" />
</%def>
<div id="timeline" style="margin-left: -50px;"></div>
<div id="timeline" style="margin-left: -50px;display:block;"></div>
<div class="clearfix">&nbsp;</div>
<div style="top:500px;position: relative">
<p>
Le 28 Novembre 2015 aura lieu la 9e édition des Journées Méditerranéennes du Logiciel Libre (JM2LL) à
Sophia-Antipolis destinées tout public (http://jm2l.linux-azur.org/).
<br>
Le thème de cette année sera « Do It Yourself » ou « Faîtes le vous-même » :
</p>
<ul>
<li>Migration vers les logiciels libres</li>
<li>Libres enfants du numérique : jeux et loisirs pour les juniors.</li>
<li>Gérer ses données personnelles</li>
<li>Do It Yourself (jeux vidéos, fablabs…)</li>
<li>Culture libre</li>
<li>Communautés du libre</li>
</ul>
<p>
Nous faisons appel aux acteurs du numérique libre pour alimenter le programme des conférences/ateliers :
si vous souhaitez échanger avec le public et partager un bon moment avec la communauté, inscrivez-vous !
</p>
<p>
Nous vous proposons cinq formats de contribution :
<ul>
<li>Stands au sein du village associatif</li>
<li>Conférences de 20 ou 40 minutes suivies d’un échange</li>
<li>Ateliers de 45 minutes ou 1h15</li>
<li>Démos de vos matériels, logiciels ou projets libres</li>
<li>Animations ouvertes</li>
</ul>
</p>
<p>
Il sera bien sûr possible de combiner plusieurs formats (par exemple, une démo ou une conférence suivie
d’un atelier).
</p>
<p>
Vous pouvez nous faire parvenir vos propositions directement via le menu participer.
</p>
</div>

+ 1
- 1
jm2l/templates/Profil/Profil.mako Vedi File

@@ -4,7 +4,7 @@
<div id="Photos">
${helpers.show_my_pictures(uprofil)}
</div>
<a href="/sign/jm2l/${uprofil.my_hash}">Mon lien</a>
<a href="/sign/jm2l/${uprofil.my_hash}">Mon lien</a>
<h3>${profil_form.prenom.data} ${profil_form.nom.data}</h3>

##<form id="ProfilForm" action="javascript:DoPost('/2015/modal/Place/${form.place_id.data}');">


+ 4
- 0
production.ini Vedi File

@@ -6,12 +6,16 @@
[app:main]
use = egg:JM2L

mail.host = localhost
mail.port = 25

pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = fr
pyramid.includes =
pyramid_mailer
pyramid_tm
pyramid_mako
pyramid_exclog


+ 3
- 1
setup.py Vedi File

@@ -27,7 +27,9 @@ requires = [
'icalendar',
'python-magic',
'Pillow',
'pyramid_exclog'
'pyramid_exclog',
'repoze.sendmail==4.1',
'pyramid_mailer'
]

setup(name='JM2L',


Caricamento…
Annulla
Salva