GithubHelp home page GithubHelp logo

Comments (4)

chrisdev avatar chrisdev commented on June 17, 2024

@Parbhat Right now the photo gallery is just a text field it should be a snippet

   @register_snippet
   class PhotoAlbum(models.Model):
        name = models.CharField(max_length=255, blank= True, null=True)
        feed_image = models.ForeignKey(
                                Image,
                                help_text="An optional image to represent the gallery",
                               null=True,
                               blank=True,
                                on_delete=models.SET_NULL,
                               related_name='+') 

    panels = [
        FieldPanel('name')
        ImagePanel('feed_image`)

    ]

    def __unicode__(self):
        return self.name

from wagtail-cookiecutter-foundation.

chrisdev avatar chrisdev commented on June 17, 2024
    class CustomImage(AbstractImage):

            gallery_name = models.ForeignKey(
                  PhotoAlbum, blank=True,
                  null=True, related_name='+', on_delete=models.SET_NULL
           )

from wagtail-cookiecutter-foundation.

chrisdev avatar chrisdev commented on June 17, 2024

@Parbhat wagtail believes that the model should do all the work and the view should be as generic as possible
So the wagtail way on handling this custom image would be to build a GalleryIndex model.

      GalleryIndexPage(Page):
           intro = RichTextField(blank=True)

           @property
            def photo_albums(self):
                  albums = PhotoAlbums.objects.all()
                  return photo_albums

            def get_context(self, request):
                  photo_albums = self.photo_albums
                  context = Super(GalleryIndexPage, self).get_context(request)
                  context['photo_albums']  = photo_albums
                  return context

Of course you also have to Build a Page to handle when the user selects a Gallery for viewing
Here you get_context should filter for all the Images that match the gallery selected.

This suggest that you Gallery Snippet will require a slug
http:/localhost:8000/gallery?party-taylor-swift
The user will fill our the info on the Gallery independent of uploading the actually photo

from wagtail-cookiecutter-foundation.

Parbhat avatar Parbhat commented on June 17, 2024

great now will be working on snippets :)

from wagtail-cookiecutter-foundation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.