Commit fe17ea8c authored by Laurent Bachelier's avatar Laurent Bachelier

Use mimetype instead of view to detect an Event file

This allows to have a correct available views list.
We rely on the priorities of views to display the view event by default.
parent 90112667
......@@ -77,12 +77,12 @@ class ApiPlugin(Plugin):
def init(self):
self.register_web_view(
View(object_type=None, name='json_info', public=False, verbose_name='JSON info'),
JsonInfoAction)
JsonInfoAction, -1)
self.register_web_view(
View(object_type='directory', name='json_list', public=False, verbose_name='JSON list'),
JsonListAction)
JsonListAction, -1)
self.register_web_view(
View(object_type='directory', name='text_list', public=False, verbose_name='Text-only list'),
TextListAction)
TextListAction, -1)
......@@ -212,9 +212,9 @@ class CorePlugin(Plugin):
self.register_web_view(
View(object_type='file', name='raw'),
DownloadAction, 10)
DownloadAction, 1)
self.register_web_view(
View(object_type='directory', name='list', verbose_name='Detailed list'),
ListAction, 10)
ListAction, 2)
self.register_hook('cleanup', CoreCleaner)
......@@ -30,6 +30,7 @@ from ass2m.server import ViewAction
from ass2m.cmd import Command
from .contacts import ContactsSelection
from .cleanup import ICleaner
__all__ = ['EventsPlugin']
......@@ -62,7 +63,7 @@ class Event(object):
self.f.set_user_perms(username, self.f.PERM_WRITE |
self.f.PERM_READ |
self.f.PERM_LIST)
self.f.view = 'event'
self.f.mimetype = 'text/event'
self.f.save()
def print_me(self):
......@@ -288,9 +289,25 @@ class EventAction(ViewAction):
self.get(Event.USER_CONFIRMED)
class EventsCleaner(ICleaner):
def fsck(self):
for f in self.storage.iter_files():
# update new way to know the file is an event
if f.view == 'event':
f.mimetype = 'text/event'
# not needed anymore, the default view will be the most precise
f.view = None
f.save()
print "%s updated to a newer Event config." % f.path
def gc(self):
pass
class EventsPlugin(Plugin):
def init(self):
self.register_cli_command('event', EventCmd)
self.register_web_view(
View(object_type='file', mimetype='text/plain', name='event'),
View(object_type='file', mimetype='text/event', name='event'),
EventAction)
self.register_hook('cleanup', EventsCleaner)
......@@ -103,7 +103,7 @@ class GalleryPlugin(Plugin):
def init(self):
self.register_web_view(
View(object_type='directory', name='gallery'),
ListGalleryAction)
ListGalleryAction, 0)
self.register_web_view(
View(object_type='file', mimetype='image', name='thumbnail'),
DownloadThumbnailAction)
DownloadThumbnailAction, -1)
......@@ -52,4 +52,4 @@ class WebsitePlugin(Plugin):
def init(self):
self.register_web_view(
WebsiteView(object_type='directory', name='website'),
WebsiteAction)
WebsiteAction, 0)
......@@ -47,7 +47,7 @@ Attendees:
f.write(event_text)
f = storage.get_file('/event1.txt')
f.view = 'event'
f.mimetype = 'text/event'
f.perms['u.penguin'] = f.PERM_READ | f.PERM_WRITE
f.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment