* Change admin registration and add registers for the right parts
* Seperate cms url config from main site config
* Update pagination views
* Mark cms content as safe (will add a check with the clean function later, as
validators have been deprecated)
* update gitignore file to remove some other pants
*.py[oc]
/sommitrealweird.db
*.py[oc]
/sommitrealweird.db
+/sommitrealweird/localsettings.py
+/tmp
--- /dev/null
+from models import BlogEntry, BlogSection
+from django.contrib import admin
+
+class BlogEntryAdmin(admin.ModelAdmin):
+ prepulated_fields = { "slug": ("title") }
+
+#admin.site.register(BlogEntry, BlogEntryAdmin)
+
+class BlogSectionAdmin(admin.ModelAdmin):
+ prepopulated_fields = { "slug": ("title")
+
+#admin.site.register(BlogSection, BlogSectionAdmin)
+
from django.db import models
from django.conf import settings
from django.db import models
from django.conf import settings
+from django.contrib import admin
FORMAT_CHOICES = (
('rst', 'reStructuredText'),
FORMAT_CHOICES = (
('rst', 'reStructuredText'),
)
class BlogEntry(models.Model):
)
class BlogEntry(models.Model):
- title = models.CharField(maxlength=150)
+ title = models.CharField(max_length=150)
islive = models.BooleanField()
sections = models.ManyToManyField('BlogSection')
islive = models.BooleanField()
sections = models.ManyToManyField('BlogSection')
- format = models.CharField(maxlength=10, choices=FORMAT_CHOICES)
- slug = models.SlugField(prepopulate_from=("title",))
+ format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
+ slug = models.SlugField()
publish_date = models.DateTimeField()
content = models.TextField()
publish_date = models.DateTimeField()
content = models.TextField()
class Meta:
ordering = ['-publish_date']
class Meta:
ordering = ['-publish_date']
class BlogSection(models.Model):
class BlogSection(models.Model):
- title = models.CharField(maxlength=150)
- slug = models.SlugField(prepopulate_from=("title",))
+ title = models.CharField(max_length=150)
+ slug = models.SlugField()
def __str__(self):
return self.__unicode__()
def __str__(self):
return self.__unicode__()
def get_absolute_url(self):
return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)
def get_absolute_url(self):
return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)
from blog.models import BlogEntry, BlogSection
from django.http import Http404, HttpResponse
from django.template import RequestContext, loader
from blog.models import BlogEntry, BlogSection
from django.http import Http404, HttpResponse
from django.template import RequestContext, loader
-from django.core.paginator import ObjectPaginator
+from django.core.paginator import Paginator
from django.conf import settings
def blog_index(request, section=None):
from django.conf import settings
def blog_index(request, section=None):
entries = entries.order_by('-publish_date')
if entries:
paginate_by=20
entries = entries.order_by('-publish_date')
if entries:
paginate_by=20
- paginator = ObjectPaginator(entries, paginate_by)
- page = int(request.GET.get('page', 0))
- if page > 0:
- page = page - 1
- paginated_entries = paginator.get_page(page)
- pages = [i for i in range(1, paginator.pages + 1)]
+ paginator = Paginator(entries, paginate_by)
+ try:
+ page = int(request.GET.get('page', 1))
+ except ValueError:
+ page = 1
+ paginated_entries = paginator.page(page)
+ pages = paginator.page_range
t = loader.get_template("blog/blog_index.html")
c = RequestContext(request,
{
t = loader.get_template("blog/blog_index.html")
c = RequestContext(request,
{
- "entries": paginated_entries,
+ "entries": paginated_entries.object_list,
"title": settings.BLOG_TITLE,
"title": settings.BLOG_TITLE,
"pages": pages,
"paginated": 1,
"pages": pages,
"paginated": 1,
- "has_next": paginator.has_next_page(page),
- "has_prev": paginator.has_next_page(page),
- "next": page + 2,
+ "has_next": paginated_entries.has_next(),
+ "has_prev": paginated_entries.has_previous(),
+ "next": page + 1,
"prev": page - 1
})
return HttpResponse(t.render(c))
"prev": page - 1
})
return HttpResponse(t.render(c))
--- /dev/null
+from models import Document, Folder
+from django.contrib import admin
+
+class DocumentAdmin(admin.ModelAdmin):
+ prepopulated_fields = { "slug": ("title",) }
+
+admin.site.register(Document, DocumentAdmin)
+
+class FolderAdmin(admin.ModelAdmin):
+ prepopulated_fields = { "slug": ("title",) }
+
+admin.site.register(Folder, FolderAdmin)
from django.db import models
from django.db import models
-from bpcms.content_val import is_allowed_name
from django.conf import settings
from django.conf import settings
+from django.contrib import admin
FORMAT_CHOICES = (
('rst', 'reStructuredText'),
FORMAT_CHOICES = (
('rst', 'reStructuredText'),
)
class Document(models.Model):
)
class Document(models.Model):
- title = models.CharField(maxlength=150)
+ title = models.CharField(max_length=150)
islive = models.BooleanField()
folder = models.ForeignKey('Folder', null=True, blank=True)
islive = models.BooleanField()
folder = models.ForeignKey('Folder', null=True, blank=True)
- format = models.CharField(maxlength=10, choices=FORMAT_CHOICES)
- slug = models.SlugField(prepopulate_from=("title",), validator_list=[is_allowed_name,])
+ format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
+ slug = models.SlugField()
content = models.TextField()
def __str__(self):
content = models.TextField()
def __str__(self):
return "%s%s%s/" %(settings.BPCMS_ROOT, folderstring, self.slug)
return "%s%s%s/" %(settings.BPCMS_ROOT, folderstring, self.slug)
class Folder(models.Model):
class Folder(models.Model):
- title = models.CharField(maxlength=150)
- slug = models.SlugField(prepopulate_from=("title",), validator_list=[is_allowed_name,])
+ title = models.CharField(max_length=150)
+ slug = models.SlugField()
parent = models.ForeignKey('self', null=True, blank=True)
def __str__(self):
return self.__unicode__()
def __unicode__(self):
parent = models.ForeignKey('self', null=True, blank=True)
def __str__(self):
return self.__unicode__()
def __unicode__(self):
- return u'%s' %(self.title)
+ return u'%s - %s' %(self.get_path(), self.title)
- def get_basic_url(self):
folders = []
curfolder = self
while curfolder != None:
folders = []
curfolder = self
while curfolder != None:
if folderstring != u'':
folderstring = "%s/" %(folderstring,)
if folderstring != u'':
folderstring = "%s/" %(folderstring,)
- return "%s%s" %(settings.BPCMS_ROOT, folderstring)
-
- class Admin:
- pass
+ return folderstring
+
+ def get_basic_url(self):
+ return "%s%s" %(settings.BPCMS_ROOT, self.get_path())
{% block content %}
<h1>{{ title }}</h1>
{% block content %}
<h1>{{ title }}</h1>
{% block content %}
<h1>{{ title }}</h1>
{% block content %}
<h1>{{ title }}</h1>
-{{ content|restructuredtext }}
+{{ content|restructuredtext|safe }}
--- /dev/null
+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('',
+ (r'^$', 'bpcms.views.document_view', {'slug': 'index'}),
+ (r'^(?P<slug>[^/]+)/$', 'bpcms.views.document_view'),
+ (r'^(?P<folders>.*)/(?P<slug>[^/]+)/$', 'bpcms.views.document_view'),
+)
+
from django.conf.urls.defaults import *
from settings import MEDIA_ROOT, MEDIA_URL
from blog.feeds import LatestBlogEntries
from django.conf.urls.defaults import *
from settings import MEDIA_ROOT, MEDIA_URL
from blog.feeds import LatestBlogEntries
+from django.contrib import admin
handler404 = 'generic.views.render_404'
handler404 = 'generic.views.render_404'
'blog': LatestBlogEntries,
}
'blog': LatestBlogEntries,
}
urlpatterns = patterns('',
# Example:
# (r'^sommitrealweird/', include('sommitrealweird.foo.urls')),
urlpatterns = patterns('',
# Example:
# (r'^sommitrealweird/', include('sommitrealweird.foo.urls')),
# Uncomment this for admin:
(r'^$', 'bpcms.views.document_view', {'slug': 'index'}),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': MEDIA_ROOT, 'show_indexes': True}),
# Uncomment this for admin:
(r'^$', 'bpcms.views.document_view', {'slug': 'index'}),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': MEDIA_ROOT, 'show_indexes': True}),
- (r'^admin/', include('django.contrib.admin.urls')),
+ (r'^admin/(.*)$', admin.site.root),
(r'^blog/', include('blog.urls')),
(r'^feeds/(?P<url>.*)/', 'django.contrib.syndication.views.feed', {'feed_dict': feeds_dict}),
(r'^blog/', include('blog.urls')),
(r'^feeds/(?P<url>.*)/', 'django.contrib.syndication.views.feed', {'feed_dict': feeds_dict}),
- (r'^(?:content/|)(?P<slug>[^/]+)/$', 'bpcms.views.document_view'),
- (r'^(?:content/|)(?P<folders>.*)/(?P<slug>[^/]+)/$', 'bpcms.views.document_view'),
+ (r'^(?:content/|)', include('bpcms.urls'))