On Jan 13, 9:40 pm, Manfred <manfred.morg...@gmail.com> wrote:
> Hello,
>
> I wrote a special kind of blog- or news application. One of the
> specialities of this application is, that authors are able to make
> entries visible/invisible by a date range or by a simple switch to
> hide the entry. This works well. But (the authors are not supposed to
> use the admin interface) authors need to be able to change the state
> of 'invisible' entries if they are in editing mode. Therefore, the
> view selects _all_ entries if one is logged in but only visible ones
> if one is not logged in.
>
> To support authors and show them if an entry is visible for the normal
> user or not, invisible entries have a different layout than visible
> ones. Using a booelan field 'entry.hide' in the template is easy by {%
> if entry.hide %}...
>
> But how can I deal with the date range? I have two fields: 'show_from'
> and 'show_until' to restrict the visible date range for each entry.
> The essence of what I need is something like this:
>
> IF entry.hide == True OR entry.show_from > date.today() OR
> entry.show_until < date.today() THEN ...
>
> In my template currently I use a statement like this: {% if entry.hide
> %} class="hidden"{% endif %} to change the section layout for
> invisible sections. But if the entry is "invisible" because of the
> date range, I had no success to mark the entry 'hidden' in the
> templete.
>
> Currently my application runs on Django 0.96, but I did not found any
> solution to this question even in Django 1.0
>
> Is there a solution?
>
> Many thanks in advance,
> Manfred.

I would put a method on your entry class, something like is_hidden,
which would do the calculation and return a boolean. Then your
template can just call {% if entry.is_hidden %} as necessary.
--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to