summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PythonTBC/settings.py1
-rw-r--r--PythonTBC/sitemap.py9
-rw-r--r--PythonTBC/urls.py8
-rw-r--r--tbc/models.py7
-rwxr-xr-xtbc/views.py5
5 files changed, 28 insertions, 2 deletions
diff --git a/PythonTBC/settings.py b/PythonTBC/settings.py
index 0f056d3..2849625 100644
--- a/PythonTBC/settings.py
+++ b/PythonTBC/settings.py
@@ -131,6 +131,7 @@ INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'django.contrib.sitemaps',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
diff --git a/PythonTBC/sitemap.py b/PythonTBC/sitemap.py
new file mode 100644
index 0000000..6f70945
--- /dev/null
+++ b/PythonTBC/sitemap.py
@@ -0,0 +1,9 @@
+from django.contrib.sitemaps import Sitemap
+from tbc.models import Chapters
+
+class TbcBookSitemap(Sitemap):
+ changefreq = "never"
+ priority = 0.5
+
+ def items(self):
+ return Chapters.objects.all()
diff --git a/PythonTBC/urls.py b/PythonTBC/urls.py
index d75e545..c5d3753 100644
--- a/PythonTBC/urls.py
+++ b/PythonTBC/urls.py
@@ -4,6 +4,11 @@ from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
+from sitemap import TbcBookSitemap
+sitemaps = {
+ 'book': TbcBookSitemap,
+}
+
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'PythonTBC.views.home', name='home'),
@@ -16,4 +21,7 @@ urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^comments/', include('comments.urls')),
url(r'^', include('tbc.urls', namespace='tbc')),
+ url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
)
+
+
diff --git a/tbc/models.py b/tbc/models.py
index 74419e4..e2e6940 100644
--- a/tbc/models.py
+++ b/tbc/models.py
@@ -2,6 +2,7 @@ from django.db import models
from django.contrib.auth.models import User
from PythonTBC import settings
from django.contrib.admin.models import LogEntry
+from local import sitemap_path
CATEGORY = (("fluid mechanics", "Fluid Mechanics"),
@@ -56,7 +57,8 @@ BOOK_PREFERENCE = (("book1","1st Book"),
def get_notebook_dir(instance, filename):
- return '%s/%s' % (instance.book.title.replace(' ', '_'), filename.replace(' ', '_'))
+ book_dir = instance.book.title.replace(' ', '_')+'_by_'+instance.book.author.replace(' ','_')
+ return '%s/%s' % (book_dir, filename.replace(' ', '_'))
def get_image_dir(instance, filename):
@@ -104,6 +106,7 @@ class Book(models.Model):
def __unicode__(self):
name = self.title or 'Book'
return '%s'%(name)
+
class Chapters(models.Model):
name = models.CharField(max_length=200)
@@ -113,6 +116,8 @@ class Chapters(models.Model):
def __unicode__(self):
name = self.name or 'Chapter'
return '%s'%(name)
+ def get_absolute_url(self):
+ return sitemap_path+str(self.notebook)
class ScreenShots(models.Model):
diff --git a/tbc/views.py b/tbc/views.py
index 9d6d4a3..fe31941 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -892,8 +892,11 @@ def SubmitCode(request):
counter += 1
curr_proposal.status = "codes submitted"
curr_proposal.save()
+ subject = "Python-TBC: Book & Code Updated"
+ message = """Hi """+curr_book.reviewer.name+""",\nA book & code has been updated on the Python TBC interface.\n Details of the book & contributor:\n Contributor: """+curr_book.contributor.user.first_name+""" """+curr_book.contributor.user.last_name+"""\nBook Title"""+curr_book.title+"""\nAuthor: """+curr_book.title+"""\nAuthor: """+curr_book.author+"""\n Publisher: """+curr_book.publisher_place+"""\nISBN: """+curr_book.isbn+"""\nFollow the link to riview the book:\nhttp://tbc-python.fosse.in/book-review/"""+str(curr_book.id)
add_log(user, curr_book, CHANGE, 'Codes & Screenshots Resubmitted',
curr_proposal.id)
+ email_send(curr_book.reviewer.email, subject, message)
return HttpResponseRedirect('/?bookupdate=done')
if request.method == 'POST':
for i in range(1, curr_book.no_chapters+1):
@@ -916,7 +919,7 @@ def SubmitCode(request):
curr_proposal.status = "codes submitted"
curr_proposal.save()
subject = "Python-TBC: Book Submission"
- message = """Hi """+curr_book.reviewer.name+""",\nA book has been submitted on the Python TBC interface.\n Detailf othe book & contributor:\n Contributor: """+curr_book.contributor.user.first_name+""" """+curr_book.contributor.user.last_name+"""\nBook Title"""+curr_book.title+"""\nAuthor: """+curr_book.title+"""\nAuthor: """+curr_book.author+"""\n Publisher: """+curr_book.publisher_place+"""\nISBN: """+curr_book.isbn+"""\nFollow the link to riview the book:\nhttp://tbc-python.fosse.in/book-review/"""+str(curr_book.id)
+ message = """Hi """+curr_book.reviewer.name+""",\nA book has been submitted on the Python TBC interface.\n Details of the book & contributor:\n Contributor: """+curr_book.contributor.user.first_name+""" """+curr_book.contributor.user.last_name+"""\nBook Title"""+curr_book.title+"""\nAuthor: """+curr_book.title+"""\nAuthor: """+curr_book.author+"""\n Publisher: """+curr_book.publisher_place+"""\nISBN: """+curr_book.isbn+"""\nFollow the link to riview the book:\nhttp://tbc-python.fosse.in/book-review/"""+str(curr_book.id)
log_chat = subject + '\n' + 'Book ' + curr_book.title + \
' has been submitted on the Python TBC interface.'
add_log(user, curr_book, CHANGE, 'Chapters and Screenshots added',