~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to wlhelp/management/commands/update_help_pdf.py

  • Committer: kaputtnik
  • Date: 2019-03-31 11:08:21 UTC
  • mto: This revision was merged to the branch mainline in revision 531.
  • Revision ID: kaputtnik-20190331110821-1o6c8ebh1sag7xat
mv main files into mainpage directory; apply needed changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from ...models import Tribe as TribeModel
2
2
 
3
3
from django.core.management.base import BaseCommand, CommandError
4
 
from settings import MEDIA_ROOT, WIDELANDS_SVN_DIR, MEDIA_URL
 
4
from django.conf import settings
5
5
 
6
6
import os
7
7
import shutil
17
17
    help =\
18
18
        """Update the overview pdfs of all tribes in a current checkout"""
19
19
 
20
 
    def handle(self, json_directory=os.path.normpath(MEDIA_ROOT + '/map_object_info'), **kwargs):
 
20
    def handle(self, json_directory=os.path.normpath(settings.MEDIA_ROOT + '/map_object_info'), **kwargs):
21
21
        source_file = open(os.path.normpath(
22
22
            json_directory + '/tribes.json'), 'r')
23
23
        tribesinfo = json.load(source_file)
31
31
            pdffile = path.join(gdir, tribename + '.pdf')
32
32
            giffile = path.join(gdir, tribename + '.gif')
33
33
 
34
 
            targetdir = path.normpath(path.join(MEDIA_ROOT, 'wlhelp',
 
34
            targetdir = path.normpath(path.join(settings.MEDIA_ROOT, 'wlhelp',
35
35
                                                'network_graphs', tribename))
36
36
 
37
37
            try:
45
45
            tribe = Tribe.objects.get(name=tribename)
46
46
            if tribe:
47
47
                tribe.network_pdf_url = path.normpath(
48
 
                    '%s/%s/%s' % (MEDIA_URL, targetdir[len(MEDIA_ROOT):], tribename + '.pdf'))
 
48
                    '%s/%s/%s' % (settings.MEDIA_URL, targetdir[len(settings.MEDIA_ROOT):], tribename + '.pdf'))
49
49
                tribe.network_gif_url = path.normpath(
50
 
                    '%s/%s/%s' % (MEDIA_URL, targetdir[len(MEDIA_ROOT):], tribename + '.gif'))
 
50
                    '%s/%s/%s' % (settings.MEDIA_URL, targetdir[len(settings.MEDIA_ROOT):], tribename + '.gif'))
51
51
                tribe.save()
52
52
            else:
53
53
                print 'Could not set tribe urls'