Hey Paullo, at this point if you go to Content -> Pages in the admin you should be able to choose Event in the "Add" dropdown. What sort of functionality are you looking for?
On Tue, Apr 1, 2014 at 7:05 AM, Paullo <[email protected]> wrote: > Hi, > > I've created modules that work as expected but I'm using the "django" way. > I would like to use the "Mezzanine" way instead (Mainly to avoid having to > create mobile templates..) but it doesn't show up in the admin panel. The > docs state that inheriting from PageAdmin will only allow it to be added as > a page rather than editable in the admin panel. How would I get the > equivalent functionality using the Page model? > > Here's the original "django":- > > *models.py:* > > from django.db import models > from django.utils import timezone > from django.forms import ValidationError > > from mezzanine.core.models import Displayable, Ownable, RichText > from mezzanine.utils.models import AdminThumbMixin > from mezzanine.conf import settings > > from phookit.apps.geocoders.models import Geocoder > > > def get_future_events(): > today = timezone.now() > return Event.objects.filter(event_date__gte=today) > > def get_expired_events(age_days): > if( not age_days ): > return [] > > today = timezone.now() > maxAge = timezone.now() - timezone.timedelta(days=age_days) > return > Event.objects.filter(event_date__gte=maxAge).exclude(event_date__gte=today).order_by("-event_date","-start_time") > > > class Event(Displayable, Ownable, RichText, AdminThumbMixin, Geocoder): > event_date = models.DateField() > start_time = models.TimeField() > end_time = models.TimeField() > > class Meta: > verbose_name = "Event" > verbose_name_plural = "Events" > ordering = ("event_date","start_time") > > > @models.permalink > def get_absolute_url(self): > url_name = "events:detail" > kwargs = {"event_id": self.id} > return (url_name, (), kwargs) > > > *admin.py:* > from copy import deepcopy > from django.contrib import admin > from mezzanine.core.admin import DisplayableAdmin, OwnableAdmin > > from .models import Event > > # never show published or expiry date > eventFieldsets = deepcopy(DisplayableAdmin.fieldsets) > eventFieldsets[0][1]["fields"].remove( ('publish_date', 'expiry_date') ) > > > class EventAdmin(DisplayableAdmin, OwnableAdmin): > > fieldsets = ( > deepcopy(eventFieldsets[0]), > ("Event details",{ > 'fields': ('address', 'content', 'event_date', ('start_time', > 'end_time'), 'mappable_location', ('lat', 'lon')) > }), > deepcopy(eventFieldsets[1]), > ) > > def save_form(self, request, form, change): > """ > Super class ordering is important here - user must get saved first. > """ > OwnableAdmin.save_form(self, request, form, change) > return DisplayableAdmin.save_form(self, request, form, change) > > admin.site.register(Event, EventAdmin) > > > And the stripped down "Mezzanine" way which isn't available in the control > panel: > > > *models.py* > from django.db import models > from mezzanine.pages.models import Page > from mezzanine.pages.models import RichText > > class Event(Page, RichText): > event_date = models.DateField("Event date") > start_time = models.TimeField("Event start time") > end_time = models.TimeField("Event end time") > > > *admin.py* > from django.contrib import > admin > from mezzanine.pages.admin import > PageAdmin > from .models import Event > > > admin.site.register(Event, PageAdmin) > > Cheers in advance > > > > > -- > You received this message because you are subscribed to the Google Groups > "Mezzanine Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
