Changeset 1462

Show
Ignore:
Timestamp:
03/04/08 21:31:04 (9 months ago)
Author:
JensDiemer
Message:

Proof of concept: Page Archiv.

Location:
trunk/pylucid/PyLucid
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/models.py

    r1456 r1462  
    3030from PyLucid.tools import crypt 
    3131from PyLucid.system.utils import get_uri_base 
    32  
    3332 
    3433 
     
    290289#______________________________________________________________________________ 
    291290 
     291class PageArchiv(models.Model): 
     292    """ 
     293    A simple archiv for old cms page content. 
     294    """ 
     295    # Explicite id field, so we can insert a help_text ;) 
     296    id = models.AutoField(primary_key=True, help_text="The internal page ID.") 
     297 
     298    content = models.TextField(blank=True, help_text="The CMS page content.") 
     299 
     300    parent = models.ForeignKey( 
     301        "self", null=True, blank=True, 
     302        to_field="id", help_text="the higher-ranking father page", 
     303    ) 
     304    position = models.IntegerField( 
     305        default = 0, 
     306        help_text = "ordering weight for sorting the pages in the menu." 
     307    ) 
     308 
     309    name = models.CharField(max_length=150, help_text="A short page name") 
     310 
     311    shortcut = models.CharField( 
     312        max_length=150, help_text="shortcut to built the URLs" 
     313    ) 
     314    title = models.CharField( 
     315        blank=True, max_length=150, help_text="A long page title" 
     316    ) 
     317 
     318    template = models.ForeignKey( 
     319        "Template", to_field="id", help_text="the used template for this page" 
     320    ) 
     321    style = models.ForeignKey( 
     322        "Style", to_field="id", help_text="the used stylesheet for this page" 
     323    ) 
     324    markup = models.ForeignKey("Markup", 
     325        related_name="pageachiv_markup", 
     326        help_text="the used markup language for this page" 
     327    ) 
     328 
     329    keywords = models.CharField( 
     330        blank=True, max_length=255, 
     331        help_text="Keywords for the html header. (separated by commas)" 
     332    ) 
     333    description = models.CharField( 
     334        blank=True, max_length=255, 
     335        help_text="Short description of the contents. (for the html header)" 
     336    ) 
     337 
     338    createtime = models.DateTimeField( 
     339        auto_now_add=True, help_text="Create time", 
     340    ) 
     341    lastupdatetime = models.DateTimeField( 
     342        auto_now=True, help_text="Time of the last change.", 
     343    ) 
     344    createby = models.ForeignKey( 
     345        User, editable=False, related_name="pageachiv_createby", 
     346        help_text="User how create the current page.", 
     347    ) 
     348    lastupdateby = models.ForeignKey( 
     349        User, editable=False, related_name="pageachiv_lastupdateby", 
     350        help_text="User as last edit the current page.", 
     351    ) 
     352 
     353    showlinks = models.BooleanField(default=True, 
     354        help_text="Put the Link to this page into Menu/Sitemap etc.?" 
     355    ) 
     356    permitViewPublic = models.BooleanField(default=True, 
     357        help_text="Can anonymous see this page?" 
     358    ) 
     359 
     360    permitViewGroup = models.ForeignKey( 
     361        Group, related_name="pageachiv_permitViewGroup", null=True, blank=True, 
     362        help_text="Limit viewable to a group?" 
     363    ) 
     364 
     365    permitEditGroup = models.ForeignKey( 
     366        Group, related_name="pageachiv_permitEditGroup", null=True, blank=True, 
     367        help_text="Usergroup how can edit this page." 
     368    ) 
     369 
     370    original = models.ForeignKey("Page") 
     371 
     372    class Admin: 
     373        list_display = ( 
     374            "id", "shortcut", "name", "title", "description", 
     375            "lastupdatetime", "lastupdateby" 
     376        ) 
     377 
     378#______________________________________________________________________________ 
     379 
    292380 
    293381class JS_LoginData(models.Model): 
  • trunk/pylucid/PyLucid/plugins_internal/page_admin/page_admin.py

    r1461 r1462  
    3737 
    3838from django.conf import settings 
    39 from PyLucid.models import Page, Plugin 
     39from PyLucid.models import Page, Plugin, PageArchiv 
    4040from PyLucid.db.page import flat_tree_list, get_sitemap_tree 
    4141from PyLucid.system.BasePlugin import PyLucidBasePlugin 
     
    227227                    context["preview_content"] = content 
    228228                elif "save" in self.request.POST: 
     229                    # FIXME: How to transfer the attributes easier? 
     230                    old_page = PageArchiv( 
     231                        content           = self.current_page.content, 
     232                        parent            = self.current_page.parent, 
     233                        position          = self.current_page.position, 
     234                        name              = self.current_page.name, 
     235                        shortcut          = self.current_page.shortcut, 
     236                        title             = self.current_page.title, 
     237                        template          = self.current_page.template, 
     238                        style             = self.current_page.style, 
     239                        markup            = self.current_page.markup, 
     240                        keywords          = self.current_page.keywords, 
     241                        description       = self.current_page.description, 
     242                        createtime        = self.current_page.createtime, 
     243                        lastupdatetime    = self.current_page.lastupdatetime, 
     244                        createby          = self.current_page.createby, 
     245                        lastupdateby      = self.current_page.lastupdateby, 
     246                        showlinks         = self.current_page.showlinks, 
     247                        permitViewPublic  = self.current_page.permitViewPublic, 
     248                        permitViewGroup   = self.current_page.permitViewGroup, 
     249                        permitEditGroup   = self.current_page.permitEditGroup, 
     250 
     251                        original = self.current_page 
     252                    ) 
     253                    old_page.save() 
     254                    self.page_msg(_("Old page data archived.")) 
     255 
     256                    old_content = self.current_page.content 
    229257                    # Save the new page data into the database: 
    230258                    try: