Review: Approve
must not be merged before the corresponding WL branch is deployed on the
website.
lgtm to me in general, though I did not test it. What is the plan for
generating the JSON files? It seems you expect them to be dumped into the JSON
directory in the repo - do you want to check those files into the repo or
should they be regenerated on the server?
Diff comments:
>
> === modified file 'wlhelp/management/commands/update_help.py'
> --- wlhelp/management/commands/update_help.py 2012-05-19 19:55:15 +0000
> +++ wlhelp/management/commands/update_help.py 2016-02-28 18:45:27 +0000
> @@ -45,32 +36,45 @@
> Parses the definitions for one tribe and generates the models
>
> name - name of the tribe
> - conf - path to the tribe/conf file
> """
> - self._tribe = Tribe(name)
> + self._delete_old_media_dir(name) # You can deactivate this line if
> you don't need to clean house.
I feel uneasy about that line. While the media directory is deleted, all
requests will return 404. It would be better do build into media_20160214, then
`ln -sf media_20160214 media`, then remove the old media dirs. That way adding
new data is atomic.
> +
> + base_directory = os.path.normpath(WIDELANDS_SVN_DIR + "/data")
> + json_directory = os.path.normpath(base_directory +
> "/map_object_info")
> +
> + tribeinfo_file = open(os.path.normpath(json_directory + "/tribe_" +
> name + ".json"), "r")
> + tribeinfo = json.load(tribeinfo_file)
> +
> + self._tribe = Tribe(tribeinfo, json_directory)
> # Generate the Tribe
> self._to = TribeModel.objects.get_or_create(name=name.lower())[0]
> - self._to.displayname =
> normalize_name(self._tribe._conf.getstring("tribe", "name"))
> - self._to.descr = normalize_name(self._tribe._conf.getstring("tribe",
> "descr"))
> + self._to.displayname = tribeinfo['descname']
> + self._to.descr = tribeinfo['tooltip']
> # copy icon
> - dn = "%s/wlhelp/img/%s/" % (MEDIA_ROOT,self._to.name)
> + dn = "%s/wlhelp/img/%s/" % (MEDIA_ROOT, tribeinfo['name'])
> try:
> os.makedirs(dn)
> except OSError, o:
> if o.errno != 17:
> raise
> new_name = path.join(dn, "icon.png")
> - file =
> path.join(self._tribe._tdir,self._tribe._conf.getstring("tribe", "icon"))
> + file = os.path.normpath(base_directory + "/" + tribeinfo['icon'])
> shutil.copy(file, new_name )
> self._to.icon_url = path.normpath("%s/%s" % (MEDIA_URL,
> new_name[len(MEDIA_ROOT):]))
> self._to.save()
>
> - def parse( self ):
> + def parse( self, tribename, base_directory, json_directory ):
> """Put all data into the database"""
> - #self._delete_old_media_dir() why delete it? We can simply overwrite
> data
> - self._parse_workers()
> - self._parse_wares()
> - self._parse_buildings()
> + self._delete_old_data(tribename) # You can deactivate this line if
> you don't need to clean house.
> +
> + wares_file = open(os.path.normpath(json_directory + "/" + tribename
> + "_wares.json"), "r")
> + self._parse_wares(base_directory, json.load(wares_file))
> +
> + workers_file = open(os.path.normpath(json_directory + "/" +
> tribename + "_workers.json"), "r")
> + self._parse_workers(base_directory, json.load(workers_file))
> +
> + buildings_file = open(os.path.normpath(json_directory + "/" +
> tribename + "_buildings.json"), "r")
> + self._parse_buildings(base_directory, json.load(buildings_file))
>
> def graph( self ):
> """Make all graphs"""
--
https://code.launchpad.net/~widelands-dev/widelands-website/encyclopedia/+merge/287410
Your team Widelands Developers is subscribed to branch lp:widelands-website.
_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~widelands-dev
More help : https://help.launchpad.net/ListHelp