Show
Ignore:
Timestamp:
11/06/07 18:53:41 (5 years ago)
Author:
francois
Message:

Ajout affichage valeur download et upload

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/server/views.py

    r3 r4  
    44from django.http import HttpResponse, Http404 
    55from bittorrent import Bittorrent 
     6 
     7PREFIX_TEMPLATES = "dev" 
    68 
    79def error_page(titre = "Erreur générale",  
     
    4648        # Mise en forme humaine 
    4749        torrents = bittorrent.liste() 
     50        uploadRate = 0 
     51        downloadRate = 0 
    4852        for torrent in torrents: 
     53                uploadRate += torrent['upload_speed'] 
     54                downloadRate += torrent['download_speed'] 
    4955                torrent['taille'] = bytes2human(torrent['taille']) 
    5056                torrent['total_envoi'] = bytes2human(torrent['total_envoi']) 
     
    5460                'nb_torrent': len(torrents), 
    5561                'torrents' : torrents, 
     62                'upload_speed' : bytes2human(uploadRate) + "s", 
     63                'download_speed' : bytes2human(downloadRate) + "s", 
    5664                'download_limit' : bittorrent.download_limit, 
    5765                'upload_limit' : bittorrent.upload_limit, 
     
    6371                                                           bittorrent.upload_limit), 
    6472        }) 
    65         template = loader.get_template("index.html") 
     73        template = loader.get_template(PREFIX_TEMPLATES + "/index.html") 
    6674        return HttpResponse(template.render(c)) 
    6775                 
     
    95103        else: 
    96104                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") 
    102109        return HttpResponse(template.render(c)) 
    103110 
     
    126133        else: 
    127134                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                     }) 
    135141        return HttpResponse(template.render(c)) 
    136142 
     
    159165                else: 
    160166                        confirmation = True 
    161  
    162167        else: 
    163168                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                     }) 
    170174         
    171175        return HttpResponse(template.render(c))