This is a simple and generic tree-like menuing system for Django_ with an easy-to-use admin interface. It covers all the essentials for building tree-structured menus and should be enough for a lot of projects. It is also easily extendable if you need to add some special behaviour to your menu items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmptyChoiceField(forms.ChoiceField): | |
def __init__(self, choices=(), empty_label=None, required=True, widget=None, label=None, | |
initial=None, help_text=None, *args, **kwargs): | |
# add an empty label if it exists (and if field is not required!) | |
if not required and empty_label is not None: | |
choices = tuple([(u'', empty_label)] + list(choices)) | |
super(EmptyChoiceField, self).__init__(choices=choices, required=required, widget=widget, label=label, | |
initial=initial, help_text=help_text, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_absolute_url(self): | |
# We need to build the URL to the paperPage inside the digital paper | |
# of the linked publication. | |
# It's built with the linked publication's absolute_url + an anchor pointing | |
# to the right book and the right page, 0-indexed. | |
# ex: http://journal.liberation.fr/publication/liberation/460/#0_17 | |
# The anchor is #0_17: | |
# - 0 -> first book of the publication | |
# - 17 -> paperPage.page_number == 18 | |
if self.book.code == BOOK_CODE.QUOTIDIEN: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 6s | |
2012-05-15 19:59:43 CEST LOG: duration: 6309.370 ms statement: SELECT classname, id | |
FROM sesql_default | |
WHERE (workflow_state = 20) AND (fulltext_tsv @@ plainto_tsquery('public.lem_french', E'ayrault ')) AND (classname IN (E'Article',E'Slideshow',E'Media',E'Pointer',E'Chat',E'Forum')) AND (workflow_state = 20) AND (editorial_source IN (20,10)) AND (publication_date >= E'2011-11-17') | |
ORDER BY publication_date_time DESC | |
LIMIT 1000 | |
# 56s | |
2012-05-15 19:54:33 CEST LOG: duration: 56736.021 ms statement: SELECT classname, id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requête 1: sélectionne un contentmodel lié à la rubrique *100126* (qui n'en contient aucun) | |
# Prend 15-30s | |
SELECT "libe_contentmodel"."id","libe_contentmodel"."child_type" | |
FROM "libe_contentmodel" | |
INNER JOIN "libe_contenttosection" | |
ON ("libe_contentmodel"."id" = "libe_contenttosection"."content_model_id") | |
WHERE ("libe_contenttosection"."section_id" = 100126 AND "libe_contentmodel"."workflow_state" = 20 ) | |
ORDER BY "libe_contentmodel"."computed_ponderation" DESC, "libe_contentmodel"."updating_date" DESC LIMIT 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyApexClasssss | |
{ | |
/** | |
* Enum representing each of before/after CRUD events on Sobjects | |
*/ | |
public enum Evt | |
{ | |
afterdelete, afterinsert, afterundelete, | |
afterupdate, beforedelete, beforeinsert, beforeupdate | |
} |