Changeset 4 for trunk/src/server/views.py
- Timestamp:
- 11/06/07 18:53:41 (5 years ago)
- Files:
-
- 1 modified
-
trunk/src/server/views.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/server/views.py
r3 r4 4 4 from django.http import HttpResponse, Http404 5 5 from bittorrent import Bittorrent 6 7 PREFIX_TEMPLATES = "dev" 6 8 7 9 def error_page(titre = "Erreur générale", … … 46 48 # Mise en forme humaine 47 49 torrents = bittorrent.liste() 50 uploadRate = 0 51 downloadRate = 0 48 52 for torrent in torrents: 53 uploadRate += torrent['upload_speed'] 54 downloadRate += torrent['download_speed'] 49 55 torrent['taille'] = bytes2human(torrent['taille']) 50 56 torrent['total_envoi'] = bytes2human(torrent['total_envoi']) … … 54 60 'nb_torrent': len(torrents), 55 61 'torrents' : torrents, 62 'upload_speed' : bytes2human(uploadRate) + "s", 63 'download_speed' : bytes2human(downloadRate) + "s", 56 64 'download_limit' : bittorrent.download_limit, 57 65 'upload_limit' : bittorrent.upload_limit, … … 63 71 bittorrent.upload_limit), 64 72 }) 65 template = loader.get_template( "index.html")73 template = loader.get_template(PREFIX_TEMPLATES + "/index.html") 66 74 return HttpResponse(template.render(c)) 67 75 … … 95 103 else: 96 104 state = "NOPOST" 97 c = Context({ 98 'etat' : state, 99 'form' : form.as_p(), 100 }) 101 template = loader.get_template("add.html") 105 c = Context({'etat' : state, 106 'form' : form.as_p(), 107 }) 108 template = loader.get_template(PREFIX_TEMPLATES + "/add.html") 102 109 return HttpResponse(template.render(c)) 103 110 … … 126 133 else: 127 134 form = MoveTorrentForm() 128 template = loader.get_template("move.html") 129 c = Context({ 130 'destination' : destination, 131 'resultat' : resultat, 132 'torrent' : info, 133 'form' : form.as_p(), 134 }) 135 template = loader.get_template(PREFIX_TEMPLATES + "/move.html") 136 c = Context({'destination' : destination, 137 'resultat' : resultat, 138 'torrent' : info, 139 'form' : form.as_p(), 140 }) 135 141 return HttpResponse(template.render(c)) 136 142 … … 159 165 else: 160 166 confirmation = True 161 162 167 else: 163 168 return HttpResponse("Erreur inconnue ....") 164 template = loader.get_template("delete.html") 165 c = Context({ 166 'confirmation' : confirmation, 167 'idtorrent' : idtorrent, 168 'torrent' : info, 169 }) 169 template = loader.get_template(PREFIX_TEMPLATES + "/delete.html") 170 c = Context({'confirmation' : confirmation, 171 'idtorrent' : idtorrent, 172 'torrent' : info, 173 }) 170 174 171 175 return HttpResponse(template.render(c))
