Changeset 2104
- Timestamp:
- 07/05/10 12:56:53 (19 months ago)
- Location:
- trunk/loreality
- Files:
-
- 8 added
- 2 deleted
- 20 edited
-
data (deleted)
-
development.db (modified) (previous)
-
development.ini (modified) (1 diff)
-
launch.sh (added)
-
loreality.egg-info (deleted)
-
loreality/config/deployment.ini_tmpl (modified) (1 diff)
-
loreality/controllers/account.py (modified) (2 diffs)
-
loreality/controllers/campaign.py (modified) (4 diffs)
-
loreality/controllers/mission.py (modified) (6 diffs)
-
loreality/controllers/pilot.py (modified) (4 diffs)
-
loreality/controllers/squadron.py (added)
-
loreality/lib/auth.py (modified) (1 diff)
-
loreality/model/databases.py (modified) (2 diffs)
-
loreality/model/form.py (modified) (1 diff)
-
loreality/public/style.css (modified) (1 diff)
-
loreality/templates/component/campaign.html (modified) (1 diff)
-
loreality/templates/component/navigation.html (modified) (1 diff)
-
loreality/templates/derived/account/signin.html (added)
-
loreality/templates/derived/page/campaign.html (modified) (2 diffs)
-
loreality/templates/derived/page/campaign_edit.html (modified) (2 diffs)
-
loreality/templates/derived/page/mission.html (modified) (2 diffs)
-
loreality/templates/derived/page/mission_edit.html (modified) (2 diffs)
-
loreality/templates/derived/page/overview_campaign.html (added)
-
loreality/templates/derived/page/overview_pilot.html (added)
-
loreality/templates/derived/page/overview_squadron.html (added)
-
loreality/templates/derived/page/pilot.html (modified) (1 diff)
-
loreality/templates/derived/page/squadron.html (added)
-
loreality/tests/functional/test_squadron.py (added)
-
loreality/websetup.py (modified) (2 diffs)
-
setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/loreality/development.ini
r2099 r2104 48 48 authkit.cookie.secret = aoeuidts 49 49 authkit.cookie.signoutpath = /signout 50 authkit.form.template.obj = loreality.lib.auth:render_signin 50 51 51 52 # Logging configuration -
trunk/loreality/loreality/config/deployment.ini_tmpl
r2097 r2104 34 34 sqlalchemy.url = sqlite:///production.db 35 35 36 # Auth 37 authkit.setup.enable = true 38 authkit.setup.method = form, cookie 39 authkit.form.authenticate.user.type = authkit.users.sqlalchemy_driver:UsersFromDatabase 40 authkit.form.authenticate.user.data = loreality.model 41 #authkit.form.authenticate.user.data = dart:admin 42 authkit.cookie.secret = aoeuidts 43 authkit.cookie.signoutpath = /signout 44 authkit.form.template.obj = loreality.lib.auth:render_signin 45 46 36 47 # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* 37 48 # Debug mode will enable the interactive debugging tool, allowing ANYONE to -
trunk/loreality/loreality/controllers/account.py
r2098 r2104 11 11 class AccountController(BaseController): 12 12 13 #-------------------------------------------------------------- 13 14 def signin(self): 14 15 if not request.environ.get('REMOTE_USER'): … … 18 19 return redirect_to(h.url_for(controller='main', action='index')) 19 20 21 #-------------------------------------------------------------- 20 22 def signout(self): 21 23 # The actual removal of the AuthKit cookie occurs when the response passes -
trunk/loreality/loreality/controllers/campaign.py
r2100 r2104 22 22 class CampaignController(BaseController): 23 23 24 #-------------------------------------------------------------- 24 25 def index(self, values=None, errors=None ): 25 c.title = " LoReality"26 c.heading = "Campaign "26 c.title = "All campaigns" 27 c.heading = "Campaigns" 27 28 c.campaigns = meta.Session.query(model.Campaign).all() 29 30 html = render('/derived/page/overview_campaign.html') 31 return htmlfill.render(html, defaults=values, errors=errors) 32 33 #-------------------------------------------------------------- 34 def view(self, id, values=None, errors=None ): 35 if id is None: 36 abort(404) 37 campaign_q = meta.Session.query(model.Campaign) 38 campaign = campaign_q.filter_by(id=uuid.UUID(id)).first() 39 if campaign is None: 40 abort(404) 41 42 c.title = campaign.name 43 c.heading = "Campaigns" 44 c.campaign = campaign 28 45 29 46 html = render('/derived/page/campaign.html') 30 47 return htmlfill.render(html, defaults=values, errors=errors) 31 48 49 #-------------------------------------------------------------- 32 50 def process(self, id=None): 33 51 action = request.params.getone('action') … … 98 116 99 117 campaign.name = result["name"] 118 campaign.description = result["description"] 100 119 meta.Session.commit() 101 return self. edit(id=id)120 return self.view(id=id) 102 121 else: 103 122 raise Exception('Invalid action %s'%action) 104 123 124 #-------------------------------------------------------------- 105 125 @authorize(h.auth.is_creator) 106 126 def edit(self, id=None, values=None, errors=None ): … … 112 132 abort(404) 113 133 114 c.title = " LoReality"115 c.heading = " Edit %s"%campaign.name134 c.title = "Edit %s"%campaign.name 135 c.heading = "Campaigns" 116 136 c.campaign = campaign 117 137 118 138 if not values: values = {} 119 139 values["name"] = campaign.name 140 values["description"] = campaign.description 120 141 121 142 html = render('/derived/page/campaign_edit.html') 122 143 return htmlfill.render(html, defaults=values, errors=errors) 123 144 145 #-------------------------------------------------------------- 124 146 @authorize(h.auth.is_creator) 125 147 def delete(self, id): … … 146 168 return self.edit( id ) 147 169 170 #-------------------------------------------------------------- 148 171 @authorize(h.auth.is_creator) 149 172 def deletecampaign(self, id): -
trunk/loreality/loreality/controllers/mission.py
r2100 r2104 22 22 23 23 class MissionController(BaseController): 24 #-------------------------------------------------------------- 25 def _get_pilots(self, already_pilots): 26 pilots = meta.Session.query(model.Pilot).all() 27 names = [] 28 for p in pilots: 29 if p not in already_pilots: 30 names.append( p.name ) 31 return names 24 32 33 #-------------------------------------------------------------- 25 34 def view(self, id, values=None, errors=None ): 26 35 if id is None: … … 34 43 c.heading = mission.name 35 44 c.mission = mission 45 c.available_pilots = self._get_pilots(mission.pilots) 36 46 37 47 html = render('/derived/page/mission.html') 38 48 return htmlfill.render(html, defaults=values, errors=errors) 39 49 50 #-------------------------------------------------------------- 40 51 def process(self, id=None): 41 52 action = request.params.getone('action') … … 67 78 else: 68 79 raise Exception('Invalid action %s'%action) 80 #-------------------------------------------------------------- 69 81 @authorize(h.auth.is_creator) 70 82 def edit(self, id=None, values=None, errors=None ): … … 79 91 c.heading = "Edit %s"%mission.name 80 92 c.mission = mission 93 c.available_pilots = self._get_pilots(mission.pilots) 81 94 82 95 if not values: values = {} … … 85 98 html = render('/derived/page/mission_edit.html') 86 99 return htmlfill.render(html, defaults=values, errors=errors) 100 #-------------------------------------------------------------- 87 101 @authorize(h.auth.is_creator) 88 102 def addpilot(self, id): 89 103 values = dict(request.params) 90 pilotid = values[" pilotid"]104 pilotid = values["Pilot"] 91 105 if id is None: 92 106 abort(404) … … 99 113 abort(404) 100 114 pilot_q = meta.Session.query(model.Pilot) 101 pilot = pilot_q.filter_by( id=uuid.UUID(pilotid)).first()115 pilot = pilot_q.filter_by(name=pilotid).first() 102 116 if pilot is None: 103 117 abort(404) 104 118 105 119 #- del now 106 mission.pilots.a dd( pilot )120 mission.pilots.append( pilot ) 107 121 meta.Session.commit() 108 122 return self.edit( id ) 123 #-------------------------------------------------------------- 109 124 @authorize(h.auth.is_creator) 110 125 def removepilot(self, id): -
trunk/loreality/loreality/controllers/pilot.py
r2100 r2104 24 24 class PilotController(BaseController): 25 25 26 #-------------------------------------------------------------- 27 def index(self, values=None, errors=None ): 28 c.heading = "Pilots" 29 c.title = "All pilots" 30 31 pilot_q = meta.Session.query(model.Pilot).order_by( model.Pilot.name ) 32 c.pilots = pilot_q.all() 33 34 html = render('/derived/page/overview_pilot.html') 35 return htmlfill.render(html, defaults=values, errors=errors) 36 #-------------------------------------------------------------- 26 37 def view(self, id, values=None, errors=None ): 27 38 if id is None: … … 32 43 abort(404) 33 44 34 c. title = "LoReality"35 c. heading= pilot.name45 c.heading = "Pilots" 46 c.title = pilot.name 36 47 c.pilot = pilot 37 48 … … 39 50 return htmlfill.render(html, defaults=values, errors=errors) 40 51 52 #-------------------------------------------------------------- 41 53 @authorize(h.auth.is_creator) 42 54 def edit(self, id=None, values=None, errors=None ): … … 48 60 abort(404) 49 61 50 c. title = "LoReality"51 c. heading= "Edit %s"%pilot.name62 c.heading = "Pilots" 63 c.title = "Edit %s"%pilot.name 52 64 c.pilot = pilot 53 65 -
trunk/loreality/loreality/lib/auth.py
r2100 r2104 1 1 from authkit.permissions import ValidAuthKitUser, HasAuthKitRole 2 2 from authkit.authorize.pylons_adaptors import authorized 3 from pylons.templating import render_mako as render 4 3 5 4 6 is_valid_user = ValidAuthKitUser() 5 7 is_creator = HasAuthKitRole(['creator']) 8 is_admin = HasAuthKitRole(['admin']) 9 is_leader = HasAuthKitRole(['leader']) 6 10 11 def render_signin(): 12 result = render('/derived/account/signin.html') 13 result = result.replace('%', '%%').replace('FORM_ACTION', '%s') 14 return render('/derived/account/signin.html') 15 -
trunk/loreality/loreality/model/databases.py
r2099 r2104 45 45 id = sa.Column(UUID(), primary_key=True,default=uuid.uuid4) 46 46 name = sa.Column(sa.types.String, nullable=False) 47 description = sa.Column(sa.types.String) 47 48 48 49 missions = orm.relation("Mission", backref="campaign") … … 69 70 self.name = name 70 71 #---------------------------------------------------------------- 72 class Squadron(Base): 73 __tablename__ = 'squadrons' 74 id = sa.Column(UUID(), primary_key=True,default=uuid.uuid4) 75 name = sa.Column(sa.types.String, nullable=False) 76 plane = sa.Column(sa.types.String) 77 78 pilots = orm.relation("Pilot", backref="squadron") 79 80 81 def __init__( self, name ): 82 self.name = name 83 #---------------------------------------------------------------- 71 84 class Pilot(Base): 72 85 __tablename__ = 'pilots' 73 86 id = sa.Column(UUID(), primary_key=True,default=uuid.uuid4) 74 87 name = sa.Column(sa.types.String, nullable=False) 88 login = sa.Column(sa.types.String, nullable=False) 89 squadron_id = sa.Column(UUID(), ForeignKey('squadrons.id')) 75 90 76 91 77 def __init__( self, name ):92 def __init__( self, name, login ): 78 93 self.name = name 94 self.login = login -
trunk/loreality/loreality/model/form.py
r2100 r2104 20 20 pre_validators = [variabledecode.NestedVariables()] 21 21 name = String(not_empty=True) 22 description = String() 22 23 23 24 class MissionNameForm(Schema): -
trunk/loreality/loreality/public/style.css
r2102 r2104 23 23 border-left: 1px solid #000; 24 24 padding-left: 3px; 25 25 } 26 26 27 /* HEADING */ 28 h1 { 29 width: 100%; 30 text-align: center; 31 color: yellow; 27 32 } 33 34 h2{ 35 border-bottom: solid white 1px; 36 } 37 38 h3{ 39 border-bottom: solid white 1px; 40 margin-left: 5px; 41 } 42 -
trunk/loreality/loreality/templates/component/campaign.html
r2100 r2104 23 23 </%def> 24 24 25 <%def name="add_pilot(mission_id )">25 <%def name="add_pilot(mission_id, available_pilots)"> 26 26 % if h.auth.authorized(h.auth.is_creator): 27 27 ${h.form(h.url_for(controller='mission', action='addpilot', id=mission_id))} 28 28 <fieldset><legend>Add a new pilot</legend> 29 29 30 <label for="name_${name}">Name</label><br /> 31 ${h.text(name='name_pilot')} 32 ${h.submit(name="action", value='process')} 30 ${h.select( 31 "Pilot", 32 id='pilotid', 33 selected_values=[], 34 options=available_pilots, 35 )} 36 ${h.submit(name="action", value='Add')} 33 37 </fieldset> 34 38 ${h.end_form()} 35 39 %endif 36 40 </%def> 41 <%def name="add_pilot_to_squadron(squadron_id, available_pilots)"> 42 % if h.auth.authorized(h.auth.is_creator): 43 ${h.form(h.url_for(controller='squadron', action='addpilot', id=squadron_id))} 44 <fieldset><legend>Add a new pilot</legend> 45 46 ${h.select( 47 "Pilot", 48 id='pilotid', 49 selected_values=[], 50 options=available_pilots, 51 )} 52 ${h.submit(name="action", value='Add')} 53 </fieldset> 54 ${h.end_form()} 55 %endif 56 </%def> -
trunk/loreality/loreality/templates/component/navigation.html
r2102 r2104 12 12 <li> <a href=${h.url_for('/')}>Home</a> </li> 13 13 % if h.auth.authorized(h.auth.is_valid_user) and not (request.urlvars['controller'] == 'account' and request.urlvars['action'] == 'signout'): 14 <li> <a href=${h.url_for(controller='campaign', action='index')}>Campaign</a> </li> 14 <li> <a href=${h.url_for(controller='campaign', action='index')}>Campaigns</a> </li> 15 <li> <a href=${h.url_for(controller='squadron', action='index')}>Squadrons</a> </li> 16 <li> <a href=${h.url_for(controller='pilot', action='index')}>Pilots</a> </li> 15 17 % endif 16 18 </ul> -
trunk/loreality/loreality/templates/derived/page/campaign.html
r2100 r2104 3 3 4 4 5 <h2>${c.campaign_title}</h2> 6 <ul> 7 % for camp in c.campaigns: 8 <li>${camp.name} 5 <h2>${c.campaign.name} 9 6 % if h.auth.authorized(h.auth.is_creator): 10 <a href=${h.url_for(controller='campaign', action='edit',id=c amp.id) }>[Edit]</a>7 <a href=${h.url_for(controller='campaign', action='edit',id=c.campaign.id) }>[Edit]</a> 11 8 %endif 9 </h2> 10 <h3>Description</h3> 11 <p>${c.campaign.description}</p> 12 <h3>Missions</h3> 12 13 <ul> 13 % for mission in c amp.missions:14 % for mission in c.campaign.missions: 14 15 <li> <a href=${h.url_for(controller='mission', action='view',id=mission.id) }>${mission.name}</a>( 15 16 % for pilot in mission.pilots: … … 19 20 % if h.auth.authorized(h.auth.is_creator): 20 21 <a href=${h.url_for(controller='mission', action='edit',id=mission.id) }>[Edit]</a> 21 <a href=${h.url_for(missionid=mission.id, controller='campaign', action='delete',id=c amp.id) }>[Del]</a>22 <a href=${h.url_for(missionid=mission.id, controller='campaign', action='delete',id=c.campaign.id) }>[Del]</a> 22 23 %endif 23 24 </li> 24 25 % endfor 25 26 </ul></li> 26 % endfor 27 </ul> 28 ${campaign.add_campaign()} 27 ${campaign.add_mission(c.campaign.id)} 28 % if h.auth.authorized(h.auth.is_creator): 29 <a href=${h.url_for(controller='campaign', action='deletecampaign',id=c.campaign.id) }>[Delete the campaign]</a></li> 30 %endif 31 <a href=${h.url_for(controller='campaign', action='index') }>[Back to overview]</a></li> -
trunk/loreality/loreality/templates/derived/page/campaign_edit.html
r2100 r2104 3 3 4 4 5 <h2> ${c.campaign.name}</h2>5 <h2><a href=${h.url_for(controller='campaign', action='view',id=c.campaign.id) }>${c.campaign.name}</a></h2> 6 6 7 7 % if h.auth.authorized(h.auth.is_creator): 8 8 ${h.form(h.url_for(controller='campaign', action='process', id=c.campaign.id))} 9 <label for="name">Name</label><br /> 10 ${h.text(name='name')} 9 <label for="name">Name</label> 10 ${h.text(name='name')}<br /> 11 <label for="description">Description</label> 12 ${h.text(name='description')}<br /> 11 13 ${h.submit(name="action", value="Modify")} 12 </fieldset>13 14 ${h.end_form()} 14 15 %endif … … 25 26 </ul> 26 27 ${campaign.add_mission(c.campaign.id)} 27 <a href=${h.url_for(controller='campaign', action='deletecampaign',id=c.campaign.id) }>[Delete the campa gnain]</a></li>28 <a href=${h.url_for(controller='campaign', action='deletecampaign',id=c.campaign.id) }>[Delete the campaign]</a></li> -
trunk/loreality/loreality/templates/derived/page/mission.html
r2100 r2104 3 3 4 4 5 <h2>${c.mission.name}</h2> 6 5 <h2>${c.mission.name} 7 6 % if h.auth.authorized(h.auth.is_creator): 8 <a href=${h.url_for(controller='mission', action='edit',id=c.mission.id) }>[Edit]</a> </li>7 <a href=${h.url_for(controller='mission', action='edit',id=c.mission.id) }>[Edit]</a> 9 8 %endif 9 </h2> 10 10 <ul> 11 11 % for pilot in c.mission.pilots: … … 16 16 % endfor 17 17 </ul> 18 ${campaign.add_pilot(c.mission.id)} 18 %if h.auth.authorized(h.auth.is_creator): 19 ${campaign.add_pilot(c.mission.id, c.available_pilots)} 20 %endif 19 21 22 <a href=${h.url_for(controller='campaign', action='view',id=c.mission.campaign_id) }>[Back to campaign]</a></li> -
trunk/loreality/loreality/templates/derived/page/mission_edit.html
r2100 r2104 1 1 <%inherit file="/base/index.html"/> 2 <%namespace name="campaign" file="/component/campaign.html" import="*" />\ 2 3 3 4 … … 17 18 <li><a href=${h.url_for(controller='pilot', action='view',id=pilot.id) }>${pilot.name}</a> 18 19 % if h.auth.authorized(h.auth.is_creator): 19 <a href=${h.url_for(controller='pilot', action='edit',id=pilot.id) }>[Edit]</a></li> 20 <a href=${h.url_for(controller='pilot', action='edit',id=pilot.id) }>[Edit]</a> 21 <a href=${h.url_for(pilotid=pilot.id, controller='mission', action='removepilot',id=c.mission.id) }>[Remove]</a></li> 20 22 %endif 21 23 %endfor 22 24 </ul> 25 %if h.auth.authorized(h.auth.is_creator): 26 ${campaign.add_pilot(c.mission.id, c.available_pilots)} 27 %endif 28 <a href=${h.url_for(controller='campaign', action='view',id=c.mission.campaign_id) }>[Back to campaign]</a></li> -
trunk/loreality/loreality/templates/derived/page/pilot.html
r2100 r2104 1 1 <%inherit file="/base/index.html"/> 2 <%namespace name="campaign" file="/component/campaign.html" import="*" />\ 2 3 3 4 4 <h2>${c.pilot.name} </h2>5 <h2>${c.pilot.name} - <a href=${h.url_for(controller='squadron', action='view',id=c.pilot.squadron_id) }>${c.pilot.squadron.name}</a></h2> 5 6 6 % if h.auth.authorized(h.auth.is_creator): 7 Login: ${c.pilot.login} 8 % if request.environ['REMOTE_USER'] == c.pilot.login: 9 <p>It is you!</p> 10 %endif 11 % if h.auth.authorized(h.auth.is_admin): 7 12 <a href=${h.url_for(controller='pilot', action='edit',id=c.pilot.id) }>[Edit]</a></li> 8 13 %endif -
trunk/loreality/loreality/websetup.py
r2100 r2104 28 28 users.role_create("admin") 29 29 users.role_create("creator") 30 users.role_create("leader") 30 31 31 32 users.user_create("DArt", password="admin") 32 33 users.user_add_role("DArt", role="admin" ) 33 34 users.user_add_role("DArt", role="creator" ) 35 users.user_add_role("DArt", role="leader" ) 34 36 35 37 users.user_create("Tolteque", password="admin") 38 39 users.user_create("MBug", password="admin") 40 users.user_add_role("MBug", role="leader" ) 36 41 37 42 log.info("Adding mission...") … … 42 47 cam.missions.append( mis ) 43 48 44 pil = Pilot("DArt") 49 squ = Squadron("12th") 50 squ.plane = "F-15C" 51 meta.Session.add( squ ) 52 53 pil = Pilot("DArt", "DArt") 45 54 meta.Session.add( pil ) 46 55 mis.pilots.append( pil ) 56 squ.pilots.append( pil ) 47 57 48 pil = Pilot("Tolteque" )58 pil = Pilot("Tolteque", "Tolteque") 49 59 meta.Session.add( pil ) 50 60 mis.pilots.append( pil ) 61 squ.pilots.append( pil ) 62 63 squ = Squadron("92nd") 64 squ.plane = "Su-27" 65 meta.Session.add( squ ) 66 67 pil = Pilot("MajorBug", "MBug") 68 meta.Session.add( pil ) 69 mis.pilots.append( pil ) 70 squ.pilots.append( pil ) 51 71 52 72 mis = Mission("mission 2") -
trunk/loreality/setup.py
r2097 r2104 8 8 setup( 9 9 name='loreality', 10 version='0. 1',11 description=' ',12 author=' ',13 author_email=' ',14 url=' ',10 version='0.0.1', 11 description='Lockon Reality Tool', 12 author='DArt', 13 author_email='dart@dartsite.org', 14 url='http://lotatc.dartsite.org', 15 15 install_requires=[ 16 16 "Pylons>=0.9.7", 17 17 "SQLAlchemy>=0.5", 18 "AuthKit>=0.4.3,<=0.4.99", 19 18 20 ], 19 21 setup_requires=["PasteScript>=1.6.3"],
Note: See TracChangeset
for help on using the changeset viewer.
