Merge lp://staging/~widelands-dev/widelands-website/move_maps_minimap into lp://staging/widelands-website

Proposed by kaputtnik
Status: Merged
Merged at revision: 545
Proposed branch: lp://staging/~widelands-dev/widelands-website/move_maps_minimap
Merge into: lp://staging/widelands-website
Diff against target: 247 lines (+124/-22)
7 files modified
wlmaps/admin.py (+13/-1)
wlmaps/forms.py (+15/-6)
wlmaps/migrations/0003_auto_20190712_0928.py (+65/-0)
wlmaps/models.py (+16/-1)
wlmaps/templates/wlmaps/index.html (+3/-7)
wlmaps/templates/wlmaps/inlines/version_info.html (+11/-0)
wlmaps/templates/wlmaps/map_detail.html (+1/-7)
To merge this branch: bzr merge lp://staging/~widelands-dev/widelands-website/move_maps_minimap
Reviewer Review Type Date Requested Status
kaputtnik (community) Needs Resubmitting
GunChleoc Approve
Review via email: mp+370039@code.staging.launchpad.net

Commit message

Move minimaps to wlmaps/minimaps
Implemented the new value needs_version_after
Delete map files (.wmf and .png) when deleting a map from the database

Description of the change

The maps minimaps are now moved to wlmaps/minimaps. This fixes also creating a faulty path in the database for the minimaps (beginning with a slash).

Deleting a map does now delete the related files.

The new value of 'needs_version_after' produced by wl_map_info is now considered. There is now an inline html file for this, so the logic is in one file.

The changes related to minimaps need manual intervention regarding the files and the database entries:

- All png files in MEDIA_ROOT/wlmaps/maps/ needs moving to MEDIA_ROOT/wlmaps/minimaps/
- Database entries for minimaps need to be changed from
  '/wlmaps/maps/NAME.png'
  to
  'wlmaps/minimaps/NAME.png'

To get this in:
- set maintenance
- backup the database
- backup the files from MEDIA_ROOT/wlmaps/
- run ./manage.py migrate
- move the png files
- correct the path(s) in the database. I want to change also some bad entries for the mapfiles. With activated virtualenvironment:

./manage.py shell
from wlmaps.models import Map
maps = Map.objects.all()
for m in maps:
    if m.minimap.name.startswith('/'):
        new_name = m.minimap.name.rpartition('/')[2]
        m.minimap = 'wlmaps/minimaps/{}'.format(new_name)
        m.save()

maps = Map.objects.all()
for m in maps:
    if m.file.name.startswith('/var/www'):
        new_name = m.file.name.rpartition('/')[2]
        m.file = 'wlmaps/maps/{}'.format(new_name)
        m.save()

This can maybe done also in one loop (changing minimap and file), but i fear saving an object twice in one loop can be problematic, although at home it works nicely.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

LGTM :)

review: Approve
548. By kaputtnik

merged with trunk

Revision history for this message
kaputtnik (franku) wrote :

I have to test a bit more before merging this. On my second computer i get some errors after merging this branch.

review: Needs Fixing
549. By kaputtnik

use a custom delete function instead of signals

Revision history for this message
kaputtnik (franku) wrote :

A better solution: Using signals, especially when deleting files, can lead into some sideeffects. So i have implemented a custom delete() function which is much better, imho.

review: Needs Resubmitting
550. By kaputtnik

merged with trunk

Revision history for this message
GunChleoc (gunchleoc) wrote :

LGTM :)

Revision history for this message
kaputtnik (franku) wrote :

Thanks :-)

Merged and deployed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches