From 4347c2947834fe7f2edf2b457b2d513454fc6a03 Mon Sep 17 00:00:00 2001 From: Mike Chen Date: Sun, 5 Jul 2009 10:23:30 +0800 Subject: [PATCH] initiliaze git rep --- .gitignore | 2 + INSTALL | 33 + LICENSE | 12 + __init__.py | 0 development.log | 0 django_authopenid/__init__.py | 40 + django_authopenid/admin.py | 9 + django_authopenid/forms.py | 435 ++ django_authopenid/middleware.py | 24 + django_authopenid/mimeparse.py | 160 + django_authopenid/models.py | 71 + django_authopenid/urls.py | 27 + django_authopenid/util.py | 145 + django_authopenid/views.py | 787 ++++ forum/__init__.py | 0 forum/admin.py | 71 + forum/auth.py | 443 ++ forum/const.py | 89 + forum/diff.py | 66 + forum/feed.py | 41 + forum/forms.py | 194 + forum/management/__init__.py | 0 forum/management/commands/__init__.py | 0 forum/management/commands/base_command.py | 35 + .../management/commands/clean_award_badges.py | 58 + .../management/commands/multi_award_badges.py | 347 ++ .../management/commands/once_award_badges.py | 350 ++ forum/management/commands/sample_command.py | 7 + forum/managers.py | 259 ++ forum/models.py | 653 +++ forum/templatetags/__init__.py | 0 forum/templatetags/extra_filters.py | 83 + forum/templatetags/extra_tags.py | 232 ++ forum/user.py | 74 + forum/views.py | 1945 +++++++++ locale/zh_cn/LC_MESSAGES/django.mo | Bin 0 -> 6605 bytes locale/zh_cn/LC_MESSAGES/django.po | 416 ++ manage.py | 11 + middleware/__init__.py | 0 middleware/pagesize.py | 29 + settings.py | 125 + settings_local.py.dist | 21 + sql_scripts/cnprog.xml | 1498 +++++++ sql_scripts/cnprog_new_install.sql | 811 ++++ sql_scripts/cnprog_new_install_2009_02_28.sql | 456 +++ sql_scripts/cnprog_new_install_2009_03_31.sql | 891 +++++ sql_scripts/cnprog_new_install_2009_04_07.sql | 24 + sql_scripts/cnprog_new_install_2009_04_09.sql | 904 +++++ sql_scripts/update_2009_01_13_001.sql | 62 + sql_scripts/update_2009_01_13_002.sql | 1 + sql_scripts/update_2009_01_18_001.sql | 62 + sql_scripts/update_2009_01_24.sql | 2 + sql_scripts/update_2009_01_25_001.sql | 2 + sql_scripts/update_2009_02_26_001.sql | 19 + sql_scripts/update_2009_04_10_001.sql | 3 + sql_scripts/update_2009_12_24_001.sql | 5 + sql_scripts/update_2009_12_27_001.sql | 3 + sql_scripts/update_2009_12_27_002.sql | 1 + templates/404.html | 48 + templates/500.html | 33 + templates/about.html | 71 + templates/answer_edit.html | 139 + templates/ask.html | 191 + templates/authopenid/changeemail.html | 39 + templates/authopenid/changeopenid.html | 33 + templates/authopenid/changepw.html | 33 + templates/authopenid/complete.html | 66 + templates/authopenid/confirm_email.txt | 12 + templates/authopenid/delete.html | 38 + templates/authopenid/failure.html | 13 + templates/authopenid/sendpw.html | 33 + templates/authopenid/sendpw_email.txt | 14 + templates/authopenid/settings.html | 41 + templates/authopenid/signin.html | 96 + templates/authopenid/signup.html | 51 + templates/authopenid/yadis.xrdf | 14 + templates/badge.html | 38 + templates/badges.html | 72 + templates/base.html | 82 + templates/base_content.html | 75 + templates/book.html | 150 + templates/close.html | 36 + templates/content/images/box-arrow.gif | Bin 0 -> 69 bytes templates/content/images/bullet_green.gif | Bin 0 -> 64 bytes templates/content/images/cc-88x31.png | Bin 0 -> 5460 bytes templates/content/images/cc-wiki.png | Bin 0 -> 2333 bytes .../content/images/close-small-hover.png | Bin 0 -> 337 bytes templates/content/images/close-small.png | Bin 0 -> 293 bytes .../content/images/cnprog_logo_200_56.gif | Bin 0 -> 2114 bytes templates/content/images/dash.gif | Bin 0 -> 44 bytes .../content/images/djangomade124x25_grey.gif | Bin 0 -> 2035 bytes templates/content/images/dot-g.gif | Bin 0 -> 61 bytes templates/content/images/dot-list.gif | Bin 0 -> 56 bytes templates/content/images/edit.png | Bin 0 -> 758 bytes .../content/images/expander-arrow-hide.gif | Bin 0 -> 126 bytes .../content/images/expander-arrow-show.gif | Bin 0 -> 135 bytes templates/content/images/favicon.gif | Bin 0 -> 3918 bytes templates/content/images/favicon.ico | Bin 0 -> 3638 bytes templates/content/images/feed-icon-small.png | Bin 0 -> 689 bytes templates/content/images/grippie.png | Bin 0 -> 162 bytes templates/content/images/indicator.gif | Bin 0 -> 2545 bytes templates/content/images/logo.png | Bin 0 -> 3631 bytes templates/content/images/logo1.png | Bin 0 -> 2752 bytes templates/content/images/logo2.png | Bin 0 -> 2124 bytes templates/content/images/medala.gif | Bin 0 -> 801 bytes templates/content/images/medala_on.gif | Bin 0 -> 957 bytes templates/content/images/new.gif | Bin 0 -> 635 bytes templates/content/images/nophoto.png | Bin 0 -> 696 bytes templates/content/images/openid.gif | Bin 0 -> 910 bytes templates/content/images/openid/aol.gif | Bin 0 -> 2205 bytes templates/content/images/openid/blogger.ico | Bin 0 -> 3638 bytes templates/content/images/openid/claimid.ico | Bin 0 -> 3638 bytes templates/content/images/openid/facebook.gif | Bin 0 -> 2075 bytes templates/content/images/openid/flickr.ico | Bin 0 -> 1150 bytes templates/content/images/openid/google.gif | Bin 0 -> 1596 bytes .../content/images/openid/livejournal.ico | Bin 0 -> 5222 bytes templates/content/images/openid/myopenid.ico | Bin 0 -> 2862 bytes .../images/openid/openid-inputicon.gif | Bin 0 -> 237 bytes templates/content/images/openid/openid.gif | Bin 0 -> 740 bytes .../content/images/openid/technorati.ico | Bin 0 -> 2294 bytes templates/content/images/openid/verisign.ico | Bin 0 -> 4710 bytes templates/content/images/openid/vidoop.ico | Bin 0 -> 1406 bytes templates/content/images/openid/wordpress.ico | Bin 0 -> 1150 bytes templates/content/images/openid/yahoo.gif | Bin 0 -> 1682 bytes templates/content/images/quest-bg.gif | Bin 0 -> 294 bytes templates/content/images/vote-accepted-on.png | Bin 0 -> 1124 bytes templates/content/images/vote-accepted.png | Bin 0 -> 1058 bytes .../content/images/vote-arrow-down-on.png | Bin 0 -> 905 bytes templates/content/images/vote-arrow-down.png | Bin 0 -> 876 bytes templates/content/images/vote-arrow-up-on.png | Bin 0 -> 906 bytes templates/content/images/vote-arrow-up.png | Bin 0 -> 843 bytes .../content/images/vote-favorite-off.png | Bin 0 -> 930 bytes templates/content/images/vote-favorite-on.png | Bin 0 -> 1023 bytes templates/content/js/com.cnprog.editor.js | 68 + templates/content/js/com.cnprog.post.js | 573 +++ templates/content/js/com.cnprog.post.pack.js | 1 + templates/content/js/com.cnprog.utils.js | 116 + templates/content/js/compress.bat | 6 + templates/content/js/excanvas.pack.js | 1 + templates/content/js/flot-build.bat | 3 + templates/content/js/jquery-1.2.6.js | 3549 +++++++++++++++++ templates/content/js/jquery-1.2.6.min.js | 32 + templates/content/js/jquery.ajaxfileupload.js | 195 + templates/content/js/jquery.flot.js | 2421 +++++++++++ templates/content/js/jquery.flot.pack.js | 1 + templates/content/js/jquery.openid.js | 176 + templates/content/js/jquery.validate.pack.js | 15 + templates/content/js/se_hilite.js | 1 + templates/content/js/se_hilite_src.js | 273 ++ .../content/js/wmd/images/wmd-buttons.png | Bin 0 -> 7465 bytes templates/content/js/wmd/showdown-min.js | 1 + templates/content/js/wmd/showdown.js | 1309 ++++++ templates/content/js/wmd/wmd-min.js | 1 + templates/content/js/wmd/wmd-test.html | 158 + templates/content/js/wmd/wmd.css | 129 + templates/content/js/wmd/wmd.js | 2390 +++++++++++ templates/content/js/yuicompressor-2.4.2.jar | Bin 0 -> 851219 bytes templates/content/style/default.css | 1753 ++++++++ .../content/style/jquery.autocomplete.css | 49 + templates/content/style/openid.css | 45 + templates/content/style/prettify.css | 27 + templates/content/style/style.css | 999 +++++ templates/faq.html | 114 + templates/feeds/rss_description.html | 1 + templates/feeds/rss_title.html | 1 + templates/footer.html | 30 + templates/header.html | 64 + templates/index.html | 121 + templates/logout.html | 26 + templates/pagesize.html | 24 + templates/paginator.html | 35 + templates/privacy.html | 40 + templates/question.html | 469 +++ templates/question_edit.html | 185 + templates/question_retag.html | 109 + templates/questions.html | 153 + templates/reopen.html | 37 + templates/revisions_answer.html | 100 + templates/revisions_question.html | 102 + templates/tags.html | 61 + templates/unanswered.html | 115 + templates/user.html | 34 + templates/user_edit.html | 90 + templates/user_favorites.html | 7 + templates/user_footer.html | 3 + templates/user_info.html | 86 + templates/user_preferences.html | 20 + templates/user_recent.html | 25 + templates/user_reputation.html | 40 + templates/user_responses.html | 21 + templates/user_stats.html | 127 + templates/user_tabs.html | 20 + templates/user_votes.html | 28 + templates/users.html | 70 + templates/users_questions.html | 60 + urls.py | 63 + utils/__init__.py | 0 utils/cache.py | 92 + utils/html.py | 51 + utils/lists.py | 86 + 200 files changed, 30458 insertions(+) create mode 100644 .gitignore create mode 100644 INSTALL create mode 100644 LICENSE create mode 100644 __init__.py create mode 100644 development.log create mode 100644 django_authopenid/__init__.py create mode 100644 django_authopenid/admin.py create mode 100644 django_authopenid/forms.py create mode 100644 django_authopenid/middleware.py create mode 100644 django_authopenid/mimeparse.py create mode 100644 django_authopenid/models.py create mode 100644 django_authopenid/urls.py create mode 100644 django_authopenid/util.py create mode 100644 django_authopenid/views.py create mode 100644 forum/__init__.py create mode 100644 forum/admin.py create mode 100644 forum/auth.py create mode 100644 forum/const.py create mode 100644 forum/diff.py create mode 100644 forum/feed.py create mode 100644 forum/forms.py create mode 100644 forum/management/__init__.py create mode 100644 forum/management/commands/__init__.py create mode 100644 forum/management/commands/base_command.py create mode 100644 forum/management/commands/clean_award_badges.py create mode 100644 forum/management/commands/multi_award_badges.py create mode 100644 forum/management/commands/once_award_badges.py create mode 100644 forum/management/commands/sample_command.py create mode 100644 forum/managers.py create mode 100644 forum/models.py create mode 100644 forum/templatetags/__init__.py create mode 100644 forum/templatetags/extra_filters.py create mode 100644 forum/templatetags/extra_tags.py create mode 100644 forum/user.py create mode 100644 forum/views.py create mode 100644 locale/zh_cn/LC_MESSAGES/django.mo create mode 100644 locale/zh_cn/LC_MESSAGES/django.po create mode 100644 manage.py create mode 100644 middleware/__init__.py create mode 100644 middleware/pagesize.py create mode 100644 settings.py create mode 100644 settings_local.py.dist create mode 100644 sql_scripts/cnprog.xml create mode 100644 sql_scripts/cnprog_new_install.sql create mode 100644 sql_scripts/cnprog_new_install_2009_02_28.sql create mode 100644 sql_scripts/cnprog_new_install_2009_03_31.sql create mode 100644 sql_scripts/cnprog_new_install_2009_04_07.sql create mode 100644 sql_scripts/cnprog_new_install_2009_04_09.sql create mode 100644 sql_scripts/update_2009_01_13_001.sql create mode 100644 sql_scripts/update_2009_01_13_002.sql create mode 100644 sql_scripts/update_2009_01_18_001.sql create mode 100644 sql_scripts/update_2009_01_24.sql create mode 100644 sql_scripts/update_2009_01_25_001.sql create mode 100644 sql_scripts/update_2009_02_26_001.sql create mode 100644 sql_scripts/update_2009_04_10_001.sql create mode 100644 sql_scripts/update_2009_12_24_001.sql create mode 100644 sql_scripts/update_2009_12_27_001.sql create mode 100644 sql_scripts/update_2009_12_27_002.sql create mode 100644 templates/404.html create mode 100644 templates/500.html create mode 100644 templates/about.html create mode 100644 templates/answer_edit.html create mode 100644 templates/ask.html create mode 100644 templates/authopenid/changeemail.html create mode 100644 templates/authopenid/changeopenid.html create mode 100644 templates/authopenid/changepw.html create mode 100644 templates/authopenid/complete.html create mode 100644 templates/authopenid/confirm_email.txt create mode 100644 templates/authopenid/delete.html create mode 100644 templates/authopenid/failure.html create mode 100644 templates/authopenid/sendpw.html create mode 100644 templates/authopenid/sendpw_email.txt create mode 100644 templates/authopenid/settings.html create mode 100644 templates/authopenid/signin.html create mode 100644 templates/authopenid/signup.html create mode 100644 templates/authopenid/yadis.xrdf create mode 100644 templates/badge.html create mode 100644 templates/badges.html create mode 100644 templates/base.html create mode 100644 templates/base_content.html create mode 100644 templates/book.html create mode 100644 templates/close.html create mode 100644 templates/content/images/box-arrow.gif create mode 100644 templates/content/images/bullet_green.gif create mode 100644 templates/content/images/cc-88x31.png create mode 100644 templates/content/images/cc-wiki.png create mode 100644 templates/content/images/close-small-hover.png create mode 100644 templates/content/images/close-small.png create mode 100644 templates/content/images/cnprog_logo_200_56.gif create mode 100644 templates/content/images/dash.gif create mode 100644 templates/content/images/djangomade124x25_grey.gif create mode 100644 templates/content/images/dot-g.gif create mode 100644 templates/content/images/dot-list.gif create mode 100644 templates/content/images/edit.png create mode 100644 templates/content/images/expander-arrow-hide.gif create mode 100644 templates/content/images/expander-arrow-show.gif create mode 100644 templates/content/images/favicon.gif create mode 100644 templates/content/images/favicon.ico create mode 100644 templates/content/images/feed-icon-small.png create mode 100644 templates/content/images/grippie.png create mode 100644 templates/content/images/indicator.gif create mode 100644 templates/content/images/logo.png create mode 100644 templates/content/images/logo1.png create mode 100644 templates/content/images/logo2.png create mode 100644 templates/content/images/medala.gif create mode 100644 templates/content/images/medala_on.gif create mode 100644 templates/content/images/new.gif create mode 100644 templates/content/images/nophoto.png create mode 100644 templates/content/images/openid.gif create mode 100644 templates/content/images/openid/aol.gif create mode 100644 templates/content/images/openid/blogger.ico create mode 100644 templates/content/images/openid/claimid.ico create mode 100644 templates/content/images/openid/facebook.gif create mode 100644 templates/content/images/openid/flickr.ico create mode 100644 templates/content/images/openid/google.gif create mode 100644 templates/content/images/openid/livejournal.ico create mode 100644 templates/content/images/openid/myopenid.ico create mode 100644 templates/content/images/openid/openid-inputicon.gif create mode 100644 templates/content/images/openid/openid.gif create mode 100644 templates/content/images/openid/technorati.ico create mode 100644 templates/content/images/openid/verisign.ico create mode 100644 templates/content/images/openid/vidoop.ico create mode 100644 templates/content/images/openid/wordpress.ico create mode 100644 templates/content/images/openid/yahoo.gif create mode 100644 templates/content/images/quest-bg.gif create mode 100644 templates/content/images/vote-accepted-on.png create mode 100644 templates/content/images/vote-accepted.png create mode 100644 templates/content/images/vote-arrow-down-on.png create mode 100644 templates/content/images/vote-arrow-down.png create mode 100644 templates/content/images/vote-arrow-up-on.png create mode 100644 templates/content/images/vote-arrow-up.png create mode 100644 templates/content/images/vote-favorite-off.png create mode 100644 templates/content/images/vote-favorite-on.png create mode 100644 templates/content/js/com.cnprog.editor.js create mode 100644 templates/content/js/com.cnprog.post.js create mode 100644 templates/content/js/com.cnprog.post.pack.js create mode 100644 templates/content/js/com.cnprog.utils.js create mode 100644 templates/content/js/compress.bat create mode 100644 templates/content/js/excanvas.pack.js create mode 100644 templates/content/js/flot-build.bat create mode 100644 templates/content/js/jquery-1.2.6.js create mode 100644 templates/content/js/jquery-1.2.6.min.js create mode 100644 templates/content/js/jquery.ajaxfileupload.js create mode 100644 templates/content/js/jquery.flot.js create mode 100644 templates/content/js/jquery.flot.pack.js create mode 100644 templates/content/js/jquery.openid.js create mode 100644 templates/content/js/jquery.validate.pack.js create mode 100644 templates/content/js/se_hilite.js create mode 100644 templates/content/js/se_hilite_src.js create mode 100644 templates/content/js/wmd/images/wmd-buttons.png create mode 100644 templates/content/js/wmd/showdown-min.js create mode 100644 templates/content/js/wmd/showdown.js create mode 100644 templates/content/js/wmd/wmd-min.js create mode 100644 templates/content/js/wmd/wmd-test.html create mode 100644 templates/content/js/wmd/wmd.css create mode 100644 templates/content/js/wmd/wmd.js create mode 100644 templates/content/js/yuicompressor-2.4.2.jar create mode 100644 templates/content/style/default.css create mode 100644 templates/content/style/jquery.autocomplete.css create mode 100644 templates/content/style/openid.css create mode 100644 templates/content/style/prettify.css create mode 100644 templates/content/style/style.css create mode 100644 templates/faq.html create mode 100644 templates/feeds/rss_description.html create mode 100644 templates/feeds/rss_title.html create mode 100644 templates/footer.html create mode 100644 templates/header.html create mode 100644 templates/index.html create mode 100644 templates/logout.html create mode 100644 templates/pagesize.html create mode 100644 templates/paginator.html create mode 100644 templates/privacy.html create mode 100644 templates/question.html create mode 100644 templates/question_edit.html create mode 100644 templates/question_retag.html create mode 100644 templates/questions.html create mode 100644 templates/reopen.html create mode 100644 templates/revisions_answer.html create mode 100644 templates/revisions_question.html create mode 100644 templates/tags.html create mode 100644 templates/unanswered.html create mode 100644 templates/user.html create mode 100644 templates/user_edit.html create mode 100644 templates/user_favorites.html create mode 100644 templates/user_footer.html create mode 100644 templates/user_info.html create mode 100644 templates/user_preferences.html create mode 100644 templates/user_recent.html create mode 100644 templates/user_reputation.html create mode 100644 templates/user_responses.html create mode 100644 templates/user_stats.html create mode 100644 templates/user_tabs.html create mode 100644 templates/user_votes.html create mode 100644 templates/users.html create mode 100644 templates/users_questions.html create mode 100644 urls.py create mode 100644 utils/__init__.py create mode 100644 utils/cache.py create mode 100644 utils/html.py create mode 100644 utils/lists.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..b7a3ffac5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +settings_local.py +*.pyc diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000000..59f2dd0bbe --- /dev/null +++ b/INSTALL @@ -0,0 +1,33 @@ +PRE-REQUIREMENTS: +----------------------------------------------- +1. Python2.5, MySQL, Django v1.0+ + +2. Python-openid v2.2 +http://openidenabled.com/python-openid/ + +3. django-authopenid(Included in project already) +http://code.google.com/p/django-authopenid/ + +4. html5lib +http://code.google.com/p/html5lib/ +Used for HTML sanitizer + +5. Markdown2 +http://code.google.com/p/python-markdown2/ + + +INSTALL STEPS: +----------------------------------------------- +1. Copy settings_local.py.dist to settings_local.py and +update all your settings. Check settings.py and update +it as well if necessory. + +2. Prepare your database by using the same database/account +configuration from above. + +3. Run "python manager.py runserver" to startup django +development environment. + +4. There are some demo scripts under sql_scripts folder, +including badges and test accounts for CNProg.com. You +don't need them to run your sample. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..e23e4b67fe --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +版权所有(c) 2008 CNProg.com + +根据2.0版本Apache许可证("许可证")授权; +根据本许可证,用户可以不使用此文件。 +用户可从下列网址获得许可证副本: + +http://www.apache.org/licenses/LICENSE-2.0 + +除非因适用法律需要或书面同意, +根据许可证分发的软件是基于"按原样"基础提供, +无任何明示的或暗示的保证或条件。 +详见根据许可证许可下,特定语言的管辖权限和限制。 \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/development.log b/development.log new file mode 100644 index 0000000000..e69de29bb2 diff --git a/django_authopenid/__init__.py b/django_authopenid/__init__.py new file mode 100644 index 0000000000..ff040ed707 --- /dev/null +++ b/django_authopenid/__init__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2007, 2008, Beno卯t Chesneau +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# * notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# * notice, this list of conditions and the following disclaimer in the +# * documentation and/or other materials provided with the +# * distribution. Neither the name of the nor the names +# * of its contributors may be used to endorse or promote products +# * derived from this software without specific prior written +# * permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Django authentification application to *with openid using django auth contrib/. + +This application allow a user to connect to you website with : + * legacy account : username/password + * openid url +""" + +__version__ = "0.9.4" diff --git a/django_authopenid/admin.py b/django_authopenid/admin.py new file mode 100644 index 0000000000..f64ee57914 --- /dev/null +++ b/django_authopenid/admin.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- + +from django.contrib import admin +from django_authopenid.models import UserAssociation + + +class UserAssociationAdmin(admin.ModelAdmin): + """User association admin class""" +admin.site.register(UserAssociation, UserAssociationAdmin) \ No newline at end of file diff --git a/django_authopenid/forms.py b/django_authopenid/forms.py new file mode 100644 index 0000000000..9c519d7474 --- /dev/null +++ b/django_authopenid/forms.py @@ -0,0 +1,435 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2007, 2008, Beno卯t Chesneau +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# * notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# * notice, this list of conditions and the following disclaimer in the +# * documentation and/or other materials provided with the +# * distribution. Neither the name of the nor the names +# * of its contributors may be used to endorse or promote products +# * derived from this software without specific prior written +# * permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +from django import forms +from django.contrib.auth.models import User +from django.contrib.auth import authenticate +from django.utils.translation import ugettext as _ +from django.conf import settings + +import re + + +# needed for some linux distributions like debian +try: + from openid.yadis import xri +except ImportError: + from yadis import xri + +from django_authopenid.util import clean_next + +__all__ = ['OpenidSigninForm', 'OpenidAuthForm', 'OpenidVerifyForm', + 'OpenidRegisterForm', 'RegistrationForm', 'ChangepwForm', + 'ChangeemailForm', 'EmailPasswordForm', 'DeleteForm', + 'ChangeOpenidForm', 'ChangeEmailForm', 'ChangepwForm'] + +class OpenidSigninForm(forms.Form): + """ signin form """ + openid_url = forms.CharField(max_length=255, widget=forms.widgets.TextInput(attrs={'class': 'openid-login-input', 'size':80})) + next = forms.CharField(max_length=255, widget=forms.HiddenInput(), required=False) + + def clean_openid_url(self): + """ test if openid is accepted """ + if 'openid_url' in self.cleaned_data: + openid_url = self.cleaned_data['openid_url'] + if xri.identifierScheme(openid_url) == 'XRI' and getattr( + settings, 'OPENID_DISALLOW_INAMES', False + ): + raise forms.ValidationError(_('i-names are not supported')) + return self.cleaned_data['openid_url'] + + def clean_next(self): + """ validate next """ + if 'next' in self.cleaned_data and self.cleaned_data['next'] != "": + self.cleaned_data['next'] = clean_next(self.cleaned_data['next']) + return self.cleaned_data['next'] + + +attrs_dict = { 'class': 'required login' } +username_re = re.compile(r'^\w+$') +RESERVED_NAMES = (u'fuck', u'shit', u'ass', u'sex', u'add', + u'edit', u'save', u'delete', u'manage', u'update', 'remove', 'new') + +class OpenidAuthForm(forms.Form): + """ legacy account signin form """ + next = forms.CharField(max_length=255, widget=forms.HiddenInput(), + required=False) + username = forms.CharField(max_length=30, + widget=forms.widgets.TextInput(attrs=attrs_dict)) + password = forms.CharField(max_length=128, + widget=forms.widgets.PasswordInput(attrs=attrs_dict)) + + def __init__(self, data=None, files=None, auto_id='id_%s', + prefix=None, initial=None): + super(OpenidAuthForm, self).__init__(data, files, auto_id, + prefix, initial) + self.user_cache = None + + def clean_username(self): + """ validate username and test if it exists.""" + if 'username' in self.cleaned_data and \ + 'openid_url' not in self.cleaned_data: + if not username_re.search(self.cleaned_data['username']): + raise forms.ValidationError(_("Usernames can only contain \ + letters, numbers and underscores")) + try: + user = User.objects.get( + username__exact = self.cleaned_data['username'] + ) + except User.DoesNotExist: + raise forms.ValidationError(_("This username does not exist \ + in our database. Please choose another.")) + except User.MultipleObjectsReturned: + raise forms.ValidationError(u'There is already more than one \ + account registered with that username. Please try \ + another.') + return self.cleaned_data['username'] + + def clean_password(self): + """" test if password is valid for this username """ + if 'username' in self.cleaned_data and \ + 'password' in self.cleaned_data: + self.user_cache = authenticate( + username=self.cleaned_data['username'], + password=self.cleaned_data['password'] + ) + if self.user_cache is None: + raise forms.ValidationError(_("Please enter a valid \ + username and password. Note that both fields are \ + case-sensitive.")) + elif self.user_cache.is_active == False: + raise forms.ValidationError(_("This account is inactive.")) + return self.cleaned_data['password'] + + def clean_next(self): + """ validate next url """ + if 'next' in self.cleaned_data and \ + self.cleaned_data['next'] != "": + self.cleaned_data['next'] = clean_next(self.cleaned_data['next']) + return self.cleaned_data['next'] + + def get_user(self): + """ get authenticated user """ + return self.user_cache + + +class OpenidRegisterForm(forms.Form): + """ openid signin form """ + next = forms.CharField(max_length=255, widget=forms.HiddenInput(), + required=False) + username = forms.CharField(max_length=30, + widget=forms.widgets.TextInput(attrs=attrs_dict)) + email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict, + maxlength=200)), label=u'Email address') + + def clean_username(self): + """ test if username is valid and exist in database """ + if 'username' in self.cleaned_data: + if not username_re.search(self.cleaned_data['username']): + raise forms.ValidationError(u"鐢ㄦ埛鍚嶅彧鑳藉寘鍚嫳鏂囧瓧姣嶃佹暟瀛楀拰涓嬪垝绾") + if self.cleaned_data['username'] in RESERVED_NAMES: + raise forms.ValidationError(u'瀵逛笉璧凤紝鎮ㄤ笉鑳芥敞鍐岃鐢ㄦ埛鍚嶏紝璇锋崲涓涓瘯璇') + if len(self.cleaned_data['username']) < 3: + raise forms.ValidationError(u'鐢ㄦ埛鍚嶅お鐭紝璇蜂娇鐢ㄤ笁涓垨涓変釜浠ヤ笂瀛楃') + try: + user = User.objects.get( + username__exact = self.cleaned_data['username'] + ) + except User.DoesNotExist: + return self.cleaned_data['username'] + except User.MultipleObjectsReturned: + raise forms.ValidationError(u'璇ョ敤鎴峰悕宸茶娉ㄥ唽锛岃鎹竴涓瘯璇') + raise forms.ValidationError(u'璇ョ敤鎴峰悕宸茶娉ㄥ唽锛岃鎹釜璇曡瘯') + + def clean_email(self): + """For security reason one unique email in database""" + if 'email' in self.cleaned_data: + try: + user = User.objects.get(email = self.cleaned_data['email']) + except User.DoesNotExist: + return self.cleaned_data['email'] + except User.MultipleObjectsReturned: + raise forms.ValidationError(u'There is already more than one \ + account registered with that e-mail address. Please try \ + another.') + raise forms.ValidationError(_("This email is already \ + registered in our database. Please choose another.")) + + +class OpenidVerifyForm(forms.Form): + """ openid verify form (associate an openid with an account) """ + next = forms.CharField(max_length=255, widget = forms.HiddenInput(), + required=False) + username = forms.CharField(max_length=30, + widget=forms.widgets.TextInput(attrs=attrs_dict)) + password = forms.CharField(max_length=128, + widget=forms.widgets.PasswordInput(attrs=attrs_dict)) + + def __init__(self, data=None, files=None, auto_id='id_%s', + prefix=None, initial=None): + super(OpenidVerifyForm, self).__init__(data, files, auto_id, + prefix, initial) + self.user_cache = None + + def clean_username(self): + """ validate username """ + if 'username' in self.cleaned_data: + if not username_re.search(self.cleaned_data['username']): + raise forms.ValidationError(_("Usernames can only contain \ + letters, numbers and underscores")) + try: + user = User.objects.get( + username__exact = self.cleaned_data['username'] + ) + except User.DoesNotExist: + raise forms.ValidationError(_("This username don't exist. \ + Please choose another.")) + except User.MultipleObjectsReturned: + raise forms.ValidationError(u'Somehow, that username is in \ + use for multiple accounts. Please contact us to get this \ + problem resolved.') + return self.cleaned_data['username'] + + def clean_password(self): + """ test if password is valid for this user """ + if 'username' in self.cleaned_data and \ + 'password' in self.cleaned_data: + self.user_cache = authenticate( + username = self.cleaned_data['username'], + password = self.cleaned_data['password'] + ) + if self.user_cache is None: + raise forms.ValidationError(_("Please enter a valid \ + username and password. Note that both fields are \ + case-sensitive.")) + elif self.user_cache.is_active == False: + raise forms.ValidationError(_("This account is inactive.")) + return self.cleaned_data['password'] + + def get_user(self): + """ get authenticated user """ + return self.user_cache + + +attrs_dict = { 'class': 'required' } +username_re = re.compile(r'^\w+$') + +class RegistrationForm(forms.Form): + """ legacy registration form """ + + next = forms.CharField(max_length=255, widget=forms.HiddenInput(), + required=False) + username = forms.CharField(max_length=30, + widget=forms.TextInput(attrs=attrs_dict), + label=u'Username') + email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict, + maxlength=200)), label=u'Email address') + password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict), + label=u'Password') + password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict), + label=u'Password (again, to catch typos)') + + def clean_username(self): + """ + Validates that the username is alphanumeric and is not already + in use. + + """ + if 'username' in self.cleaned_data: + if not username_re.search(self.cleaned_data['username']): + raise forms.ValidationError(u'Usernames can only contain \ + letters, numbers and underscores') + try: + user = User.objects.get( + username__exact = self.cleaned_data['username'] + ) + + except User.DoesNotExist: + return self.cleaned_data['username'] + except User.MultipleObjectsReturned: + raise forms.ValidationError(u'Somehow, that username is in \ + use for multiple accounts. Please contact us to get this \ + problem resolved.') + raise forms.ValidationError(u'This username is already taken. \ + Please choose another.') + + def clean_email(self): + """ validate if email exist in database + :return: raise error if it exist """ + if 'email' in self.cleaned_data: + try: + user = User.objects.get(email = self.cleaned_data['email']) + except User.DoesNotExist: + return self.cleaned_data['email'] + except User.MultipleObjectsReturned: + raise forms.ValidationError(u'There is already more than one \ + account registered with that e-mail address. Please try \ + another.') + raise forms.ValidationError(u'This email is already registered \ + in our database. Please choose another.') + return self.cleaned_data['email'] + + def clean_password2(self): + """ + Validates that the two password inputs match. + + """ + if 'password1' in self.cleaned_data and \ + 'password2' in self.cleaned_data and \ + self.cleaned_data['password1'] == \ + self.cleaned_data['password2']: + return self.cleaned_data['password2'] + raise forms.ValidationError(u'You must type the same password each \ + time') + + +class ChangepwForm(forms.Form): + """ change password form """ + oldpw = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict)) + password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict)) + password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict)) + + def __init__(self, data=None, user=None, *args, **kwargs): + if user is None: + raise TypeError("Keyword argument 'user' must be supplied") + super(ChangepwForm, self).__init__(data, *args, **kwargs) + self.user = user + + def clean_oldpw(self): + """ test old password """ + if not self.user.check_password(self.cleaned_data['oldpw']): + raise forms.ValidationError(_("Old password is incorrect. \ + Please enter the correct password.")) + return self.cleaned_data['oldpw'] + + def clean_password2(self): + """ + Validates that the two password inputs match. + """ + if 'password1' in self.cleaned_data and \ + 'password2' in self.cleaned_data and \ + self.cleaned_data['password1'] == self.cleaned_data['password2']: + return self.cleaned_data['password2'] + raise forms.ValidationError(_("new passwords do not match")) + + +class ChangeemailForm(forms.Form): + """ change email form """ + email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict, + maxlength=200)), label=u'Email address') + password = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict)) + + def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, \ + initial=None, user=None): + if user is None: + raise TypeError("Keyword argument 'user' must be supplied") + super(ChangeemailForm, self).__init__(data, files, auto_id, + prefix, initial) + self.test_openid = False + self.user = user + + + def clean_email(self): + """ check if email don't exist """ + if 'email' in self.cleaned_data: + if self.user.email != self.cleaned_data['email']: + try: + user = User.objects.get(email = self.cleaned_data['email']) + except User.DoesNotExist: + return self.cleaned_data['email'] + except User.MultipleObjectsReturned: + raise forms.ValidationError(u'There is already more than one \ + account registered with that e-mail address. Please try \ + another.') + raise forms.ValidationError(u'This email is already registered \ + in our database. Please choose another.') + return self.cleaned_data['email'] + + + def clean_password(self): + """ check if we have to test a legacy account or not """ + if 'password' in self.cleaned_data: + if not self.user.check_password(self.cleaned_data['password']): + self.test_openid = True + return self.cleaned_data['password'] + +class ChangeopenidForm(forms.Form): + """ change openid form """ + openid_url = forms.CharField(max_length=255, + widget=forms.TextInput(attrs={'class': "required" })) + + def __init__(self, data=None, user=None, *args, **kwargs): + if user is None: + raise TypeError("Keyword argument 'user' must be supplied") + super(ChangeopenidForm, self).__init__(data, *args, **kwargs) + self.user = user + +class DeleteForm(forms.Form): + """ confirm form to delete an account """ + confirm = forms.CharField(widget=forms.CheckboxInput(attrs=attrs_dict)) + password = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict)) + + def __init__(self, data=None, files=None, auto_id='id_%s', + prefix=None, initial=None, user=None): + super(DeleteForm, self).__init__(data, files, auto_id, prefix, initial) + self.test_openid = False + self.user = user + + def clean_password(self): + """ check if we have to test a legacy account or not """ + if 'password' in self.cleaned_data: + if not self.user.check_password(self.cleaned_data['password']): + self.test_openid = True + return self.cleaned_data['password'] + + +class EmailPasswordForm(forms.Form): + """ send new password form """ + username = forms.CharField(max_length=30, + widget=forms.TextInput(attrs={'class': "required" })) + + def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, + initial=None): + super(EmailPasswordForm, self).__init__(data, files, auto_id, + prefix, initial) + self.user_cache = None + + + def clean_username(self): + """ get user for this username """ + if 'username' in self.cleaned_data: + try: + self.user_cache = User.objects.get( + username = self.cleaned_data['username']) + except: + raise forms.ValidationError(_("Incorrect username.")) + return self.cleaned_data['username'] diff --git a/django_authopenid/middleware.py b/django_authopenid/middleware.py new file mode 100644 index 0000000000..c0572c6e73 --- /dev/null +++ b/django_authopenid/middleware.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from django_authopenid import mimeparse +from django.http import HttpResponseRedirect +from django.core.urlresolvers import reverse + +__all__ = ["OpenIDMiddleware"] + +class OpenIDMiddleware(object): + """ + Populate request.openid. This comes either from cookie or from + session, depending on the presence of OPENID_USE_SESSIONS. + """ + def process_request(self, request): + request.openid = request.session.get('openid', None) + + def process_response(self, request, response): + if response.status_code != 200 or len(response.content) < 200: + return response + path = request.get_full_path() + if path == "/" and request.META.has_key('HTTP_ACCEPT') and \ + mimeparse.best_match(['text/html', 'application/xrds+xml'], + request.META['HTTP_ACCEPT']) == 'application/xrds+xml': + return HttpResponseRedirect(reverse('yadis_xrdf')) + return response \ No newline at end of file diff --git a/django_authopenid/mimeparse.py b/django_authopenid/mimeparse.py new file mode 100644 index 0000000000..ab02eab0fe --- /dev/null +++ b/django_authopenid/mimeparse.py @@ -0,0 +1,160 @@ +"""MIME-Type Parser + +This module provides basic functions for handling mime-types. It can handle +matching mime-types against a list of media-ranges. See section 14.1 of +the HTTP specification [RFC 2616] for a complete explaination. + + http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 + +Contents: + - parse_mime_type(): Parses a mime-type into it's component parts. + - parse_media_range(): Media-ranges are mime-types with wild-cards and a 'q' quality parameter. + - quality(): Determines the quality ('q') of a mime-type when compared against a list of media-ranges. + - quality_parsed(): Just like quality() except the second parameter must be pre-parsed. + - best_match(): Choose the mime-type with the highest quality ('q') from a list of candidates. +""" + +__version__ = "0.1.1" +__author__ = 'Joe Gregorio' +__email__ = "joe@bitworking.org" +__credits__ = "" + +def parse_mime_type(mime_type): + """Carves up a mime_type and returns a tuple of the + (type, subtype, params) where 'params' is a dictionary + of all the parameters for the media range. + For example, the media range 'application/xhtml;q=0.5' would + get parsed into: + + ('application', 'xhtml', {'q', '0.5'}) + """ + parts = mime_type.split(";") + params = dict([tuple([s.strip() for s in param.split("=")])\ + for param in parts[1:] ]) + (type, subtype) = parts[0].split("/") + return (type.strip(), subtype.strip(), params) + +def parse_media_range(range): + """Carves up a media range and returns a tuple of the + (type, subtype, params) where 'params' is a dictionary + of all the parameters for the media range. + For example, the media range 'application/*;q=0.5' would + get parsed into: + + ('application', '*', {'q', '0.5'}) + + In addition this function also guarantees that there + is a value for 'q' in the params dictionary, filling it + in with a proper default if necessary. + """ + (type, subtype, params) = parse_mime_type(range) + if not params.has_key('q') or not params['q'] or \ + not float(params['q']) or float(params['q']) > 1\ + or float(params['q']) < 0: + params['q'] = '1' + return (type, subtype, params) + +def quality_parsed(mime_type, parsed_ranges): + """Find the best match for a given mime_type against + a list of media_ranges that have already been + parsed by parse_media_range(). Returns the + 'q' quality parameter of the best match, 0 if no + match was found. This function bahaves the same as quality() + except that 'parsed_ranges' must be a list of + parsed media ranges. """ + best_fitness = -1 + best_match = "" + best_fit_q = 0 + (target_type, target_subtype, target_params) =\ + parse_media_range(mime_type) + for (type, subtype, params) in parsed_ranges: + param_matches = reduce(lambda x, y: x+y, [1 for (key, value) in \ + target_params.iteritems() if key != 'q' and \ + params.has_key(key) and value == params[key]], 0) + if (type == target_type or type == '*' or target_type == '*') and \ + (subtype == target_subtype or subtype == '*' or target_subtype == '*'): + fitness = (type == target_type) and 100 or 0 + fitness += (subtype == target_subtype) and 10 or 0 + fitness += param_matches + if fitness > best_fitness: + best_fitness = fitness + best_fit_q = params['q'] + + return float(best_fit_q) + +def quality(mime_type, ranges): + """Returns the quality 'q' of a mime_type when compared + against the media-ranges in ranges. For example: + + >>> quality('text/html','text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5') + 0.7 + + """ + parsed_ranges = [parse_media_range(r) for r in ranges.split(",")] + return quality_parsed(mime_type, parsed_ranges) + +def best_match(supported, header): + """Takes a list of supported mime-types and finds the best + match for all the media-ranges listed in header. The value of + header must be a string that conforms to the format of the + HTTP Accept: header. The value of 'supported' is a list of + mime-types. + + >>> best_match(['application/xbel+xml', 'text/xml'], 'text/*;q=0.5,*/*; q=0.1') + 'text/xml' + """ + parsed_header = [parse_media_range(r) for r in header.split(",")] + weighted_matches = [(quality_parsed(mime_type, parsed_header), mime_type)\ + for mime_type in supported] + weighted_matches.sort() + return weighted_matches[-1][0] and weighted_matches[-1][1] or '' + +if __name__ == "__main__": + import unittest + + class TestMimeParsing(unittest.TestCase): + + def test_parse_media_range(self): + self.assert_(('application', 'xml', {'q': '1'}) == parse_media_range('application/xml;q=1')) + self.assertEqual(('application', 'xml', {'q': '1'}), parse_media_range('application/xml')) + self.assertEqual(('application', 'xml', {'q': '1'}), parse_media_range('application/xml;q=')) + self.assertEqual(('application', 'xml', {'q': '1'}), parse_media_range('application/xml ; q=')) + self.assertEqual(('application', 'xml', {'q': '1', 'b': 'other'}), parse_media_range('application/xml ; q=1;b=other')) + self.assertEqual(('application', 'xml', {'q': '1', 'b': 'other'}), parse_media_range('application/xml ; q=2;b=other')) + + def test_rfc_2616_example(self): + accept = "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5" + self.assertEqual(1, quality("text/html;level=1", accept)) + self.assertEqual(0.7, quality("text/html", accept)) + self.assertEqual(0.3, quality("text/plain", accept)) + self.assertEqual(0.5, quality("image/jpeg", accept)) + self.assertEqual(0.4, quality("text/html;level=2", accept)) + self.assertEqual(0.7, quality("text/html;level=3", accept)) + + def test_best_match(self): + mime_types_supported = ['application/xbel+xml', 'application/xml'] + # direct match + self.assertEqual(best_match(mime_types_supported, 'application/xbel+xml'), 'application/xbel+xml') + # direct match with a q parameter + self.assertEqual(best_match(mime_types_supported, 'application/xbel+xml; q=1'), 'application/xbel+xml') + # direct match of our second choice with a q parameter + self.assertEqual(best_match(mime_types_supported, 'application/xml; q=1'), 'application/xml') + # match using a subtype wildcard + self.assertEqual(best_match(mime_types_supported, 'application/*; q=1'), 'application/xml') + # match using a type wildcard + self.assertEqual(best_match(mime_types_supported, '*/*'), 'application/xml') + + mime_types_supported = ['application/xbel+xml', 'text/xml'] + # match using a type versus a lower weighted subtype + self.assertEqual(best_match(mime_types_supported, 'text/*;q=0.5,*/*; q=0.1'), 'text/xml') + # fail to match anything + self.assertEqual(best_match(mime_types_supported, 'text/html,application/atom+xml; q=0.9'), '') + + def test_support_wildcards(self): + mime_types_supported = ['image/*', 'application/xml'] + # match using a type wildcard + self.assertEqual(best_match(mime_types_supported, 'image/png'), 'image/*') + # match using a wildcard for both requested and supported + self.assertEqual(best_match(mime_types_supported, 'image/*'), 'image/*') + + unittest.main() \ No newline at end of file diff --git a/django_authopenid/models.py b/django_authopenid/models.py new file mode 100644 index 0000000000..9826c452b6 --- /dev/null +++ b/django_authopenid/models.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +from django.conf import settings +from django.contrib.auth.models import User +from django.db import models + +import md5, random, sys, os, time + +__all__ = ['Nonce', 'Association', 'UserAssociation', + 'UserPasswordQueueManager', 'UserPasswordQueue'] + +class Nonce(models.Model): + """ openid nonce """ + server_url = models.CharField(max_length=255) + timestamp = models.IntegerField() + salt = models.CharField(max_length=40) + + def __unicode__(self): + return u"Nonce: %s" % self.id + + +class Association(models.Model): + """ association openid url and lifetime """ + server_url = models.TextField(max_length=2047) + handle = models.CharField(max_length=255) + secret = models.TextField(max_length=255) # Stored base64 encoded + issued = models.IntegerField() + lifetime = models.IntegerField() + assoc_type = models.TextField(max_length=64) + + def __unicode__(self): + return u"Association: %s, %s" % (self.server_url, self.handle) + +class UserAssociation(models.Model): + """ + model to manage association between openid and user + """ + openid_url = models.CharField(blank=False, max_length=255) + user = models.ForeignKey(User, unique=True) + + def __unicode__(self): + return "Openid %s with user %s" % (self.openid_url, self.user) + +class UserPasswordQueueManager(models.Manager): + """ manager for UserPasswordQueue object """ + def get_new_confirm_key(self): + "Returns key that isn't being used." + # The random module is seeded when this Apache child is created. + # Use SECRET_KEY as added salt. + while 1: + confirm_key = md5.new("%s%s%s%s" % ( + random.randint(0, sys.maxint - 1), os.getpid(), + time.time(), settings.SECRET_KEY)).hexdigest() + try: + self.get(confirm_key=confirm_key) + except self.model.DoesNotExist: + break + return confirm_key + + +class UserPasswordQueue(models.Model): + """ + model for new password queue. + """ + user = models.ForeignKey(User, unique=True) + new_password = models.CharField(max_length=30) + confirm_key = models.CharField(max_length=40) + + objects = UserPasswordQueueManager() + + def __unicode__(self): + return self.user.username diff --git a/django_authopenid/urls.py b/django_authopenid/urls.py new file mode 100644 index 0000000000..1ab6594165 --- /dev/null +++ b/django_authopenid/urls.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +from django.conf.urls.defaults import patterns, url +from django.utils.translation import ugettext as _ + +urlpatterns = patterns('django_authopenid.views', + # yadis rdf + url(r'^yadis.xrdf$', 'xrdf', name='yadis_xrdf'), + # manage account registration + url(r'^%s$' % _('signin/'), 'signin', name='user_signin'), + url(r'^%s$' % _('signout/'), 'signout', name='user_signout'), + url(r'^%s%s$' % (_('signin/'), _('complete/')), 'complete_signin', + name='user_complete_signin'), + url(r'^%s$' % _('register/'), 'register', name='user_register'), + url(r'^%s$' % _('signup/'), 'signup', name='user_signup'), + #disable current sendpw function + url(r'^%s$' % _('sendpw/'), 'signin', name='user_sendpw'), + #url(r'^%s$' % _('sendpw/'), 'sendpw', name='user_sendpw'), + #url(r'^%s%s$' % (_('password/'), _('confirm/')), 'confirmchangepw', + # name='user_confirmchangepw'), + + # manage account settings + #url(r'^$', 'account_settings', name='user_account_settings'), + #url(r'^%s$' % _('password/'), 'changepw', name='user_changepw'), + #url(r'^%s$' % _('email/'), 'changeemail', name='user_changeemail'), + #url(r'^%s$' % _('openid/'), 'changeopenid', name='user_changeopenid'), + url(r'^%s$' % _('delete/'), 'delete', name='user_delete'), +) diff --git a/django_authopenid/util.py b/django_authopenid/util.py new file mode 100644 index 0000000000..841a81c7b5 --- /dev/null +++ b/django_authopenid/util.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +from openid.store.interface import OpenIDStore +from openid.association import Association as OIDAssociation +from openid.extensions import sreg +import openid.store + +from django.db.models.query import Q +from django.conf import settings +from django.http import str_to_unicode + + +# needed for some linux distributions like debian +try: + from openid.yadis import xri +except: + from yadis import xri + +import time, base64, md5, operator +import urllib + +from models import Association, Nonce + +__all__ = ['OpenID', 'DjangoOpenIDStore', 'from_openid_response', 'clean_next'] + +DEFAULT_NEXT = getattr(settings, 'OPENID_REDIRECT_NEXT', '/') +def clean_next(next): + if next is None: + return DEFAULT_NEXT + next = str_to_unicode(urllib.unquote(next), 'utf-8') + next = next.strip() + if next.startswith('/'): + return next + return DEFAULT_NEXT + +class OpenID: + def __init__(self, openid_, issued, attrs=None, sreg_=None): + self.openid = openid_ + self.issued = issued + self.attrs = attrs or {} + self.sreg = sreg_ or {} + self.is_iname = (xri.identifierScheme(openid_) == 'XRI') + + def __repr__(self): + return '' % self.openid + + def __str__(self): + return self.openid + +class DjangoOpenIDStore(OpenIDStore): + def __init__(self): + self.max_nonce_age = 6 * 60 * 60 # Six hours + + def storeAssociation(self, server_url, association): + assoc = Association( + server_url = server_url, + handle = association.handle, + secret = base64.encodestring(association.secret), + issued = association.issued, + lifetime = association.issued, + assoc_type = association.assoc_type + ) + assoc.save() + + def getAssociation(self, server_url, handle=None): + assocs = [] + if handle is not None: + assocs = Association.objects.filter( + server_url = server_url, handle = handle + ) + else: + assocs = Association.objects.filter( + server_url = server_url + ) + if not assocs: + return None + associations = [] + for assoc in assocs: + association = OIDAssociation( + assoc.handle, base64.decodestring(assoc.secret), assoc.issued, + assoc.lifetime, assoc.assoc_type + ) + if association.getExpiresIn() == 0: + self.removeAssociation(server_url, assoc.handle) + else: + associations.append((association.issued, association)) + if not associations: + return None + return associations[-1][1] + + def removeAssociation(self, server_url, handle): + assocs = list(Association.objects.filter( + server_url = server_url, handle = handle + )) + assocs_exist = len(assocs) > 0 + for assoc in assocs: + assoc.delete() + return assocs_exist + + def useNonce(self, server_url, timestamp, salt): + if abs(timestamp - time.time()) > openid.store.nonce.SKEW: + return False + + query = [ + Q(server_url__exact=server_url), + Q(timestamp__exact=timestamp), + Q(salt__exact=salt), + ] + try: + ononce = Nonce.objects.get(reduce(operator.and_, query)) + except Nonce.DoesNotExist: + ononce = Nonce( + server_url=server_url, + timestamp=timestamp, + salt=salt + ) + ononce.save() + return True + + ononce.delete() + + return False + + def cleanupNonce(self): + Nonce.objects.filter(timestamp nor the names +# * of its contributors may be used to endorse or promote products +# * derived from this software without specific prior written +# * permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from django.http import HttpResponseRedirect, get_host +from django.shortcuts import render_to_response as render +from django.template import RequestContext, loader, Context +from django.conf import settings +from django.contrib.auth.models import User +from django.contrib.auth import login, logout +from django.contrib.auth.decorators import login_required +from django.core.urlresolvers import reverse +from django.utils.encoding import smart_unicode +from django.utils.html import escape +from django.utils.translation import ugettext as _ +from django.contrib.sites.models import Site +from django.utils.http import urlquote_plus +from django.core.mail import send_mail + +from openid.consumer.consumer import Consumer, \ + SUCCESS, CANCEL, FAILURE, SETUP_NEEDED +from openid.consumer.discover import DiscoveryFailure +from openid.extensions import sreg +# needed for some linux distributions like debian +try: + from openid.yadis import xri +except ImportError: + from yadis import xri + +import re +import urllib + + +from django_authopenid.util import OpenID, DjangoOpenIDStore, from_openid_response, clean_next +from django_authopenid.models import UserAssociation, UserPasswordQueue +from django_authopenid.forms import OpenidSigninForm, OpenidAuthForm, OpenidRegisterForm, \ + OpenidVerifyForm, RegistrationForm, ChangepwForm, ChangeemailForm, \ + ChangeopenidForm, DeleteForm, EmailPasswordForm + +def get_url_host(request): + if request.is_secure(): + protocol = 'https' + else: + protocol = 'http' + host = escape(get_host(request)) + return '%s://%s' % (protocol, host) + +def get_full_url(request): + return get_url_host(request) + request.get_full_path() + + + +def ask_openid(request, openid_url, redirect_to, on_failure=None, + sreg_request=None): + """ basic function to ask openid and return response """ + request.encoding = 'UTF-8' + on_failure = on_failure or signin_failure + + trust_root = getattr( + settings, 'OPENID_TRUST_ROOT', get_url_host(request) + '/' + ) + if xri.identifierScheme(openid_url) == 'XRI' and getattr( + settings, 'OPENID_DISALLOW_INAMES', False + ): + msg = _("i-names are not supported") + return on_failure(request, msg) + consumer = Consumer(request.session, DjangoOpenIDStore()) + try: + auth_request = consumer.begin(openid_url) + except DiscoveryFailure: + msg = _(u"闈炴硶OpenID鍦板潃锛 %s" % openid_url) + return on_failure(request, msg) + + if sreg_request: + auth_request.addExtension(sreg_request) + redirect_url = auth_request.redirectURL(trust_root, redirect_to) + return HttpResponseRedirect(redirect_url) + +def complete(request, on_success=None, on_failure=None, return_to=None): + """ complete openid signin """ + on_success = on_success or default_on_success + on_failure = on_failure or default_on_failure + + consumer = Consumer(request.session, DjangoOpenIDStore()) + # make sure params are encoded in utf8 + params = dict((k,smart_unicode(v)) for k, v in request.GET.items()) + openid_response = consumer.complete(params, return_to) + + + if openid_response.status == SUCCESS: + return on_success(request, openid_response.identity_url, + openid_response) + elif openid_response.status == CANCEL: + return on_failure(request, 'The request was canceled') + elif openid_response.status == FAILURE: + return on_failure(request, openid_response.message) + elif openid_response.status == SETUP_NEEDED: + return on_failure(request, 'Setup needed') + else: + assert False, "Bad openid status: %s" % openid_response.status + +def default_on_success(request, identity_url, openid_response): + """ default action on openid signin success """ + request.session['openid'] = from_openid_response(openid_response) + return HttpResponseRedirect(clean_next(request.GET.get('next'))) + +def default_on_failure(request, message): + """ default failure action on signin """ + return render('openid_failure.html', { + 'message': message + }) + + +def not_authenticated(func): + """ decorator that redirect user to next page if + he is already logged.""" + def decorated(request, *args, **kwargs): + if request.user.is_authenticated(): + next = request.GET.get("next", "/") + return HttpResponseRedirect(next) + return func(request, *args, **kwargs) + return decorated + +@not_authenticated +def signin(request): + """ + signin page. It manage the legacy authentification (user/password) + and authentification with openid. + + url: /signin/ + + template : authopenid/signin.htm + """ + request.encoding = 'UTF-8' + on_failure = signin_failure + next = clean_next(request.GET.get('next')) + + form_signin = OpenidSigninForm(initial={'next':next}) + form_auth = OpenidAuthForm(initial={'next':next}) + + if request.POST: + + if 'bsignin' in request.POST.keys(): + + form_signin = OpenidSigninForm(request.POST) + if form_signin.is_valid(): + next = clean_next(form_signin.cleaned_data.get('next')) + sreg_req = sreg.SRegRequest(optional=['nickname', 'email']) + redirect_to = "%s%s?%s" % ( + get_url_host(request), + reverse('user_complete_signin'), + urllib.urlencode({'next':next}) + ) + + return ask_openid(request, + form_signin.cleaned_data['openid_url'], + redirect_to, + on_failure=signin_failure, + sreg_request=sreg_req) + + elif 'blogin' in request.POST.keys(): + # perform normal django authentification + form_auth = OpenidAuthForm(request.POST) + if form_auth.is_valid(): + user_ = form_auth.get_user() + login(request, user_) + next = clean_next(form_auth.cleaned_data.get('next')) + return HttpResponseRedirect(next) + + + return render('authopenid/signin.html', { + 'form1': form_auth, + 'form2': form_signin, + 'msg': request.GET.get('msg',''), + 'sendpw_url': reverse('user_sendpw'), + }, context_instance=RequestContext(request)) + +def complete_signin(request): + """ in case of complete signin with openid """ + return complete(request, signin_success, signin_failure, + get_url_host(request) + reverse('user_complete_signin')) + + +def signin_success(request, identity_url, openid_response): + """ + openid signin success. + + If the openid is already registered, the user is redirected to + url set par next or in settings with OPENID_REDIRECT_NEXT variable. + If none of these urls are set user is redirectd to /. + + if openid isn't registered user is redirected to register page. + """ + + openid_ = from_openid_response(openid_response) + request.session['openid'] = openid_ + try: + rel = UserAssociation.objects.get(openid_url__exact = str(openid_)) + except: + # try to register this new user + return register(request) + user_ = rel.user + if user_.is_active: + user_.backend = "django.contrib.auth.backends.ModelBackend" + login(request, user_) + + next = clean_next(request.GET.get('next')) + return HttpResponseRedirect(next) + +def is_association_exist(openid_url): + """ test if an openid is already in database """ + is_exist = True + try: + uassoc = UserAssociation.objects.get(openid_url__exact = openid_url) + except: + is_exist = False + return is_exist + +@not_authenticated +def register(request): + """ + register an openid. + + If user is already a member he can associate its openid with + its account. + + A new account could also be created and automaticaly associated + to the openid. + + url : /complete/ + + template : authopenid/complete.html + """ + + is_redirect = False + next = clean_next(request.GET.get('next')) + openid_ = request.session.get('openid', None) + if not openid_: + return HttpResponseRedirect(reverse('user_signin') + next) + + nickname = openid_.sreg.get('nickname', '') + email = openid_.sreg.get('email', '') + + form1 = OpenidRegisterForm(initial={ + 'next': next, + 'username': nickname, + 'email': email, + }) + form2 = OpenidVerifyForm(initial={ + 'next': next, + 'username': nickname, + }) + + if request.POST: + just_completed = False + if 'bnewaccount' in request.POST.keys(): + form1 = OpenidRegisterForm(request.POST) + if form1.is_valid(): + next = clean_next(form1.cleaned_data.get('next')) + is_redirect = True + tmp_pwd = User.objects.make_random_password() + user_ = User.objects.create_user(form1.cleaned_data['username'], + form1.cleaned_data['email'], tmp_pwd) + + # make association with openid + uassoc = UserAssociation(openid_url=str(openid_), + user_id=user_.id) + uassoc.save() + + # login + user_.backend = "django.contrib.auth.backends.ModelBackend" + login(request, user_) + elif 'bverify' in request.POST.keys(): + form2 = OpenidVerifyForm(request.POST) + if form2.is_valid(): + is_redirect = True + next = clean_next(form2.cleaned_data.get('next')) + user_ = form2.get_user() + + uassoc = UserAssociation(openid_url=str(openid_), + user_id=user_.id) + uassoc.save() + login(request, user_) + + # redirect, can redirect only if forms are valid. + if is_redirect: + return HttpResponseRedirect(next) + + return render('authopenid/complete.html', { + 'form1': form1, + 'form2': form2, + 'nickname': nickname, + 'email': email + }, context_instance=RequestContext(request)) + +def signin_failure(request, message): + """ + falure with openid signin. Go back to signin page. + + template : "authopenid/signin.html" + """ + next = clean_next(request.GET.get('next')) + form_signin = OpenidSigninForm(initial={'next': next}) + form_auth = OpenidAuthForm(initial={'next': next}) + + return render('authopenid/signin.html', { + 'msg': message, + 'form1': form_auth, + 'form2': form_signin, + }, context_instance=RequestContext(request)) + +@not_authenticated +def signup(request): + """ + signup page. Create a legacy account + + url : /signup/" + + templates: authopenid/signup.html, authopenid/confirm_email.txt + """ + action_signin = reverse('user_signin') + next = clean_next(request.GET.get('next')) + form = RegistrationForm(initial={'next':next}) + form_signin = OpenidSigninForm(initial={'next':next}) + + if request.POST: + form = RegistrationForm(request.POST) + if form.is_valid(): + next = clean_next(form.cleaned_data.get('next')) + user_ = User.objects.create_user( form.cleaned_data['username'], + form.cleaned_data['email'], form.cleaned_data['password1']) + + user_.backend = "django.contrib.auth.backends.ModelBackend" + login(request, user_) + + # send email + current_domain = Site.objects.get_current().domain + subject = _("Welcome") + message_template = loader.get_template( + 'authopenid/confirm_email.txt' + ) + message_context = Context({ + 'site_url': 'http://%s/' % current_domain, + 'username': form.cleaned_data['username'], + 'password': form.cleaned_data['password1'] + }) + message = message_template.render(message_context) + send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, + [user_.email]) + + return HttpResponseRedirect(next) + + return render('authopenid/signup.html', { + 'form': form, + 'form2': form_signin, + }, context_instance=RequestContext(request)) + +@login_required +def signout(request): + """ + signout from the website. Remove openid from session and kill it. + + url : /signout/" + """ + try: + del request.session['openid'] + except KeyError: + pass + next = clean_next(request.GET.get('next')) + logout(request) + + return HttpResponseRedirect(next) + +def xrdf(request): + url_host = get_url_host(request) + return_to = [ + "%s%s" % (url_host, reverse('user_complete_signin')) + ] + return render('authopenid/yadis.xrdf', { + 'return_to': return_to + }, context_instance=RequestContext(request)) + +@login_required +def account_settings(request): + """ + index pages to changes some basic account settings : + - change password + - change email + - associate a new openid + - delete account + + url : / + + template : authopenid/settings.html + """ + msg = request.GET.get('msg', '') + is_openid = True + + try: + uassoc = UserAssociation.objects.get( + user__username__exact=request.user.username + ) + except: + is_openid = False + + + return render('authopenid/settings.html', { + 'msg': msg, + 'is_openid': is_openid + }, context_instance=RequestContext(request)) + +@login_required +def changepw(request): + """ + change password view. + + url : /changepw/ + template: authopenid/changepw.html + """ + + user_ = request.user + + if request.POST: + form = ChangepwForm(request.POST, user=user_) + if form.is_valid(): + user_.set_password(form.cleaned_data['password1']) + user_.save() + msg = _("Password changed.") + redirect = "%s?msg=%s" % ( + reverse('user_account_settings'), + urlquote_plus(msg)) + return HttpResponseRedirect(redirect) + else: + form = ChangepwForm(user=user_) + + return render('authopenid/changepw.html', {'form': form }, + context_instance=RequestContext(request)) + +@login_required +def changeemail(request): + """ + changeemail view. It require password or openid to allow change. + + url: /changeemail/ + + template : authopenid/changeemail.html + """ + msg = request.GET.get('msg', '') + extension_args = {} + user_ = request.user + + redirect_to = get_url_host(request) + reverse('user_changeemail') + + if request.POST: + form = ChangeemailForm(request.POST, user=user_) + if form.is_valid(): + if not form.test_openid: + user_.email = form.cleaned_data['email'] + user_.save() + msg = _("Email changed.") + redirect = "%s?msg=%s" % (reverse('user_account_settings'), + urlquote_plus(msg)) + return HttpResponseRedirect(redirect) + else: + request.session['new_email'] = form.cleaned_data['email'] + return ask_openid(request, form.cleaned_data['password'], + redirect_to, on_failure=emailopenid_failure) + elif not request.POST and 'openid.mode' in request.GET: + return complete(request, emailopenid_success, + emailopenid_failure, redirect_to) + else: + form = ChangeemailForm(initial={'email': user_.email}, + user=user_) + + return render('authopenid/changeemail.html', { + 'form': form, + 'msg': msg + }, context_instance=RequestContext(request)) + + +def emailopenid_success(request, identity_url, openid_response): + openid_ = from_openid_response(openid_response) + + user_ = request.user + try: + uassoc = UserAssociation.objects.get( + openid_url__exact=identity_url + ) + except: + return emailopenid_failure(request, + _("No OpenID %s found associated in our database" % identity_url)) + + if uassoc.user.username != request.user.username: + return emailopenid_failure(request, + _("The OpenID %s isn't associated to current user logged in" % + identity_url)) + + new_email = request.session.get('new_email', '') + if new_email: + user_.email = new_email + user_.save() + del request.session['new_email'] + msg = _("Email Changed.") + + redirect = "%s?msg=%s" % (reverse('user_account_settings'), + urlquote_plus(msg)) + return HttpResponseRedirect(redirect) + + +def emailopenid_failure(request, message): + redirect_to = "%s?msg=%s" % ( + reverse('user_changeemail'), urlquote_plus(message)) + return HttpResponseRedirect(redirect_to) + +@login_required +def changeopenid(request): + """ + change openid view. Allow user to change openid + associated to its username. + + url : /changeopenid/ + + template: authopenid/changeopenid.html + """ + + extension_args = {} + openid_url = '' + has_openid = True + msg = request.GET.get('msg', '') + + user_ = request.user + + try: + uopenid = UserAssociation.objects.get(user=user_) + openid_url = uopenid.openid_url + except: + has_openid = False + + redirect_to = get_url_host(request) + reverse('user_changeopenid') + if request.POST and has_openid: + form = ChangeopenidForm(request.POST, user=user_) + if form.is_valid(): + return ask_openid(request, form.cleaned_data['openid_url'], + redirect_to, on_failure=changeopenid_failure) + elif not request.POST and has_openid: + if 'openid.mode' in request.GET: + return complete(request, changeopenid_success, + changeopenid_failure, redirect_to) + + form = ChangeopenidForm(initial={'openid_url': openid_url }, user=user_) + return render('authopenid/changeopenid.html', { + 'form': form, + 'has_openid': has_openid, + 'msg': msg + }, context_instance=RequestContext(request)) + +def changeopenid_success(request, identity_url, openid_response): + openid_ = from_openid_response(openid_response) + is_exist = True + try: + uassoc = UserAssociation.objects.get(openid_url__exact=identity_url) + except: + is_exist = False + + if not is_exist: + try: + uassoc = UserAssociation.objects.get( + user__username__exact=request.user.username + ) + uassoc.openid_url = identity_url + uassoc.save() + except: + uassoc = UserAssociation(user=request.user, + openid_url=identity_url) + uassoc.save() + elif uassoc.user.username != request.user.username: + return changeopenid_failure(request, + _('This OpenID is already associated with another account.')) + + request.session['openids'] = [] + request.session['openids'].append(openid_) + + msg = _("OpenID %s is now associated with your account." % identity_url) + redirect = "%s?msg=%s" % ( + reverse('user_account_settings'), + urlquote_plus(msg)) + return HttpResponseRedirect(redirect) + + +def changeopenid_failure(request, message): + redirect_to = "%s?msg=%s" % ( + reverse('user_changeopenid'), + urlquote_plus(message)) + return HttpResponseRedirect(redirect_to) + +@login_required +def delete(request): + """ + delete view. Allow user to delete its account. Password/openid are required to + confirm it. He should also check the confirm checkbox. + + url : /delete + + template : authopenid/delete.html + """ + + extension_args = {} + + user_ = request.user + + redirect_to = get_url_host(request) + reverse('user_delete') + if request.POST: + form = DeleteForm(request.POST, user=user_) + if form.is_valid(): + if not form.test_openid: + user_.delete() + return signout(request) + else: + return ask_openid(request, form.cleaned_data['password'], + redirect_to, on_failure=deleteopenid_failure) + elif not request.POST and 'openid.mode' in request.GET: + return complete(request, deleteopenid_success, deleteopenid_failure, + redirect_to) + + form = DeleteForm(user=user_) + + msg = request.GET.get('msg','') + return render('authopenid/delete.html', { + 'form': form, + 'msg': msg, + }, context_instance=RequestContext(request)) + +def deleteopenid_success(request, identity_url, openid_response): + openid_ = from_openid_response(openid_response) + + user_ = request.user + try: + uassoc = UserAssociation.objects.get( + openid_url__exact=identity_url + ) + except: + return deleteopenid_failure(request, + _("No OpenID %s found associated in our database" % identity_url)) + + if uassoc.user.username == user_.username: + user_.delete() + return signout(request) + else: + return deleteopenid_failure(request, + _("The OpenID %s isn't associated to current user logged in" % + identity_url)) + + msg = _("Account deleted.") + redirect = "/?msg=%s" % (urlquote_plus(msg)) + return HttpResponseRedirect(redirect) + + +def deleteopenid_failure(request, message): + redirect_to = "%s?msg=%s" % (reverse('user_delete'), urlquote_plus(message)) + return HttpResponseRedirect(redirect_to) + + +def sendpw(request): + """ + send a new password to the user. It return a mail with + a new pasword and a confirm link in. To activate the + new password, the user should click on confirm link. + + url : /sendpw/ + + templates : authopenid/sendpw_email.txt, authopenid/sendpw.html + """ + + msg = request.GET.get('msg','') + if request.POST: + form = EmailPasswordForm(request.POST) + if form.is_valid(): + new_pw = User.objects.make_random_password() + confirm_key = UserPasswordQueue.objects.get_new_confirm_key() + try: + uqueue = UserPasswordQueue.objects.get( + user=form.user_cache + ) + except: + uqueue = UserPasswordQueue( + user=form.user_cache + ) + uqueue.new_password = new_pw + uqueue.confirm_key = confirm_key + uqueue.save() + # send email + current_domain = Site.objects.get_current().domain + subject = _("Request for new password") + message_template = loader.get_template( + 'authopenid/sendpw_email.txt') + message_context = Context({ + 'site_url': 'http://%s' % current_domain, + 'confirm_key': confirm_key, + 'username': form.user_cache.username, + 'password': new_pw, + 'url_confirm': reverse('user_confirmchangepw'), + }) + message = message_template.render(message_context) + send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, + [form.user_cache.email]) + msg = _("A new password has been sent to your email address.") + else: + form = EmailPasswordForm() + + return render('authopenid/sendpw.html', { + 'form': form, + 'msg': msg + }, context_instance=RequestContext(request)) + + +def confirmchangepw(request): + """ + view to set new password when the user click on confirm link + in its mail. Basically it check if the confirm key exist, then + replace old password with new password and remove confirm + ley from the queue. Then it redirect the user to signin + page. + + url : /sendpw/confirm/?key + + """ + confirm_key = request.GET.get('key', '') + if not confirm_key: + return HttpResponseRedirect('/') + + try: + uqueue = UserPasswordQueue.objects.get( + confirm_key__exact=confirm_key + ) + except: + msg = _("Could not change password. Confirmation key '%s'\ + is not registered." % confirm_key) + redirect = "%s?msg=%s" % ( + reverse('user_sendpw'), urlquote_plus(msg)) + return HttpResponseRedirect(redirect) + + try: + user_ = User.objects.get(id=uqueue.user.id) + except: + msg = _("Can not change password. User don't exist anymore \ + in our database.") + redirect = "%s?msg=%s" % (reverse('user_sendpw'), + urlquote_plus(msg)) + return HttpResponseRedirect(redirect) + + user_.set_password(uqueue.new_password) + user_.save() + uqueue.delete() + msg = _("Password changed for %s. You may now sign in." % + user_.username) + redirect = "%s?msg=%s" % (reverse('user_signin'), + urlquote_plus(msg)) + + return HttpResponseRedirect(redirect) diff --git a/forum/__init__.py b/forum/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/forum/admin.py b/forum/admin.py new file mode 100644 index 0000000000..438a99e766 --- /dev/null +++ b/forum/admin.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +from django.contrib import admin +from models import * + + +class QuestionAdmin(admin.ModelAdmin): + """Question admin class""" + +class TagAdmin(admin.ModelAdmin): + """Tag admin class""" + +class Answerdmin(admin.ModelAdmin): + """Answer admin class""" + +class CommentAdmin(admin.ModelAdmin): + """ admin class""" + +class VoteAdmin(admin.ModelAdmin): + """ admin class""" + +class FlaggedItemAdmin(admin.ModelAdmin): + """ admin class""" + +class FavoriteQuestionAdmin(admin.ModelAdmin): + """ admin class""" + +class QuestionRevisionAdmin(admin.ModelAdmin): + """ admin class""" + +class AnswerRevisionAdmin(admin.ModelAdmin): + """ admin class""" + +class AwardAdmin(admin.ModelAdmin): + """ admin class""" + +class BadgeAdmin(admin.ModelAdmin): + """ admin class""" + +class ReputeAdmin(admin.ModelAdmin): + """ admin class""" + +class ActivityAdmin(admin.ModelAdmin): + """ admin class""" + +class BookAdmin(admin.ModelAdmin): + """ admin class""" + +class BookAuthorInfoAdmin(admin.ModelAdmin): + """ admin class""" + +class BookAuthorRssAdmin(admin.ModelAdmin): + """ admin class""" + + +admin.site.register(Question, QuestionAdmin) +admin.site.register(Tag, TagAdmin) +admin.site.register(Answer, Answerdmin) +admin.site.register(Comment, CommentAdmin) +admin.site.register(Vote, VoteAdmin) +admin.site.register(FlaggedItem, FlaggedItemAdmin) +admin.site.register(FavoriteQuestion, FavoriteQuestionAdmin) +admin.site.register(QuestionRevision, QuestionRevisionAdmin) +admin.site.register(AnswerRevision, AnswerRevisionAdmin) +admin.site.register(Badge, BadgeAdmin) +admin.site.register(Award, AwardAdmin) +admin.site.register(Repute, ReputeAdmin) +admin.site.register(Activity, ActivityAdmin) +admin.site.register(Book, BookAdmin) +admin.site.register(BookAuthorInfo, BookAuthorInfoAdmin) +admin.site.register(BookAuthorRss, BookAuthorRssAdmin) \ No newline at end of file diff --git a/forum/auth.py b/forum/auth.py new file mode 100644 index 0000000000..0608031a36 --- /dev/null +++ b/forum/auth.py @@ -0,0 +1,443 @@ +锘""" +Authorisation related functions. + +The actions a User is authorised to perform are dependent on their reputation +and superuser status. +""" +import datetime +from django.contrib.contenttypes.models import ContentType +from django.db import transaction +from models import Repute +from models import Question +from models import Answer +from const import TYPE_REPUTATION +question_type = ContentType.objects.get_for_model(Question) +answer_type = ContentType.objects.get_for_model(Answer) + +VOTE_UP = 15 +FLAG_OFFENSIVE = 15 +POST_IMAGES = 15 +LEAVE_COMMENTS = 50 +UPLOAD_FILES = 60 +VOTE_DOWN = 100 +CLOSE_OWN_QUESTIONS = 250 +RETAG_OTHER_QUESTIONS = 500 +REOPEN_OWN_QUESTIONS = 500 +EDIT_COMMUNITY_WIKI_POSTS = 750 +EDIT_OTHER_POSTS = 2000 +DELETE_COMMENTS = 2000 +VIEW_OFFENSIVE_FLAGS = 2000 +DISABLE_URL_NOFOLLOW = 2000 +CLOSE_OTHER_QUESTIONS = 3000 +LOCK_POSTS = 4000 + +VOTE_RULES = { + 'scope_votes_per_user_per_day' : 30, # how many votes of one user has everyday + 'scope_flags_per_user_per_day' : 5, # how many times user can flag posts everyday + 'scope_warn_votes_left' : 10, # start when to warn user how many votes left + 'scope_deny_unvote_days' : 1, # if 1 days passed, user can't cancel votes. + 'scope_flags_invisible_main_page' : 3, # post doesn't show on main page if has more than 3 offensive flags + 'scope_flags_delete_post' : 5, # post will be deleted if it has more than 5 offensive flags +} + +REPUTATION_RULES = { + 'initial_score' : 1, + 'scope_per_day_by_upvotes' : 200, + 'gain_by_upvoted' : 10, + 'gain_by_answer_accepted' : 15, + 'gain_by_accepting_answer' : 2, + 'gain_by_downvote_canceled' : 2, + 'gain_by_canceling_downvote' : 1, + 'lose_by_canceling_accepted_answer' : -2, + 'lose_by_accepted_answer_cancled' : -15, + 'lose_by_downvoted' : -2, + 'lose_by_flagged' : -2, + 'lose_by_downvoting' : -1, + 'lose_by_flagged_lastrevision_3_times': -30, + 'lose_by_flagged_lastrevision_5_times': -100, + 'lose_by_upvote_canceled' : -10, +} + +def can_vote_up(user): + """Determines if a User can vote Questions and Answers up.""" + return user.is_authenticated() and ( + user.reputation >= VOTE_UP or + user.is_superuser) + +def can_flag_offensive(user): + """Determines if a User can flag Questions and Answers as offensive.""" + return user.is_authenticated() and ( + user.reputation >= FLAG_OFFENSIVE or + user.is_superuser) + +def can_add_comments(user): + """Determines if a User can add comments to Questions and Answers.""" + return user.is_authenticated() and ( + user.reputation >= LEAVE_COMMENTS or + user.is_superuser) + +def can_vote_down(user): + """Determines if a User can vote Questions and Answers down.""" + return user.is_authenticated() and ( + user.reputation >= VOTE_DOWN or + user.is_superuser) + +def can_retag_questions(user): + """Determines if a User can retag Questions.""" + return user.is_authenticated() and ( + RETAG_OTHER_QUESTIONS <= user.reputation < EDIT_OTHER_POSTS or + user.is_superuser) + +def can_edit_post(user, post): + """Determines if a User can edit the given Question or Answer.""" + return user.is_authenticated() and ( + user.id == post.author_id or + (post.wiki and user.reputation >= EDIT_COMMUNITY_WIKI_POSTS) or + user.reputation >= EDIT_OTHER_POSTS or + user.is_superuser) + +def can_delete_comment(user, comment): + """Determines if a User can delete the given Comment.""" + return user.is_authenticated() and ( + user.id == comment.user_id or + user.reputation >= DELETE_COMMENTS or + user.is_superuser) + +def can_view_offensive_flags(user): + """Determines if a User can view offensive flag counts.""" + return user.is_authenticated() and ( + user.reputation >= VIEW_OFFENSIVE_FLAGS or + user.is_superuser) + +def can_close_question(user, question): + """Determines if a User can close the given Question.""" + return user.is_authenticated() and ( + (user.id == question.author_id and + user.reputation >= CLOSE_OWN_QUESTIONS) or + user.reputation >= CLOSE_OTHER_QUESTIONS or + user.is_superuser) + +def can_lock_posts(user): + """Determines if a User can lock Questions or Answers.""" + return user.is_authenticated() and ( + user.reputation >= LOCK_POSTS or + user.is_superuser) + +def can_follow_url(user): + """Determines if the URL link can be followed by Google search engine.""" + return user.reputation >= DISABLE_URL_NOFOLLOW + +def can_accept_answer(user, question, answer): + return (user.is_authenticated() and + question.author != answer.author and + question.author == user) or user.is_superuser + +# now only support to reopen own question except superuser +def can_reopen_question(user, question): + return (user.is_authenticated() and + user.id == question.author_id and + user.reputation >= REOPEN_OWN_QUESTIONS) or user.is_superuser + +def can_delete_post(user, post): + return (user.is_authenticated() and + user.id == post.author_id) or user.is_superuser + +def can_view_deleted_post(user, post): + return user.is_superuser + +# user preferences view permissions +def is_user_self(request_user, target_user): + return (request_user.is_authenticated() and request_user == target_user) + +def can_view_user_votes(request_user, target_user): + return (request_user.is_authenticated() and request_user == target_user) + +def can_view_user_preferences(request_user, target_user): + return (request_user.is_authenticated() and request_user == target_user) + +def can_view_user_edit(request_user, target_user): + return (request_user.is_authenticated() and request_user == target_user) + +def can_upload_files(request_user): + return (request_user.is_authenticated() and request_user.reputation >= UPLOAD_FILES) or \ + request_user.is_superuser + +########################################### +## actions and reputation changes event +########################################### +def calculate_reputation(origin, offset): + result = int(origin) + int(offset) + return result if result > 0 else 1 + +@transaction.commit_on_success +def onFlaggedItem(item, post, user): + + item.save() + post.offensive_flag_count = post.offensive_flag_count + 1 + post.save() + + post.author.reputation = calculate_reputation(post.author.reputation, + int(REPUTATION_RULES['lose_by_flagged'])) + post.author.save() + + question = post + if ContentType.objects.get_for_model(post) == answer_type: + question = post.question + + reputation = Repute(user=post.author, + negative=int(REPUTATION_RULES['lose_by_flagged']), + question=question, reputed_at=datetime.datetime.now(), + reputation_type=-4, + reputation=post.author.reputation) + reputation.save() + + #todo: These should be updated to work on same revisions. + if post.offensive_flag_count == VOTE_RULES['scope_flags_invisible_main_page'] : + post.author.reputation = calculate_reputation(post.author.reputation, + int(REPUTATION_RULES['lose_by_flagged_lastrevision_3_times'])) + post.author.save() + + reputation = Repute(user=post.author, + negative=int(REPUTATION_RULES['lose_by_flagged_lastrevision_3_times']), + question=question, + reputed_at=datetime.datetime.now(), + reputation_type=-6, + reputation=post.author.reputation) + reputation.save() + + elif post.offensive_flag_count == VOTE_RULES['scope_flags_delete_post']: + post.author.reputation = calculate_reputation(post.author.reputation, + int(REPUTATION_RULES['lose_by_flagged_lastrevision_5_times'])) + post.author.save() + + reputation = Repute(user=post.author, + negative=int(REPUTATION_RULES['lose_by_flagged_lastrevision_5_times']), + question=question, + reputed_at=datetime.datetime.now(), + reputation_type=-7, + reputation=post.author.reputation) + reputation.save() + + post.deleted = True + #post.deleted_at = datetime.datetime.now() + #post.deleted_by = Admin + post.save() + + +@transaction.commit_on_success +def onAnswerAccept(answer, user): + answer.accepted = True + answer.accepted_at = datetime.datetime.now() + answer.question.answer_accepted = True + answer.save() + answer.question.save() + + answer.author.reputation = calculate_reputation(answer.author.reputation, + int(REPUTATION_RULES['gain_by_answer_accepted'])) + answer.author.save() + reputation = Repute(user=answer.author, + positive=int(REPUTATION_RULES['gain_by_answer_accepted']), + question=answer.question, + reputed_at=datetime.datetime.now(), + reputation_type=2, + reputation=answer.author.reputation) + reputation.save() + + user.reputation = calculate_reputation(user.reputation, + int(REPUTATION_RULES['gain_by_accepting_answer'])) + user.save() + reputation = Repute(user=user, + positive=int(REPUTATION_RULES['gain_by_accepting_answer']), + question=answer.question, + reputed_at=datetime.datetime.now(), + reputation_type=3, + reputation=user.reputation) + reputation.save() + +@transaction.commit_on_success +def onAnswerAcceptCanceled(answer, user): + answer.accepted = False + answer.accepted_at = None + answer.question.answer_accepted = False + answer.save() + answer.question.save() + + answer.author.reputation = calculate_reputation(answer.author.reputation, + int(REPUTATION_RULES['lose_by_accepted_answer_cancled'])) + answer.author.save() + reputation = Repute(user=answer.author, + negative=int(REPUTATION_RULES['lose_by_accepted_answer_cancled']), + question=answer.question, + reputed_at=datetime.datetime.now(), + reputation_type=-2, + reputation=answer.author.reputation) + reputation.save() + + user.reputation = calculate_reputation(user.reputation, + int(REPUTATION_RULES['lose_by_canceling_accepted_answer'])) + user.save() + reputation = Repute(user=user, + negative=int(REPUTATION_RULES['lose_by_canceling_accepted_answer']), + question=answer.question, + reputed_at=datetime.datetime.now(), + reputation_type=-1, + reputation=user.reputation) + reputation.save() + +@transaction.commit_on_success +def onUpVoted(vote, post, user): + vote.save() + + post.vote_up_count = int(post.vote_up_count) + 1 + post.score = int(post.score) + 1 + post.save() + + if not post.wiki: + author = post.author + if Repute.objects.get_reputation_by_upvoted_today(author) < int(REPUTATION_RULES['scope_per_day_by_upvotes']): + author.reputation = calculate_reputation(author.reputation, + int(REPUTATION_RULES['gain_by_upvoted'])) + author.save() + + question = post + if ContentType.objects.get_for_model(post) == answer_type: + question = post.question + + reputation = Repute(user=author, + positive=int(REPUTATION_RULES['gain_by_upvoted']), + question=question, + reputed_at=datetime.datetime.now(), + reputation_type=1, + reputation=author.reputation) + reputation.save() + +@transaction.commit_on_success +def onUpVotedCanceled(vote, post, user): + vote.delete() + + post.vote_up_count = int(post.vote_up_count) - 1 + if post.vote_up_count < 0: + post.vote_up_count = 0 + post.score = int(post.score) - 1 + post.save() + + if not post.wiki: + author = post.author + author.reputation = calculate_reputation(author.reputation, + int(REPUTATION_RULES['lose_by_upvote_canceled'])) + author.save() + + question = post + if ContentType.objects.get_for_model(post) == answer_type: + question = post.question + + reputation = Repute(user=author, + negative=int(REPUTATION_RULES['lose_by_upvote_canceled']), + question=question, + reputed_at=datetime.datetime.now(), + reputation_type=-8, + reputation=author.reputation) + reputation.save() + +@transaction.commit_on_success +def onDownVoted(vote, post, user): + vote.save() + + post.vote_down_count = int(post.vote_down_count) + 1 + post.score = int(post.score) - 1 + post.save() + + if not post.wiki: + author = post.author + author.reputation = calculate_reputation(author.reputation, + int(REPUTATION_RULES['lose_by_downvoted'])) + author.save() + + question = post + if ContentType.objects.get_for_model(post) == answer_type: + question = post.question + + reputation = Repute(user=author, + negative=int(REPUTATION_RULES['lose_by_downvoted']), + question=question, + reputed_at=datetime.datetime.now(), + reputation_type=-3, + reputation=author.reputation) + reputation.save() + + user.reputation = calculate_reputation(user.reputation, + int(REPUTATION_RULES['lose_by_downvoting'])) + user.save() + + reputation = Repute(user=user, + negative=int(REPUTATION_RULES['lose_by_downvoting']), + question=question, + reputed_at=datetime.datetime.now(), + reputation_type=-5, + reputation=user.reputation) + reputation.save() + +@transaction.commit_on_success +def onDownVotedCanceled(vote, post, user): + vote.delete() + + post.vote_down_count = int(post.vote_down_count) - 1 + if post.vote_down_count < 0: + post.vote_down_count = 0 + post.score = post.score + 1 + post.save() + + if not post.wiki: + author = post.author + author.reputation = calculate_reputation(author.reputation, + int(REPUTATION_RULES['gain_by_downvote_canceled'])) + author.save() + + question = post + if ContentType.objects.get_for_model(post) == answer_type: + question = post.question + + reputation = Repute(user=author, + positive=int(REPUTATION_RULES['gain_by_downvote_canceled']), + question=question, + reputed_at=datetime.datetime.now(), + reputation_type=4, + reputation=author.reputation) + reputation.save() + + user.reputation = calculate_reputation(user.reputation, + int(REPUTATION_RULES['gain_by_canceling_downvote'])) + user.save() + + reputation = Repute(user=user, + positive=int(REPUTATION_RULES['gain_by_canceling_downvote']), + question=question, + reputed_at=datetime.datetime.now(), + reputation_type=5, + reputation=user.reputation) + reputation.save() + +def onDeleteCanceled(post, user): + post.deleted = False + post.deleted_by = None + post.deleted_at = None + post.save() + for tag in list(post.tags.all()): + if tag.used_count == 1 and tag.deleted: + tag.deleted = False + tag.deleted_by = None + tag.deleted_at = None + tag.save() + +def onDeleted(post, user): + post.deleted = True + post.deleted_by = user + post.deleted_at = datetime.datetime.now() + post.save() + + for tag in list(post.tags.all()): + if tag.used_count == 1: + tag.deleted = True + tag.deleted_by = user + tag.deleted_at = datetime.datetime.now() + tag.save() diff --git a/forum/const.py b/forum/const.py new file mode 100644 index 0000000000..d285de7d8b --- /dev/null +++ b/forum/const.py @@ -0,0 +1,89 @@ +锘# encoding:utf-8 +""" +All constants could be used in other modules +For reasons that models, views can't have unicode text in this project, all unicode text go here. +""" +CLOSE_REASONS = ( + (1, u'瀹屽叏閲嶅鐨勯棶棰'), + (2, u'涓嶆槸缂栫▼鎶鏈棶棰'), + (3, u'澶富瑙傛с佸紩璧蜂簤鍚电殑闂'), + (4, u'涓嶆槸涓涓彲浠ュ洖绛旂殑鈥滈棶棰樷'), + (5, u'闂宸茬粡瑙e喅锛屽凡寰楀埌姝g‘绛旀'), + (6, u'宸茬粡杩囨椂銆佷笉鍙噸鐜扮殑闂'), + (7, u'澶眬閮ㄣ佹湰鍦板寲鐨勯棶棰'), + (8, u'鎭舵剰瑷璁'), + (9, u'鍨冨溇骞垮憡'), +) + +TYPE_REPUTATION = ( + (1, 'gain_by_upvoted'), + (2, 'gain_by_answer_accepted'), + (3, 'gain_by_accepting_answer'), + (4, 'gain_by_downvote_canceled'), + (5, 'gain_by_canceling_downvote'), + (-1, 'lose_by_canceling_accepted_answer'), + (-2, 'lose_by_accepted_answer_cancled'), + (-3, 'lose_by_downvoted'), + (-4, 'lose_by_flagged'), + (-5, 'lose_by_downvoting'), + (-6, 'lose_by_flagged_lastrevision_3_times'), + (-7, 'lose_by_flagged_lastrevision_5_times'), + (-8, 'lose_by_upvote_canceled'), +) + +TYPE_ACTIVITY_ASK_QUESTION=1 +TYPE_ACTIVITY_ANSWER=2 +TYPE_ACTIVITY_COMMENT_QUESTION=3 +TYPE_ACTIVITY_COMMENT_ANSWER=4 +TYPE_ACTIVITY_UPDATE_QUESTION=5 +TYPE_ACTIVITY_UPDATE_ANSWER=6 +TYPE_ACTIVITY_PRIZE=7 +TYPE_ACTIVITY_MARK_ANSWER=8 +TYPE_ACTIVITY_VOTE_UP=9 +TYPE_ACTIVITY_VOTE_DOWN=10 +TYPE_ACTIVITY_CANCEL_VOTE=11 +TYPE_ACTIVITY_DELETE_QUESTION=12 +TYPE_ACTIVITY_DELETE_ANSWER=13 +TYPE_ACTIVITY_MARK_OFFENSIVE=14 +TYPE_ACTIVITY_UPDATE_TAGS=15 +TYPE_ACTIVITY_FAVORITE=16 +TYPE_ACTIVITY_USER_FULL_UPDATED = 17 +#TYPE_ACTIVITY_EDIT_QUESTION=17 +#TYPE_ACTIVITY_EDIT_ANSWER=18 + +TYPE_ACTIVITY = ( + (TYPE_ACTIVITY_ASK_QUESTION, u'鎻愰棶'), + (TYPE_ACTIVITY_ANSWER, u'鍥炵瓟'), + (TYPE_ACTIVITY_COMMENT_QUESTION, u'璇勮闂'), + (TYPE_ACTIVITY_COMMENT_ANSWER, u'璇勮鍥炵瓟'), + (TYPE_ACTIVITY_UPDATE_QUESTION, u'淇敼闂'), + (TYPE_ACTIVITY_UPDATE_ANSWER, u'淇敼鍥炵瓟'), + (TYPE_ACTIVITY_PRIZE, u'鑾峰'), + (TYPE_ACTIVITY_MARK_ANSWER, u'鏍囪鏈浣崇瓟妗'), + (TYPE_ACTIVITY_VOTE_UP, u'鎶曡禐鎴愮エ'), + (TYPE_ACTIVITY_VOTE_DOWN, u'鎶曞弽瀵圭エ'), + (TYPE_ACTIVITY_CANCEL_VOTE, u'鎾ら攢鎶曠エ'), + (TYPE_ACTIVITY_DELETE_QUESTION, u'鍒犻櫎闂'), + (TYPE_ACTIVITY_DELETE_ANSWER, u'鍒犻櫎鍥炵瓟'), + (TYPE_ACTIVITY_MARK_OFFENSIVE, u'鏍囪鍨冨溇甯'), + (TYPE_ACTIVITY_UPDATE_TAGS, u'鏇存柊鏍囩'), + (TYPE_ACTIVITY_FAVORITE, u'鏀惰棌'), + (TYPE_ACTIVITY_USER_FULL_UPDATED, u'瀹屾垚涓汉鎵鏈夎祫鏂'), + #(TYPE_ACTIVITY_EDIT_QUESTION, u'缂栬緫闂'), + #(TYPE_ACTIVITY_EDIT_ANSWER, u'缂栬緫绛旀'), +) + +TYPE_RESPONSE = { + 'QUESTION_ANSWERED' : u'鍥炵瓟闂', + 'QUESTION_COMMENTED': u'闂璇勮', + 'ANSWER_COMMENTED' : u'鍥炵瓟璇勮', + 'ANSWER_ACCEPTED' : u'鏈浣崇瓟妗', +} + +CONST = { + 'closed' : u' [宸插叧闂璢', + 'deleted' : u' [宸插垹闄', + 'default_version' : u'鍒濆鐗堟湰', + 'retagged' : u'鏇存柊浜嗘爣绛', + +} diff --git a/forum/diff.py b/forum/diff.py new file mode 100644 index 0000000000..d741d78899 --- /dev/null +++ b/forum/diff.py @@ -0,0 +1,66 @@ +#!/usr/bin/python2.2 +"""HTML Diff: http://www.aaronsw.com/2002/diff +Rough code, badly documented. Send me comments and patches.""" + +__author__ = 'Aaron Swartz ' +__copyright__ = '(C) 2003 Aaron Swartz. GNU GPL 2.' +__version__ = '0.22' + +import difflib, string + +def isTag(x): return x[0] == "<" and x[-1] == ">" + +def textDiff(a, b): + """Takes in strings a and b and returns a human-readable HTML diff.""" + + out = [] + a, b = html2list(a), html2list(b) + s = difflib.SequenceMatcher(None, a, b) + for e in s.get_opcodes(): + if e[0] == "replace": + # @@ need to do something more complicated here + # call textDiff but not for html, but for some html... ugh + # gonna cop-out for now + out.append(''+''.join(a[e[1]:e[2]]) + ''+''.join(b[e[3]:e[4]])+"") + elif e[0] == "delete": + out.append(''+ ''.join(a[e[1]:e[2]]) + "") + elif e[0] == "insert": + out.append(''+''.join(b[e[3]:e[4]]) + "") + elif e[0] == "equal": + out.append(''.join(b[e[3]:e[4]])) + else: + raise "Um, something's broken. I didn't expect a '" + `e[0]` + "'." + return ''.join(out) + +def html2list(x, b=0): + mode = 'char' + cur = '' + out = [] + for c in x: + if mode == 'tag': + if c == '>': + if b: cur += ']' + else: cur += c + out.append(cur); cur = ''; mode = 'char' + else: cur += c + elif mode == 'char': + if c == '<': + out.append(cur) + if b: cur = '[' + else: cur = c + mode = 'tag' + elif c in string.whitespace: out.append(cur+c); cur = '' + else: cur += c + out.append(cur) + return filter(lambda x: x is not '', out) + +if __name__ == '__main__': + import sys + try: + a, b = sys.argv[1:3] + except ValueError: + print "htmldiff: highlight the differences between two html files" + print "usage: " + sys.argv[0] + " a b" + sys.exit(1) + print textDiff(open(a).read(), open(b).read()) + diff --git a/forum/feed.py b/forum/feed.py new file mode 100644 index 0000000000..d75f3be64c --- /dev/null +++ b/forum/feed.py @@ -0,0 +1,41 @@ +锘#!/usr/bin/env python +#encoding:utf-8 +#------------------------------------------------------------------------------- +# Name: Syndication feed class for subsribtion +# Purpose: +# +# Author: Mike +# +# Created: 29/01/2009 +# Copyright: (c) CNPROG.COM 2009 +# Licence: GPL V2 +#------------------------------------------------------------------------------- +from django.contrib.syndication.feeds import Feed, FeedDoesNotExist +from models import Question +class RssLastestQuestionsFeed(Feed): + title = u"CNProg绋嬪簭鍛橀棶绛旂ぞ鍖-鏈鏂伴棶棰" + link = u"http://www.cnprog.com/questions/" + description = u"涓浗绋嬪簭鍛樼殑缂栫▼鎶鏈棶绛旂ぞ鍖恒傛垜浠仛涓撲笟鐨勩佸彲鍗忎綔缂栬緫鐨勬妧鏈棶绛旂ぞ鍖恒" + #ttl = 10 + copyright = u'Copyright(c)2009.CNPROG.COM' + + def item_link(self, item): + return '/questions/%s/' % item.id + + def item_author_name(self, item): + return item.author.username + + def item_author_link(self, item): + return item.author.get_profile_url() + + def item_pubdate(self, item): + return item.added_at + + def items(self, item): + return Question.objects.filter(deleted=False).order_by('-added_at')[:30] + +def main(): + pass + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/forum/forms.py b/forum/forms.py new file mode 100644 index 0000000000..70a44f286d --- /dev/null +++ b/forum/forms.py @@ -0,0 +1,194 @@ +锘縤mport re +from datetime import date +from django import forms +from models import * +from const import * + +class TitleField(forms.CharField): + def __init__(self, *args, **kwargs): + super(TitleField, self).__init__(*args, **kwargs) + self.required = True + self.widget = forms.TextInput(attrs={'size' : 70, 'autocomplete' : 'off'}) + self.max_length = 255 + self.label = u'鏍囬' + self.help_text = u'璇疯緭鍏ュ闂鍏锋湁鎻忚堪鎬ц川鐨勬爣棰 - 鈥滃府蹇欙紒绱фユ眰鍔╋紒鈥濅笉鏄缓璁殑鎻愰棶鏂瑰紡銆' + self.initial = '' + + def clean(self, value): + if len(value) < 10: + raise forms.ValidationError(u"鏍囬鐨勯暱搴﹀繀椤诲ぇ浜10") + + return value + +class EditorField(forms.CharField): + def __init__(self, *args, **kwargs): + super(EditorField, self).__init__(*args, **kwargs) + self.required = True + self.widget = forms.Textarea(attrs={'id':'editor'}) + self.label = u'鍐呭' + self.help_text = u'' + self.initial = '' + + def clean(self, value): + if len(value) < 10: + raise forms.ValidationError(u"鍐呭鑷冲皯瑕10涓瓧绗") + + return value + +class TagNamesField(forms.CharField): + def __init__(self, *args, **kwargs): + super(TagNamesField, self).__init__(*args, **kwargs) + self.required = True + self.widget = forms.TextInput(attrs={'size' : 50, 'autocomplete' : 'off'}) + self.max_length = 255 + self.label = u'鏍囩' + self.help_text = u'澶氫釜鏍囩璇风敤绌烘牸闂撮殧-鏈澶5涓爣绛俱傦紙浼樺厛浣跨敤鑷姩鍖归厤鐨勮嫳鏂囨爣绛俱傦級' + self.initial = '' + + def clean(self, value): + value = super(TagNamesField, self).clean(value) + data = value.strip() + if len(data) < 1: + raise forms.ValidationError(u'鏍囩涓嶈兘涓虹┖') + list = data.split(' ') + list_temp = [] + if len(list) > 5: + raise forms.ValidationError(u'鏈澶氬彧鑳芥湁5涓爣绛') + for tag in list: + if len(tag) > 20: + raise forms.ValidationError(u'姣忎釜鏍囩鐨勯暱搴︿笉瓒呰繃20') + + #TODO: regex match not allowed characters here + + if tag.find('/') > -1 or tag.find('\\') > -1 or tag.find('<') > -1 or tag.find('>') > -1 or tag.find('&') > -1 or tag.find('\'') > -1 or tag.find('"') > -1: + #if not tagname_re.match(tag): + raise forms.ValidationError(u'鏍囩璇蜂娇鐢ㄨ嫳鏂囧瓧姣嶏紝涓枃鎴栬呮暟瀛楀瓧绗︿覆锛. - _ # 涔熷彲浠ワ級') + # only keep one same tag + if tag not in list_temp and len(tag.strip()) > 0: + list_temp.append(tag) + return u' '.join(list_temp) + +class WikiField(forms.BooleanField): + def __init__(self, *args, **kwargs): + super(WikiField, self).__init__(*args, **kwargs) + self.required = False + self.label = u'绀惧尯wiki妯″紡' + self.help_text = u'閫夋嫨绀惧尯wiki妯″紡锛岄棶绛斾笉璁$畻绉垎锛岀鍚嶄篃涓嶆樉绀轰綔鑰呬俊鎭' + + +class SummaryField(forms.CharField): + def __init__(self, *args, **kwargs): + super(SummaryField, self).__init__(*args, **kwargs) + self.required = False + self.widget = forms.TextInput(attrs={'size' : 50, 'autocomplete' : 'off'}) + self.max_length = 300 + self.label = u'鏇存柊姒傝锛' + self.help_text = u'杈撳叆鏈淇敼鐨勭畝鍗曟杩帮紙濡傦細淇敼浜嗗埆瀛楋紝淇浜嗚娉曪紝鏀硅繘浜嗘牱寮忕瓑銆傞潪蹇呭~椤广傦級' + +class AskForm(forms.Form): + title = TitleField() + text = EditorField() + tags = TagNamesField() + wiki = WikiField() + + openid = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 40, 'class':'openid-input'})) + user = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + email = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + + + +class AnswerForm(forms.Form): + text = EditorField() + wiki = WikiField() + openid = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 40, 'class':'openid-input'})) + user = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + email = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + def __init__(self, question, *args, **kwargs): + super(AnswerForm, self).__init__(*args, **kwargs) + if question.wiki: + self.fields['wiki'].initial = True + +class CloseForm(forms.Form): + reason = forms.ChoiceField(choices=CLOSE_REASONS) + +class RetagQuestionForm(forms.Form): + tags = TagNamesField() + # initialize the default values + def __init__(self, question, *args, **kwargs): + super(RetagQuestionForm, self).__init__(*args, **kwargs) + self.fields['tags'].initial = question.tagnames + +class RevisionForm(forms.Form): + """ + Lists revisions of a Question or Answer + """ + revision = forms.ChoiceField(widget=forms.Select(attrs={'style' : 'width:520px'})) + + def __init__(self, post, latest_revision, *args, **kwargs): + super(RevisionForm, self).__init__(*args, **kwargs) + revisions = post.revisions.all().values_list( + 'revision', 'author__username', 'revised_at', 'summary') + date_format = '%c' + self.fields['revision'].choices = [ + (r[0], u'%s - %s (%s) %s' % (r[0], r[1], r[2].strftime(date_format), r[3])) + for r in revisions] + self.fields['revision'].initial = latest_revision.revision + +class EditQuestionForm(forms.Form): + title = TitleField() + text = EditorField() + tags = TagNamesField() + summary = SummaryField() + + def __init__(self, question, revision, *args, **kwargs): + super(EditQuestionForm, self).__init__(*args, **kwargs) + self.fields['title'].initial = revision.title + self.fields['text'].initial = revision.text + self.fields['tags'].initial = revision.tagnames + # Once wiki mode is enabled, it can't be disabled + if not question.wiki: + self.fields['wiki'] = WikiField() + +class EditAnswerForm(forms.Form): + text = EditorField() + summary = SummaryField() + + def __init__(self, answer, revision, *args, **kwargs): + super(EditAnswerForm, self).__init__(*args, **kwargs) + self.fields['text'].initial = revision.text + +class EditUserForm(forms.Form): + email = forms.EmailField(label=u'Email', help_text=u'涓嶄細鍏紑锛岀敤浜庡ご鍍忔樉绀烘湇鍔', required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + realname = forms.CharField(label=u'鐪熷疄濮撳悕', required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + website = forms.URLField(label=u'涓汉缃戠珯', required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + city = forms.CharField(label=u'鍩庡競', required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + birthday = forms.DateField(label=u'鐢熸棩', help_text=u'涓嶄細鍏紑锛屽彧浼氭樉绀烘偍鐨勫勾榫勶紝鏍煎紡涓猴細YYYY-MM-DD', required=True, widget=forms.TextInput(attrs={'size' : 35})) + about = forms.CharField(label=u'涓汉绠浠', required=False, widget=forms.Textarea(attrs={'cols' : 60})) + + def __init__(self, user, *args, **kwargs): + super(EditUserForm, self).__init__(*args, **kwargs) + self.fields['email'].initial = user.email + self.fields['realname'].initial = user.real_name + self.fields['website'].initial = user.website + self.fields['city'].initial = user.location + + if user.date_of_birth is not None: + self.fields['birthday'].initial = user.date_of_birth.date() + else: + self.fields['birthday'].initial = '1990-01-01' + self.fields['about'].initial = user.about + self.user = user + + def clean_email(self): + """For security reason one unique email in database""" + if self.user.email != self.cleaned_data['email']: + if 'email' in self.cleaned_data: + try: + user = User.objects.get(email = self.cleaned_data['email']) + except User.DoesNotExist: + return self.cleaned_data['email'] + except User.MultipleObjectsReturned: + raise forms.ValidationError(u'璇ョ數瀛愰偖浠跺凡琚敞鍐岋紝璇烽夋嫨鍙︿竴涓啀璇曘') + raise forms.ValidationError("璇ョ數瀛愰偖浠跺笎鍙峰凡琚敞鍐岋紝璇烽夋嫨鍙︿竴涓啀璇曘") + else: + return self.cleaned_data['email'] \ No newline at end of file diff --git a/forum/management/__init__.py b/forum/management/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/forum/management/commands/__init__.py b/forum/management/commands/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/forum/management/commands/base_command.py b/forum/management/commands/base_command.py new file mode 100644 index 0000000000..c073bf7a2e --- /dev/null +++ b/forum/management/commands/base_command.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +#encoding:utf-8 +#------------------------------------------------------------------------------- +# Name: Award badges command +# Purpose: This is a command file croning in background process regularly to +# query database and award badges for user's special acitivities. +# +# Author: Mike, Sailing +# +# Created: 22/01/2009 +# Copyright: (c) Mike 2009 +# Licence: GPL V2 +#------------------------------------------------------------------------------- + +from datetime import datetime, date +from django.core.management.base import NoArgsCommand +from django.db import connection +from django.shortcuts import get_object_or_404 +from django.contrib.contenttypes.models import ContentType + +from forum.models import * +from forum.const import * + +class BaseCommand(NoArgsCommand): + def update_activities_auditted(self, cursor, activity_ids): + # update processed rows to auditted + if len(activity_ids): + query = "UPDATE activity SET is_auditted = 1 WHERE id in (%s)"\ + % ','.join('%s' % item for item in activity_ids) + cursor.execute(query) + + + + + diff --git a/forum/management/commands/clean_award_badges.py b/forum/management/commands/clean_award_badges.py new file mode 100644 index 0000000000..df3d291727 --- /dev/null +++ b/forum/management/commands/clean_award_badges.py @@ -0,0 +1,58 @@ +#------------------------------------------------------------------------------- +# Name: Award badges command +# Purpose: This is a command file croning in background process regularly to +# query database and award badges for user's special acitivities. +# +# Author: Mike +# +# Created: 18/01/2009 +# Copyright: (c) Mike 2009 +# Licence: GPL V2 +#------------------------------------------------------------------------------- +#!/usr/bin/env python +#encoding:utf-8 +from django.core.management.base import NoArgsCommand +from django.db import connection +from django.shortcuts import get_object_or_404 +from django.contrib.contenttypes.models import ContentType + +from forum.models import * + +class Command(NoArgsCommand): + def handle_noargs(self, **options): + try: + self.clean_awards() + except Exception, e: + print e + finally: + connection.close() + + def clean_awards(self): + Award.objects.all().delete() + + award_type =ContentType.objects.get_for_model(Award) + Activity.objects.filter(content_type=award_type).delete() + + for user in User.objects.all(): + user.gold = 0 + user.silver = 0 + user.bronze = 0 + user.save() + + for badge in Badge.objects.all(): + badge.awarded_count = 0 + badge.save() + + query = "UPDATE activity SET is_auditted = 0" + cursor = connection.cursor() + try: + cursor.execute(query) + finally: + cursor.close() + connection.close() + +def main(): + pass + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/forum/management/commands/multi_award_badges.py b/forum/management/commands/multi_award_badges.py new file mode 100644 index 0000000000..723a8cec47 --- /dev/null +++ b/forum/management/commands/multi_award_badges.py @@ -0,0 +1,347 @@ +#!/usr/bin/env python +#encoding:utf-8 +#------------------------------------------------------------------------------- +# Name: Award badges command +# Purpose: This is a command file croning in background process regularly to +# query database and award badges for user's special acitivities. +# +# Author: Mike, Sailing +# +# Created: 22/01/2009 +# Copyright: (c) Mike 2009 +# Licence: GPL V2 +#------------------------------------------------------------------------------- + +from datetime import datetime, date +from django.core.management.base import NoArgsCommand +from django.db import connection +from django.shortcuts import get_object_or_404 +from django.contrib.contenttypes.models import ContentType + +from forum.models import * +from forum.const import * +from base_command import BaseCommand +""" +(1, '鐐肩嫳娉曞笀', 3, '鐐肩嫳娉曞笀', '鍒犻櫎鑷繁鏈3涓互涓婅禐鎴愮エ鐨勫笘瀛', 1, 0), +(2, '鍘嬪姏鐧介', 3, '鍘嬪姏鐧介', '鍒犻櫎鑷繁鏈3涓互涓婂弽瀵圭エ鐨勫笘瀛', 1, 0), +(3, '浼樼鍥炵瓟', 3, '浼樼鍥炵瓟', '鍥炵瓟濂借瘎10娆′互涓', 1, 0), +(4, '浼樼闂', 3, '浼樼闂', '闂濂借瘎10娆′互涓', 1, 0), +(5, '璇勮瀹', 3, '璇勮瀹', '璇勮10娆′互涓', 0, 0), +(6, '娴佽闂', 3, '娴佽闂', '闂鐨勬祻瑙堥噺瓒呰繃1000浜烘', 1, 0), +(7, '宸¢诲叺', 3, '宸¢诲叺', '绗竴娆℃爣璁板瀮鍦惧笘瀛', 0, 0), +(8, '娓呮磥宸', 3, '娓呮磥宸', '绗竴娆℃挙閿鎶曠エ', 0, 0), +(9, '鎵硅瘎瀹', 3, '鎵硅瘎瀹', '绗竴娆″弽瀵圭エ', 0, 0), +(10, '灏忕紪', 3, '灏忕紪', '绗竴娆$紪杈戞洿鏂', 0, 0), +(11, '鏉戦暱', 3, '鏉戦暱', '绗竴娆¢噸鏂版爣绛', 0, 0), +(12, '瀛﹁', 3, '瀛﹁', '绗竴娆℃爣璁扮瓟妗', 0, 0), +(13, '瀛︾敓', 3, '瀛︾敓', '绗竴娆℃彁闂苟涓旀湁涓娆′互涓婅禐鎴愮エ', 0, 0), +(14, '鏀寔鑰', 3, '鏀寔鑰', '绗竴娆¤禐鎴愮エ', 0, 0), +(15, '鏁欏笀', 3, '鏁欏笀', '绗竴娆″洖绛旈棶棰樺苟涓斿緱鍒颁竴涓互涓婅禐鎴愮エ', 0, 0), +(16, '鑷紶浣滆', 3, '鑷紶浣滆', '瀹屾暣濉啓鐢ㄦ埛璧勬枡鎵鏈夐夐」', 0, 0), +(17, '鑷鎴愭墠', 3, '鑷鎴愭墠', '鍥炵瓟鑷繁鐨勯棶棰樺苟涓旀湁3涓互涓婅禐鎴愮エ', 1, 0), +(18, '鏈鏈変环鍊煎洖绛', 1, '鏈鏈変环鍊煎洖绛', '鍥炵瓟瓒呰繃100娆¤禐鎴愮エ', 1, 0), +(19, '鏈鏈変环鍊奸棶棰', 1, '鏈鏈変环鍊奸棶棰', '闂瓒呰繃100娆¤禐鎴愮エ', 1, 0), +(20, '涓囦汉杩', 1, '涓囦汉杩', '闂琚100浜轰互涓婃敹钘', 1, 0), +(21, '钁楀悕闂', 1, '钁楀悕闂', '闂鐨勬祻瑙堥噺瓒呰繃10000浜烘', 1, 0), +(22, 'alpha鐢ㄦ埛', 2, 'alpha鐢ㄦ埛', '鍐呮祴鏈熼棿鐨勬椿璺冪敤鎴', 0, 0), +(23, '鏋佸ソ鍥炵瓟', 2, '鏋佸ソ鍥炵瓟', '鍥炵瓟瓒呰繃25娆¤禐鎴愮エ', 1, 0), +(24, '鏋佸ソ闂', 2, '鏋佸ソ闂', '闂瓒呰繃25娆¤禐鎴愮エ', 1, 0), +(25, '鍙楁杩庨棶棰', 2, '鍙楁杩庨棶棰', '闂琚25浜轰互涓婃敹钘', 1, 0), +(26, '浼樼甯傛皯', 2, '浼樼甯傛皯', '鎶曠エ300娆′互涓', 0, 0), +(27, '缂栬緫涓讳换', 2, '缂栬緫涓讳换', '缂栬緫浜100涓笘瀛', 0, 0), +(28, '閫氭墠', 2, '閫氭墠', '鍦ㄥ涓爣绛鹃鍩熸椿璺', 0, 0), +(29, '涓撳', 2, '涓撳', '鍦ㄤ竴涓爣绛鹃鍩熸椿璺冨嚭浼', 0, 0), +(30, '鑰侀笩', 2, '鑰侀笩', '娲昏穬瓒呰繃涓骞寸殑鐢ㄦ埛', 0, 0), +(31, '鏈鍙楀叧娉ㄩ棶棰', 2, '鏈鍙楀叧娉ㄩ棶棰', '闂鐨勬祻瑙堥噺瓒呰繃2500浜烘', 1, 0), +(32, '瀛﹂棶瀹', 2, '瀛﹂棶瀹', '绗竴娆″洖绛旇鎶曡禐鎴愮エ10娆′互涓', 0, 0), +(33, 'beta鐢ㄦ埛', 2, 'beta鐢ㄦ埛', 'beta鏈熼棿娲昏穬鍙備笌', 0, 0), +(34, '瀵煎笀', 2, '瀵煎笀', '琚寚瀹氫负鏈浣崇瓟妗堝苟涓旇禐鎴愮エ40浠ヤ笂', 1, 0), +(35, '宸笀', 2, '宸笀', '鍦ㄦ彁闂60澶╀箣鍚庡洖绛斿苟涓旇禐鎴愮エ5娆′互涓', 1, 0), +(36, '鍒嗙被涓撳', 2, '鍒嗙被涓撳', '鍒涘缓鐨勬爣绛捐50涓互涓婇棶棰樹娇鐢', 1, 0); + + +TYPE_ACTIVITY_ASK_QUESTION=1 +TYPE_ACTIVITY_ANSWER=2 +TYPE_ACTIVITY_COMMENT_QUESTION=3 +TYPE_ACTIVITY_COMMENT_ANSWER=4 +TYPE_ACTIVITY_UPDATE_QUESTION=5 +TYPE_ACTIVITY_UPDATE_ANSWER=6 +TYPE_ACTIVITY_PRIZE=7 +TYPE_ACTIVITY_MARK_ANSWER=8 +TYPE_ACTIVITY_VOTE_UP=9 +TYPE_ACTIVITY_VOTE_DOWN=10 +TYPE_ACTIVITY_CANCEL_VOTE=11 +TYPE_ACTIVITY_DELETE_QUESTION=12 +TYPE_ACTIVITY_DELETE_ANSWER=13 +TYPE_ACTIVITY_MARK_OFFENSIVE=14 +TYPE_ACTIVITY_UPDATE_TAGS=15 +TYPE_ACTIVITY_FAVORITE=16 +TYPE_ACTIVITY_USER_FULL_UPDATED = 17 +""" + +class Command(BaseCommand): + def handle_noargs(self, **options): + try: + self.delete_question_be_voted_up_3() + self.delete_answer_be_voted_up_3() + self.delete_question_be_vote_down_3() + self.delete_answer_be_voted_down_3() + self.answer_be_voted_up_10() + self.question_be_voted_up_10() + self.question_view_1000() + self.answer_self_question_be_voted_up_3() + self.answer_be_voted_up_100() + self.question_be_voted_up_100() + self.question_be_favorited_100() + self.question_view_10000() + self.answer_be_voted_up_25() + self.question_be_voted_up_25() + self.question_be_favorited_25() + self.question_view_2500() + self.answer_be_accepted_and_voted_up_40() + self.question_be_answered_after_60_days_and_be_voted_up_5() + self.created_tag_be_used_in_question_50() + except Exception, e: + print e + finally: + connection.close() + + def delete_question_be_voted_up_3(self): + """ + (1, '鐐肩嫳娉曞笀', 3, '鐐肩嫳娉曞笀', '鍒犻櫎鑷繁鏈3涓互涓婅禐鎴愮エ鐨勫笘瀛', 1, 0), + """ + query = "SELECT act.id, act.user_id, act.object_id FROM activity act, question q WHERE act.object_id = q.id AND\ + act.activity_type = %s AND\ + q.vote_up_count >=3 AND \ + act.is_auditted = 0" % (TYPE_ACTIVITY_DELETE_QUESTION) + self.__process_activities_badge(query, 1, Question) + + def delete_answer_be_voted_up_3(self): + """ + (1, '鐐肩嫳娉曞笀', 3, '鐐肩嫳娉曞笀', '鍒犻櫎鑷繁鏈3涓互涓婅禐鎴愮エ鐨勫笘瀛', 1, 0), + """ + query = "SELECT act.id, act.user_id, act.object_id FROM activity act, answer an WHERE act.object_id = an.id AND\ + act.activity_type = %s AND\ + an.vote_up_count >=3 AND \ + act.is_auditted = 0" % (TYPE_ACTIVITY_DELETE_ANSWER) + self.__process_activities_badge(query, 1, Answer) + + def delete_question_be_vote_down_3(self): + """ + (2, '鍘嬪姏鐧介', 3, '鍘嬪姏鐧介', '鍒犻櫎鑷繁鏈3涓互涓婂弽瀵圭エ鐨勫笘瀛', 1, 0), + """ + query = "SELECT act.id, act.user_id, act.object_id FROM activity act, question q WHERE act.object_id = q.id AND\ + act.activity_type = %s AND\ + q.vote_down_count >=3 AND \ + act.is_auditted = 0" % (TYPE_ACTIVITY_DELETE_QUESTION) + content_type = ContentType.objects.get_for_model(Question) + self.__process_activities_badge(query, 2, Question) + + def delete_answer_be_voted_down_3(self): + """ + (2, '鍘嬪姏鐧介', 3, '鍘嬪姏鐧介', '鍒犻櫎鑷繁鏈3涓互涓婂弽瀵圭エ鐨勫笘瀛', 1, 0), + """ + query = "SELECT act.id, act.user_id, act.object_id FROM activity act, answer an WHERE act.object_id = an.id AND\ + act.activity_type = %s AND\ + an.vote_down_count >=3 AND \ + act.is_auditted = 0" % (TYPE_ACTIVITY_DELETE_ANSWER) + self.__process_activities_badge(query, 2, Answer) + + def answer_be_voted_up_10(self): + """ + (3, '浼樼鍥炵瓟', 3, '浼樼鍥炵瓟', '鍥炵瓟濂借瘎10娆′互涓', 1, 0), + """ + query = "SELECT act.id, act.user_id, act.object_id FROM \ + activity act, answer a WHERE act.object_id = a.id AND\ + act.activity_type = %s AND \ + a.vote_up_count >= 10 AND\ + act.is_auditted = 0" % (TYPE_ACTIVITY_ANSWER) + self.__process_activities_badge(query, 3, Answer) + + def question_be_voted_up_10(self): + """ + (4, '浼樼闂', 3, '浼樼闂', '闂濂借瘎10娆′互涓', 1, 0), + """ + query = "SELECT act.id, act.user_id, act.object_id FROM \ + activity act, question q WHERE act.object_id = q.id AND\ + act.activity_type = %s AND \ + q.vote_up_count >= 10 AND\ + act.is_auditted = 0" % (TYPE_ACTIVITY_ASK_QUESTION) + self.__process_activities_badge(query, 4, Question) + + def question_view_1000(self): + """ + (6, '娴佽闂', 3, '娴佽闂', '闂鐨勬祻瑙堥噺瓒呰繃1000浜烘', 1, 0), + """ + query = "SELECT act.id, act.user_id, act.object_id FROM \ + activity act, question q WHERE act.activity_type = %s AND\ + act.object_id = q.id AND \ + q.view_count >= 1000 AND\ + act.object_id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (TYPE_ACTIVITY_ASK_QUESTION, 6) + self.__process_activities_badge(query, 6, Question, False) + + def answer_self_question_be_voted_up_3(self): + """ + (17, '鑷鎴愭墠', 3, '鑷鎴愭墠', '鍥炵瓟鑷繁鐨勯棶棰樺苟涓旀湁3涓互涓婅禐鎴愮エ', 1, 0), + """ + query = "SELECT act.id, act.user_id, act.object_id FROM \ + activity act, answer an WHERE act.activity_type = %s AND\ + act.object_id = an.id AND\ + an.vote_up_count >= 3 AND\ + act.user_id = (SELECT user_id FROM question q WHERE q.id = an.question_id) AND\ + act.object_id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (TYPE_ACTIVITY_ANSWER, 17) + self.__process_activities_badge(query, 17, Question, False) + + def answer_be_voted_up_100(self): + """ + (18, '鏈鏈変环鍊煎洖绛', 1, '鏈鏈変环鍊煎洖绛', '鍥炵瓟瓒呰繃100娆¤禐鎴愮エ', 1, 0), + """ + query = "SELECT an.id, an.author_id FROM answer an WHERE an.vote_up_count >= 100 AND an.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (18) + + self.__process_badge(query, 18, Answer) + + def question_be_voted_up_100(self): + """ + (19, '鏈鏈変环鍊奸棶棰', 1, '鏈鏈変环鍊奸棶棰', '闂瓒呰繃100娆¤禐鎴愮エ', 1, 0), + """ + query = "SELECT q.id, q.author_id FROM question q WHERE q.vote_up_count >= 100 AND q.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (19) + + self.__process_badge(query, 19, Question) + + def question_be_favorited_100(self): + """ + (20, '涓囦汉杩', 1, '涓囦汉杩', '闂琚100浜轰互涓婃敹钘', 1, 0), + """ + query = "SELECT q.id, q.author_id FROM question q WHERE q.favourite_count >= 100 AND q.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (20) + + self.__process_badge(query, 20, Question) + + def question_view_10000(self): + """ + (21, '钁楀悕闂', 1, '钁楀悕闂', '闂鐨勬祻瑙堥噺瓒呰繃10000浜烘', 1, 0), + """ + query = "SELECT q.id, q.author_id FROM question q WHERE q.view_count >= 10000 AND q.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (21) + + self.__process_badge(query, 21, Question) + + def answer_be_voted_up_25(self): + """ + (23, '鏋佸ソ鍥炵瓟', 2, '鏋佸ソ鍥炵瓟', '鍥炵瓟瓒呰繃25娆¤禐鎴愮エ', 1, 0), + """ + query = "SELECT a.id, a.author_id FROM answer a WHERE a.vote_up_count >= 25 AND a.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (23) + + self.__process_badge(query, 23, Answer) + + def question_be_voted_up_25(self): + """ + (24, '鏋佸ソ闂', 2, '鏋佸ソ闂', '闂瓒呰繃25娆¤禐鎴愮エ', 1, 0), + """ + query = "SELECT q.id, q.author_id FROM question q WHERE q.vote_up_count >= 25 AND q.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (24) + + self.__process_badge(query, 24, Question) + + def question_be_favorited_25(self): + """ + (25, '鍙楁杩庨棶棰', 2, '鍙楁杩庨棶棰', '闂琚25浜轰互涓婃敹钘', 1, 0), + """ + query = "SELECT q.id, q.author_id FROM question q WHERE q.favourite_count >= 25 AND q.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (25) + + self.__process_badge(query, 25, Question) + + def question_view_2500(self): + """ + (31, '鏈鍙楀叧娉ㄩ棶棰', 2, '鏈鍙楀叧娉ㄩ棶棰', '闂鐨勬祻瑙堥噺瓒呰繃2500浜烘', 1, 0), + """ + query = "SELECT q.id, q.author_id FROM question q WHERE q.view_count >= 2500 AND q.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (31) + + self.__process_badge(query, 31, Question) + + def answer_be_accepted_and_voted_up_40(self): + """ + (34, '瀵煎笀', 2, '瀵煎笀', '琚寚瀹氫负鏈浣崇瓟妗堝苟涓旇禐鎴愮エ40浠ヤ笂', 1, 0), + """ + query = "SELECT a.id, a.author_id FROM answer a WHERE a.vote_up_count >= 40 AND\ + a.accepted = 1 AND\ + a.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (34) + + self.__process_badge(query, 34, Answer) + + def question_be_answered_after_60_days_and_be_voted_up_5(self): + """ + (35, '宸笀', 2, '宸笀', '鍦ㄦ彁闂60澶╀箣鍚庡洖绛斿苟涓旇禐鎴愮エ5娆′互涓', 1, 0), + """ + query = "SELECT a.id, a.author_id FROM question q, answer a WHERE q.id = a.question_id AND\ + DATEDIFF(a.added_at, q.added_at) >= 60 AND\ + a.vote_up_count >= 5 AND \ + a.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (35) + + self.__process_badge(query, 35, Answer) + + def created_tag_be_used_in_question_50(self): + """ + (36, '鍒嗙被涓撳', 2, '鍒嗙被涓撳', '鍒涘缓鐨勬爣绛捐50涓互涓婇棶棰樹娇鐢', 1, 0); + """ + query = "SELECT t.id, t.created_by_id FROM tag t, auth_user u WHERE t.created_by_id = u.id AND \ + t. used_count >= 50 AND \ + t.id NOT IN \ + (SELECT object_id FROM award WHERE award.badge_id = %s)" % (36) + + self.__process_badge(query, 36, Tag) + + def __process_activities_badge(self, query, badge, content_object, update_auditted=True): + content_type = ContentType.objects.get_for_model(content_object) + + cursor = connection.cursor() + try: + cursor.execute(query) + rows = cursor.fetchall() + + if update_auditted: + activity_ids = [] + badge = get_object_or_404(Badge, id=badge) + for row in rows: + activity_id = row[0] + user_id = row[1] + object_id = row[2] + + user = get_object_or_404(User, id=user_id) + award = Award(user=user, badge=badge, content_type=content_type, object_id=objet_id) + award.save() + + if update_auditted: + activity_ids.append(activity_id) + + if update_auditted: + self.update_activities_auditted(cursor, activity_ids) + finally: + cursor.close() + + def __process_badge(self, query, badge, content_object): + content_type = ContentType.objects.get_for_model(Answer) + cursor = connection.cursor() + try: + cursor.execute(query) + rows = cursor.fetchall() + + badge = get_object_or_404(Badge, id=badge) + for row in rows: + object_id = row[0] + user_id = row[1] + + user = get_object_or_404(User, id=user_id) + award = Award(user=user, badge=badge, content_type=content_type, object_id=object_id) + award.save() + finally: + cursor.close() \ No newline at end of file diff --git a/forum/management/commands/once_award_badges.py b/forum/management/commands/once_award_badges.py new file mode 100644 index 0000000000..c1a147d7d2 --- /dev/null +++ b/forum/management/commands/once_award_badges.py @@ -0,0 +1,350 @@ +锘#!/usr/bin/env python +#encoding:utf-8 +#------------------------------------------------------------------------------- +# Name: Award badges command +# Purpose: This is a command file croning in background process regularly to +# query database and award badges for user's special acitivities. +# +# Author: Mike, Sailing +# +# Created: 18/01/2009 +# Copyright: (c) Mike 2009 +# Licence: GPL V2 +#------------------------------------------------------------------------------- + +from datetime import datetime, date +from django.db import connection +from django.shortcuts import get_object_or_404 +from django.contrib.contenttypes.models import ContentType + +from forum.models import * +from forum.const import * +from base_command import BaseCommand +""" +(1, '鐐肩嫳娉曞笀', 3, '鐐肩嫳娉曞笀', '鍒犻櫎鑷繁鏈3涓互涓婅禐鎴愮エ鐨勫笘瀛', 1, 0), +(2, '鍘嬪姏鐧介', 3, '鍘嬪姏鐧介', '鍒犻櫎鑷繁鏈3涓互涓婂弽瀵圭エ鐨勫笘瀛', 1, 0), +(3, '浼樼鍥炵瓟', 3, '浼樼鍥炵瓟', '鍥炵瓟濂借瘎10娆′互涓', 1, 0), +(4, '浼樼闂', 3, '浼樼闂', '闂濂借瘎10娆′互涓', 1, 0), +(5, '璇勮瀹', 3, '璇勮瀹', '璇勮10娆′互涓', 0, 0), +(6, '娴佽闂', 3, '娴佽闂', '闂鐨勬祻瑙堥噺瓒呰繃1000浜烘', 1, 0), +(7, '宸¢诲叺', 3, '宸¢诲叺', '绗竴娆℃爣璁板瀮鍦惧笘瀛', 0, 0), +(8, '娓呮磥宸', 3, '娓呮磥宸', '绗竴娆℃挙閿鎶曠エ', 0, 0), +(9, '鎵硅瘎瀹', 3, '鎵硅瘎瀹', '绗竴娆″弽瀵圭エ', 0, 0), +(10, '灏忕紪', 3, '灏忕紪', '绗竴娆$紪杈戞洿鏂', 0, 0), +(11, '鏉戦暱', 3, '鏉戦暱', '绗竴娆¢噸鏂版爣绛', 0, 0), +(12, '瀛﹁', 3, '瀛﹁', '绗竴娆℃爣璁扮瓟妗', 0, 0), +(13, '瀛︾敓', 3, '瀛︾敓', '绗竴娆℃彁闂苟涓旀湁涓娆′互涓婅禐鎴愮エ', 0, 0), +(14, '鏀寔鑰', 3, '鏀寔鑰', '绗竴娆¤禐鎴愮エ', 0, 0), +(15, '鏁欏笀', 3, '鏁欏笀', '绗竴娆″洖绛旈棶棰樺苟涓斿緱鍒颁竴涓互涓婅禐鎴愮エ', 0, 0), +(16, '鑷紶浣滆', 3, '鑷紶浣滆', '瀹屾暣濉啓鐢ㄦ埛璧勬枡鎵鏈夐夐」', 0, 0), +(17, '鑷鎴愭墠', 3, '鑷鎴愭墠', '鍥炵瓟鑷繁鐨勯棶棰樺苟涓旀湁3涓互涓婅禐鎴愮エ', 1, 0), +(18, '鏈鏈変环鍊煎洖绛', 1, '鏈鏈変环鍊煎洖绛', '鍥炵瓟瓒呰繃100娆¤禐鎴愮エ', 1, 0), +(19, '鏈鏈変环鍊奸棶棰', 1, '鏈鏈変环鍊奸棶棰', '闂瓒呰繃100娆¤禐鎴愮エ', 1, 0), +(20, '涓囦汉杩', 1, '涓囦汉杩', '闂琚100浜轰互涓婃敹钘', 1, 0), +(21, '钁楀悕闂', 1, '钁楀悕闂', '闂鐨勬祻瑙堥噺瓒呰繃10000浜烘', 1, 0), +(22, 'alpha鐢ㄦ埛', 2, 'alpha鐢ㄦ埛', '鍐呮祴鏈熼棿鐨勬椿璺冪敤鎴', 0, 0), +(23, '鏋佸ソ鍥炵瓟', 2, '鏋佸ソ鍥炵瓟', '鍥炵瓟瓒呰繃25娆¤禐鎴愮エ', 1, 0), +(24, '鏋佸ソ闂', 2, '鏋佸ソ闂', '闂瓒呰繃25娆¤禐鎴愮エ', 1, 0), +(25, '鍙楁杩庨棶棰', 2, '鍙楁杩庨棶棰', '闂琚25浜轰互涓婃敹钘', 1, 0), +(26, '浼樼甯傛皯', 2, '浼樼甯傛皯', '鎶曠エ300娆′互涓', 0, 0), +(27, '缂栬緫涓讳换', 2, '缂栬緫涓讳换', '缂栬緫浜100涓笘瀛', 0, 0), +(28, '閫氭墠', 2, '閫氭墠', '鍦ㄥ涓爣绛鹃鍩熸椿璺', 0, 0), +(29, '涓撳', 2, '涓撳', '鍦ㄤ竴涓爣绛鹃鍩熸椿璺冨嚭浼', 0, 0), +(30, '鑰侀笩', 2, '鑰侀笩', '娲昏穬瓒呰繃涓骞寸殑鐢ㄦ埛', 0, 0), +(31, '鏈鍙楀叧娉ㄩ棶棰', 2, '鏈鍙楀叧娉ㄩ棶棰', '闂鐨勬祻瑙堥噺瓒呰繃2500浜烘', 1, 0), +(32, '瀛﹂棶瀹', 2, '瀛﹂棶瀹', '绗竴娆″洖绛旇鎶曡禐鎴愮エ10娆′互涓', 0, 0), +(33, 'beta鐢ㄦ埛', 2, 'beta鐢ㄦ埛', 'beta鏈熼棿娲昏穬鍙備笌', 0, 0), +(34, '瀵煎笀', 2, '瀵煎笀', '琚寚瀹氫负鏈浣崇瓟妗堝苟涓旇禐鎴愮エ40浠ヤ笂', 1, 0), +(35, '宸笀', 2, '宸笀', '鍦ㄦ彁闂60澶╀箣鍚庡洖绛斿苟涓旇禐鎴愮エ5娆′互涓', 1, 0), +(36, '鍒嗙被涓撳', 2, '鍒嗙被涓撳', '鍒涘缓鐨勬爣绛捐50涓互涓婇棶棰樹娇鐢', 1, 0); + + +TYPE_ACTIVITY_ASK_QUESTION=1 +TYPE_ACTIVITY_ANSWER=2 +TYPE_ACTIVITY_COMMENT_QUESTION=3 +TYPE_ACTIVITY_COMMENT_ANSWER=4 +TYPE_ACTIVITY_UPDATE_QUESTION=5 +TYPE_ACTIVITY_UPDATE_ANSWER=6 +TYPE_ACTIVITY_PRIZE=7 +TYPE_ACTIVITY_MARK_ANSWER=8 +TYPE_ACTIVITY_VOTE_UP=9 +TYPE_ACTIVITY_VOTE_DOWN=10 +TYPE_ACTIVITY_CANCEL_VOTE=11 +TYPE_ACTIVITY_DELETE_QUESTION=12 +TYPE_ACTIVITY_DELETE_ANSWER=13 +TYPE_ACTIVITY_MARK_OFFENSIVE=14 +TYPE_ACTIVITY_UPDATE_TAGS=15 +TYPE_ACTIVITY_FAVORITE=16 +TYPE_ACTIVITY_USER_FULL_UPDATED = 17 +""" + +BADGE_AWARD_TYPE_FIRST = { + TYPE_ACTIVITY_MARK_OFFENSIVE : 7, + TYPE_ACTIVITY_CANCEL_VOTE: 8, + TYPE_ACTIVITY_VOTE_DOWN : 9, + TYPE_ACTIVITY_UPDATE_QUESTION : 10, + TYPE_ACTIVITY_UPDATE_ANSWER : 10, + TYPE_ACTIVITY_UPDATE_TAGS : 11, + TYPE_ACTIVITY_MARK_ANSWER : 12, + TYPE_ACTIVITY_VOTE_UP : 14, + TYPE_ACTIVITY_USER_FULL_UPDATED: 16 + +} + +class Command(BaseCommand): + def handle_noargs(self, **options): + try: + self.alpha_user() + self.beta_user() + self.first_type_award() + self.first_ask_be_voted() + self.first_answer_be_voted() + self.first_answer_be_voted_10() + self.vote_count_300() + self.edit_count_100() + self.comment_count_10() + except Exception, e: + print e + finally: + connection.close() + + def alpha_user(self): + """ + Before Jan 25, 2009(Chinese New Year Eve and enter into Beta for CNProg), every registered user + will be awarded the "Alpha" badge if he has any activities. + """ + alpha_end_date = date(2009, 1, 25) + if date.today() < alpha_end_date: + badge = get_object_or_404(Badge, id=22) + for user in User.objects.all(): + award = Award.objects.filter(user=user, badge=badge) + if award and not badge.multiple: + continue + activities = Activity.objects.filter(user=user) + if len(activities) > 0: + new_award = Award(user=user, badge=badge) + new_award.save() + + def beta_user(self): + """ + Before Feb 25, 2009, every registered user + will be awarded the "Beta" badge if he has any activities. + """ + beta_end_date = date(2009, 2, 25) + if date.today() < beta_end_date: + badge = get_object_or_404(Badge, id=33) + for user in User.objects.all(): + award = Award.objects.filter(user=user, badge=badge) + if award and not badge.multiple: + continue + activities = Activity.objects.filter(user=user) + if len(activities) > 0: + new_award = Award(user=user, badge=badge) + new_award.save() + + def first_type_award(self): + """ + This will award below badges for users first behaviors: + + (7, '宸¢诲叺', 3, '宸¢诲叺', '绗竴娆℃爣璁板瀮鍦惧笘瀛', 0, 0), + (8, '娓呮磥宸', 3, '娓呮磥宸', '绗竴娆℃挙閿鎶曠エ', 0, 0), + (9, '鎵硅瘎瀹', 3, '鎵硅瘎瀹', '绗竴娆″弽瀵圭エ', 0, 0), + (10, '灏忕紪', 3, '灏忕紪', '绗竴娆$紪杈戞洿鏂', 0, 0), + (11, '鏉戦暱', 3, '鏉戦暱', '绗竴娆¢噸鏂版爣绛', 0, 0), + (12, '瀛﹁', 3, '瀛﹁', '绗竴娆℃爣璁扮瓟妗', 0, 0), + (14, '鏀寔鑰', 3, '鏀寔鑰', '绗竴娆¤禐鎴愮エ', 0, 0), + (16, '鑷紶浣滆', 3, '鑷紶浣滆', '瀹屾暣濉啓鐢ㄦ埛璧勬枡鎵鏈夐夐」', 0, 0), + """ + activity_types = ','.join('%s' % item for item in BADGE_AWARD_TYPE_FIRST.keys()) + # ORDER BY user_id, activity_type + query = "SELECT id, user_id, activity_type, content_type_id, object_id\ + FROM activity WHERE is_auditted = 0 AND activity_type IN (%s) ORDER BY user_id, activity_type" % activity_types + + cursor = connection.cursor() + try: + cursor.execute(query) + rows = cursor.fetchall() + # collect activity_id in current process + activity_ids = [] + last_user_id = 0 + last_activity_type = 0 + for row in rows: + activity_ids.append(row[0]) + user_id = row[1] + activity_type = row[2] + content_type_id = row[3] + object_id = row[4] + + # if the user and activity are same as the last, continue + if user_id == last_user_id and activity_type == last_activity_type: + continue; + + user = get_object_or_404(User, id=user_id) + badge = get_object_or_404(Badge, id=BADGE_AWARD_TYPE_FIRST[activity_type]) + content_type = get_object_or_404(ContentType, id=content_type_id) + + count = Award.objects.filter(user=user, badge=badge).count() + if count and not badge.multiple: + continue + else: + # new award + award = Award(user=user, badge=badge, content_type=content_type, object_id=object_id) + award.save() + + # set the current user_id and activity_type to last + last_user_id = user_id + last_activity_type = activity_type + + # update processed rows to auditted + self.update_activities_auditted(cursor, activity_ids) + finally: + cursor.close() + + def first_ask_be_voted(self): + """ + For user asked question and got first upvote, we award him following badge: + + (13, '瀛︾敓', 3, '瀛︾敓', '绗竴娆℃彁闂苟涓旀湁涓娆′互涓婅禐鎴愮エ', 0, 0), + """ + query = "SELECT act.user_id, q.vote_up_count, act.object_id FROM \ + activity act, question q WHERE act.activity_type = %s AND \ + act.object_id = q.id AND\ + act.user_id NOT IN (SELECT distinct user_id FROM award WHERE badge_id = %s)" % (TYPE_ACTIVITY_ASK_QUESTION, 13) + cursor = connection.cursor() + try: + cursor.execute(query) + rows = cursor.fetchall() + + badge = get_object_or_404(Badge, id=13) + content_type = ContentType.objects.get_for_model(Question) + awarded_users = [] + for row in rows: + user_id = row[0] + vote_up_count = row[1] + object_id = row[2] + if vote_up_count > 0 and user_id not in awarded_users: + user = get_object_or_404(User, id=user_id) + award = Award(user=user, badge=badge, content_type=content_type, object_id=object_id) + award.save() + awarded_users.append(user_id) + finally: + cursor.close() + + def first_answer_be_voted(self): + """ + When user answerd questions and got first upvote, we award him following badge: + + (15, '鏁欏笀', 3, '鏁欏笀', '绗竴娆″洖绛旈棶棰樺苟涓斿緱鍒颁竴涓互涓婅禐鎴愮エ', 0, 0), + """ + query = "SELECT act.user_id, a.vote_up_count, act.object_id FROM \ + activity act, answer a WHERE act.activity_type = %s AND \ + act.object_id = a.id AND\ + act.user_id NOT IN (SELECT distinct user_id FROM award WHERE badge_id = %s)" % (TYPE_ACTIVITY_ANSWER, 15) + cursor = connection.cursor() + try: + cursor.execute(query) + rows = cursor.fetchall() + + awarded_users = [] + badge = get_object_or_404(Badge, id=15) + content_type = ContentType.objects.get_for_model(Answer) + for row in rows: + user_id = row[0] + vote_up_count = row[1] + object_id = row[2] + if vote_up_count > 0 and user_id not in awarded_users: + user = get_object_or_404(User, id=user_id) + award = Award(user=user, badge=badge, content_type=content_type, object_id=object_id) + award.save() + awarded_users.append(user_id) + finally: + cursor.close() + + def first_answer_be_voted_10(self): + """ + (32, '瀛﹂棶瀹', 2, '瀛﹂棶瀹', '绗竴娆″洖绛旇鎶曡禐鎴愮エ10娆′互涓', 0, 0) + """ + query = "SELECT act.user_id, act.object_id FROM \ + activity act, answer a WHERE act.object_id = a.id AND\ + act.activity_type = %s AND \ + a.vote_up_count >= 10 AND\ + act.user_id NOT IN (SELECT user_id FROM award WHERE badge_id = %s)" % (TYPE_ACTIVITY_ANSWER, 32) + cursor = connection.cursor() + try: + cursor.execute(query) + rows = cursor.fetchall() + + awarded_users = [] + badge = get_object_or_404(Badge, id=32) + content_type = ContentType.objects.get_for_model(Answer) + for row in rows: + user_id = row[0] + if user_id not in awarded_users: + user = get_object_or_404(User, id=user_id) + object_id = row[1] + award = Award(user=user, badge=badge, content_type=content_type, object_id=object_id) + award.save() + awarded_users.append(user_id) + finally: + cursor.close() + + def vote_count_300(self): + """ + (26, '浼樼甯傛皯', 2, '浼樼甯傛皯', '鎶曠エ300娆′互涓', 0, 0) + """ + query = "SELECT count(*) vote_count, user_id FROM activity WHERE \ + activity_type = %s OR \ + activity_type = %s AND \ + user_id NOT IN (SELECT user_id FROM award WHERE badge_id = %s) \ + GROUP BY user_id HAVING vote_count >= 300" % (TYPE_ACTIVITY_VOTE_UP, TYPE_ACTIVITY_VOTE_DOWN, 26) + + self.__award_for_count_num(query, 26) + + def edit_count_100(self): + """ + (27, '缂栬緫涓讳换', 2, '缂栬緫涓讳换', '缂栬緫浜100涓笘瀛', 0, 0) + """ + query = "SELECT count(*) vote_count, user_id FROM activity WHERE \ + activity_type = %s OR \ + activity_type = %s AND \ + user_id NOT IN (SELECT user_id FROM award WHERE badge_id = %s) \ + GROUP BY user_id HAVING vote_count >= 100" % (TYPE_ACTIVITY_UPDATE_QUESTION, TYPE_ACTIVITY_UPDATE_ANSWER, 27) + + self.__award_for_count_num(query, 27) + + def comment_count_10(self): + """ + (5, '璇勮瀹', 3, '璇勮瀹', '璇勮10娆′互涓', 0, 0), + """ + query = "SELECT count(*) vote_count, user_id FROM activity WHERE \ + activity_type = %s OR \ + activity_type = %s AND \ + user_id NOT IN (SELECT user_id FROM award WHERE badge_id = %s) \ + GROUP BY user_id HAVING vote_count >= 10" % (TYPE_ACTIVITY_COMMENT_QUESTION, TYPE_ACTIVITY_COMMENT_ANSWER, 5) + self.__award_for_count_num(query, 5) + + def __award_for_count_num(self, query, badge): + cursor = connection.cursor() + try: + cursor.execute(query) + rows = cursor.fetchall() + + awarded_users = [] + badge = get_object_or_404(Badge, id=badge) + for row in rows: + vote_count = row[0] + user_id = row[1] + + if user_id not in awarded_users: + user = get_object_or_404(User, id=user_id) + award = Award(user=user, badge=badge) + award.save() + awarded_users.append(user_id) + finally: + cursor.close() + +def main(): + pass + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/forum/management/commands/sample_command.py b/forum/management/commands/sample_command.py new file mode 100644 index 0000000000..55e67235dc --- /dev/null +++ b/forum/management/commands/sample_command.py @@ -0,0 +1,7 @@ +from django.core.management.base import NoArgsCommand +from forum.models import Comment + +class Command(NoArgsCommand): + def handle_noargs(self, **options): + objs = Comment.objects.all() + print objs \ No newline at end of file diff --git a/forum/managers.py b/forum/managers.py new file mode 100644 index 0000000000..0f22c59cfe --- /dev/null +++ b/forum/managers.py @@ -0,0 +1,259 @@ +锘縤mport datetime +import logging +from django.contrib.auth.models import User, UserManager +from django.db import connection, models, transaction +from django.db.models import Q +from forum.models import * +from urllib import quote, unquote + +class QuestionManager(models.Manager): + def get_translation_questions(self, orderby, page_size): + questions = self.filter(deleted=False, author__id__in=[28,29]).order_by(orderby)[:page_size] + return questions + + def get_questions_by_pagesize(self, orderby, page_size): + questions = self.filter(deleted=False).order_by(orderby)[:page_size] + return questions + + def get_questions_by_tag(self, tagname, orderby): + questions = self.filter(deleted=False, tags__name = unquote(tagname)).order_by(orderby) + return questions + + def get_unanswered_questions(self, orderby): + questions = self.filter(deleted=False, answer_count=0).order_by(orderby) + return questions + + def get_questions(self, orderby): + questions = self.filter(deleted=False).order_by(orderby) + return questions + + def update_tags(self, question, tagnames, user): + """ + Updates Tag associations for a question to match the given + tagname string. + + Returns ``True`` if tag usage counts were updated as a result, + ``False`` otherwise. + """ + from forum.models import Tag + current_tags = list(question.tags.all()) + current_tagnames = set(t.name for t in current_tags) + updated_tagnames = set(t for t in tagnames.split(' ') if t) + modified_tags = [] + + removed_tags = [t for t in current_tags + if t.name not in updated_tagnames] + if removed_tags: + modified_tags.extend(removed_tags) + question.tags.remove(*removed_tags) + + added_tagnames = updated_tagnames - current_tagnames + if added_tagnames: + added_tags = Tag.objects.get_or_create_multiple(added_tagnames, + user) + modified_tags.extend(added_tags) + question.tags.add(*added_tags) + + if modified_tags: + Tag.objects.update_use_counts(modified_tags) + return True + + return False + + def update_answer_count(self, question): + """ + Executes an UPDATE query to update denormalised data with the + number of answers the given question has. + """ + + # for some reasons, this Answer class failed to be imported, + # although we have imported all classes from models on top. + from forum.models import Answer + self.filter(id=question.id).update( + answer_count=Answer.objects.get_answers_from_question(question).count()) + + def update_view_count(self, question): + """ + update counter+1 when user browse question page + """ + self.filter(id=question.id).update(view_count = question.view_count + 1) + + def update_favorite_count(self, question): + """ + update favourite_count for given question + """ + from forum.models import FavoriteQuestion + self.filter(id=question.id).update(favourite_count = FavoriteQuestion.objects.filter(question=question).count()) + + def get_similar_questions(self, question): + """ + Get 10 similar questions for given one. + This will search the same tag list for give question(by exactly same string) first. + Questions with the individual tags will be added to list if above questions are not full. + """ + #print datetime.datetime.now() + from forum.models import Question + questions = list(Question.objects.filter(tagnames = question.tagnames).all()) + + tags_list = question.tags.all() + for tag in tags_list: + extend_questions = Question.objects.filter(tags__id = tag.id)[:50] + for item in extend_questions: + if item not in questions and len(questions) < 10: + questions.append(item) + + #print datetime.datetime.now() + return questions + +class TagManager(models.Manager): + UPDATE_USED_COUNTS_QUERY = ( + 'UPDATE tag ' + 'SET used_count = (' + 'SELECT COUNT(*) FROM question_tags ' + 'WHERE tag_id = tag.id' + ') ' + 'WHERE id IN (%s)') + + def get_valid_tags(self, page_size): + from forum.models import Tag + tags = Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by("-id")[:page_size] + return tags + + def get_or_create_multiple(self, names, user): + """ + Fetches a list of Tags with the given names, creating any Tags + which don't exist when necesssary. + """ + tags = list(self.filter(name__in=names)) + #Set all these tag visible + for tag in tags: + if tag.deleted: + tag.deleted = False + tag.deleted_by = None + tag.deleted_at = None + tag.save() + + if len(tags) < len(names): + existing_names = set(tag.name for tag in tags) + new_names = [name for name in names if name not in existing_names] + tags.extend([self.create(name=name, created_by=user) + for name in new_names if self.filter(name=name).count() == 0 and len(name.strip()) > 0]) + + return tags + + def update_use_counts(self, tags): + """Updates the given Tags with their current use counts.""" + if not tags: + return + cursor = connection.cursor() + query = self.UPDATE_USED_COUNTS_QUERY % ','.join(['%s'] * len(tags)) + cursor.execute(query, [tag.id for tag in tags]) + transaction.commit_unless_managed() + + def get_tags_by_questions(self, questions): + question_ids = [] + for question in questions: + question_ids.append(question.id) + + question_ids_str = ','.join([str(id) for id in question_ids]) + related_tags = self.extra( + tables=['tag', 'question_tags'], + where=["tag.id = question_tags.tag_id AND question_tags.question_id IN (" + question_ids_str + ")"] + ).distinct() + + return related_tags + +class AnswerManager(models.Manager): + GET_ANSWERS_FROM_USER_QUESTIONS = u'SELECT answer.* FROM answer INNER JOIN question ON answer.question_id = question.id WHERE question.author_id =%s AND answer.author_id <> %s' + def get_answers_from_question(self, question, user=None): + """ + Retrieves visibile answers for the given question. Delete answers + are only visibile to the person who deleted them. + """ + + if user is None or not user.is_authenticated(): + return self.filter(question=question, deleted=False) + else: + return self.filter(Q(question=question), + Q(deleted=False) | Q(deleted_by=user)) + + def get_answers_from_questions(self, user_id): + """ + Retrieves visibile answers for the given question. Which are not included own answers + """ + cursor = connection.cursor() + cursor.execute(self.GET_ANSWERS_FROM_USER_QUESTIONS, [user_id, user_id]) + return cursor.fetchall() + +class VoteManager(models.Manager): + COUNT_UP_VOTE_BY_USER = "SELECT count(*) FROM vote WHERE user_id = %s AND vote = 1" + COUNT_DOWN_VOTE_BY_USER = "SELECT count(*) FROM vote WHERE user_id = %s AND vote = -1" + COUNT_VOTES_PER_DAY_BY_USER = "SELECT COUNT(*) FROM vote WHERE user_id = %s AND DATE(voted_at) = DATE(NOW())" + def get_up_vote_count_from_user(self, user): + if user is not None: + cursor = connection.cursor() + cursor.execute(self.COUNT_UP_VOTE_BY_USER, [user.id]) + row = cursor.fetchone() + return row[0] + else: + return 0 + + def get_down_vote_count_from_user(self, user): + if user is not None: + cursor = connection.cursor() + cursor.execute(self.COUNT_DOWN_VOTE_BY_USER, [user.id]) + row = cursor.fetchone() + return row[0] + else: + return 0 + + def get_votes_count_today_from_user(self, user): + if user is not None: + cursor = connection.cursor() + cursor.execute(self.COUNT_VOTES_PER_DAY_BY_USER, [user.id]) + row = cursor.fetchone() + return row[0] + + else: + return 0 + +class FlaggedItemManager(models.Manager): + COUNT_FLAGS_PER_DAY_BY_USER = "SELECT COUNT(*) FROM flagged_item WHERE user_id = %s AND DATE(flagged_at) = DATE(NOW())" + def get_flagged_items_count_today(self, user): + if user is not None: + cursor = connection.cursor() + cursor.execute(self.COUNT_FLAGS_PER_DAY_BY_USER, [user.id]) + row = cursor.fetchone() + return row[0] + + else: + return 0 + +class ReputeManager(models.Manager): + COUNT_REPUTATION_PER_DAY_BY_USER = "SELECT SUM(positive)+SUM(negative) FROM repute WHERE user_id = %s AND (reputation_type=1 OR reputation_type=-8) AND DATE(reputed_at) = DATE(NOW())" + def get_reputation_by_upvoted_today(self, user): + """ + For one user in one day, he can only earn rep till certain score (ep. +200) + by upvoted(also substracted from upvoted canceled). This is because we need + to prohibit gaming system by upvoting/cancel again and again. + """ + if user is not None: + cursor = connection.cursor() + cursor.execute(self.COUNT_REPUTATION_PER_DAY_BY_USER, [user.id]) + row = cursor.fetchone() + return row[0] + + else: + return 0 +class AwardManager(models.Manager): + def get_recent_awards(self): + awards = super(AwardManager, self).extra( + select={'badge_id': 'badge.id', 'badge_name':'badge.name', + 'badge_description': 'badge.description', 'badge_type': 'badge.type', + 'user_id': 'auth_user.id', 'user_name': 'auth_user.username' + }, + tables=['award', 'badge', 'auth_user'], + order_by=['-awarded_at'], + where=['auth_user.id=award.user_id AND badge_id=badge.id'], + ).values('badge_id', 'badge_name', 'badge_description', 'badge_type', 'user_id', 'user_name') + return awards diff --git a/forum/models.py b/forum/models.py new file mode 100644 index 0000000000..290c9d56bb --- /dev/null +++ b/forum/models.py @@ -0,0 +1,653 @@ +锘# encoding:utf-8 +import datetime +import hashlib +from urllib import quote_plus, urlencode +from django.db import models +from django.utils.html import strip_tags +from django.core.urlresolvers import reverse +from django.contrib.auth.models import User +from django.contrib.contenttypes import generic +from django.contrib.contenttypes.models import ContentType +from django.template.defaultfilters import slugify +from django.db.models.signals import post_delete, post_save, pre_save +import django.dispatch + +from forum.managers import * +from const import * + +class Tag(models.Model): + name = models.CharField(max_length=255, unique=True) + created_by = models.ForeignKey(User, related_name='created_tags') + deleted = models.BooleanField(default=False) + deleted_at = models.DateTimeField(null=True, blank=True) + deleted_by = models.ForeignKey(User, null=True, blank=True, related_name='deleted_tags') + # Denormalised data + used_count = models.PositiveIntegerField(default=0) + + objects = TagManager() + + class Meta: + db_table = u'tag' + ordering = ('-used_count', 'name') + + def __unicode__(self): + return self.name + +class Comment(models.Model): + content_type = models.ForeignKey(ContentType) + object_id = models.PositiveIntegerField() + content_object = generic.GenericForeignKey('content_type', 'object_id') + user = models.ForeignKey(User, related_name='comments') + comment = models.CharField(max_length=300) + added_at = models.DateTimeField(default=datetime.datetime.now) + + class Meta: + ordering = ('-added_at',) + db_table = u'comment' + def __unicode__(self): + return self.comment + +class Vote(models.Model): + VOTE_UP = +1 + VOTE_DOWN = -1 + VOTE_CHOICES = ( + (VOTE_UP, u'Up'), + (VOTE_DOWN, u'Down'), + ) + + content_type = models.ForeignKey(ContentType) + object_id = models.PositiveIntegerField() + content_object = generic.GenericForeignKey('content_type', 'object_id') + user = models.ForeignKey(User, related_name='votes') + vote = models.SmallIntegerField(choices=VOTE_CHOICES) + voted_at = models.DateTimeField(default=datetime.datetime.now) + + objects = VoteManager() + + class Meta: + unique_together = ('content_type', 'object_id', 'user') + db_table = u'vote' + def __unicode__(self): + return '[%s] voted at %s: %s' %(self.user, self.voted_at, self.vote) + + def is_upvote(self): + return self.vote == self.VOTE_UP + + def is_downvote(self): + return self.vote == self.VOTE_DOWN + +class FlaggedItem(models.Model): + """A flag on a Question or Answer indicating offensive content.""" + content_type = models.ForeignKey(ContentType) + object_id = models.PositiveIntegerField() + content_object = generic.GenericForeignKey('content_type', 'object_id') + user = models.ForeignKey(User, related_name='flagged_items') + flagged_at = models.DateTimeField(default=datetime.datetime.now) + + objects = FlaggedItemManager() + + class Meta: + unique_together = ('content_type', 'object_id', 'user') + db_table = u'flagged_item' + def __unicode__(self): + return '[%s] flagged at %s' %(self.user, self.flagged_at) + +class Question(models.Model): + title = models.CharField(max_length=300) + author = models.ForeignKey(User, related_name='questions') + added_at = models.DateTimeField(default=datetime.datetime.now) + tags = models.ManyToManyField(Tag, related_name='questions') + # Status + wiki = models.BooleanField(default=False) + wikified_at = models.DateTimeField(null=True, blank=True) + answer_accepted = models.BooleanField(default=False) + closed = models.BooleanField(default=False) + closed_by = models.ForeignKey(User, null=True, blank=True, related_name='closed_questions') + closed_at = models.DateTimeField(null=True, blank=True) + close_reason = models.SmallIntegerField(choices=CLOSE_REASONS, null=True, blank=True) + deleted = models.BooleanField(default=False) + deleted_at = models.DateTimeField(null=True, blank=True) + deleted_by = models.ForeignKey(User, null=True, blank=True, related_name='deleted_questions') + locked = models.BooleanField(default=False) + locked_by = models.ForeignKey(User, null=True, blank=True, related_name='locked_questions') + locked_at = models.DateTimeField(null=True, blank=True) + # Denormalised data + score = models.IntegerField(default=0) + vote_up_count = models.IntegerField(default=0) + vote_down_count = models.IntegerField(default=0) + answer_count = models.PositiveIntegerField(default=0) + comment_count = models.PositiveIntegerField(default=0) + view_count = models.PositiveIntegerField(default=0) + offensive_flag_count = models.SmallIntegerField(default=0) + favourite_count = models.PositiveIntegerField(default=0) + last_edited_at = models.DateTimeField(null=True, blank=True) + last_edited_by = models.ForeignKey(User, null=True, blank=True, related_name='last_edited_questions') + last_activity_at = models.DateTimeField(default=datetime.datetime.now) + last_activity_by = models.ForeignKey(User, related_name='last_active_in_questions') + tagnames = models.CharField(max_length=125) + summary = models.CharField(max_length=180) + html = models.TextField() + comments = generic.GenericRelation(Comment) + votes = generic.GenericRelation(Vote) + flagged_items = generic.GenericRelation(FlaggedItem) + + objects = QuestionManager() + + def save(self, **kwargs): + """ + Overridden to manually manage addition of tags when the object + is first saved. + + This is required as we're using ``tagnames`` as the sole means of + adding and editing tags. + """ + initial_addition = (self.id is None) + super(Question, self).save(**kwargs) + if initial_addition: + tags = Tag.objects.get_or_create_multiple(self.tagname_list(), + self.author) + self.tags.add(*tags) + Tag.objects.update_use_counts(tags) + + def tagname_list(self): + """Creates a list of Tag names from the ``tagnames`` attribute.""" + return [name for name in self.tagnames.split(u' ')] + + def get_absolute_url(self): + return '%s%s' % (reverse('question', args=[self.id]), self.title) + + def has_favorite_by_user(self, user): + if not user.is_authenticated(): + return False + return FavoriteQuestion.objects.filter(question=self, user=user).count() > 0 + + def get_answer_count_by_user(self, user_id): + query_set = Answer.objects.filter(author__id=user_id) + return query_set.filter(question=self).count() + + def get_question_title(self): + if self.closed: + attr = CONST['closed'] + elif self.deleted: + attr = CONST['deleted'] + else: + attr = None + return u'%s %s' % (self.title, attr) if attr is not None else self.title + + def get_revision_url(self): + return reverse('question_revisions', args=[self.id]) + + def get_latest_revision(self): + return self.revisions.all()[0] + + def __unicode__(self): + return self.title + + class Meta: + db_table = u'question' + +class QuestionRevision(models.Model): + """A revision of a Question.""" + question = models.ForeignKey(Question, related_name='revisions') + revision = models.PositiveIntegerField(blank=True) + title = models.CharField(max_length=300) + author = models.ForeignKey(User, related_name='question_revisions') + revised_at = models.DateTimeField() + tagnames = models.CharField(max_length=125) + summary = models.CharField(max_length=300, blank=True) + text = models.TextField() + + class Meta: + db_table = u'question_revision' + ordering = ('-revision',) + + def get_question_title(self): + return self.question.title + + def get_absolute_url(self): + return '/questions/%s/revisions' % (self.question.id) + + def save(self, **kwargs): + """Looks up the next available revision number.""" + if not self.revision: + self.revision = QuestionRevision.objects.filter( + question=self.question).values_list('revision', + flat=True)[0] + 1 + super(QuestionRevision, self).save(**kwargs) + + def __unicode__(self): + return u'revision %s of %s' % (self.revision, self.title) + +class Answer(models.Model): + question = models.ForeignKey(Question, related_name='answers') + author = models.ForeignKey(User, related_name='answers') + added_at = models.DateTimeField(default=datetime.datetime.now) + # Status + wiki = models.BooleanField(default=False) + wikified_at = models.DateTimeField(null=True, blank=True) + accepted = models.BooleanField(default=False) + accepted_at = models.DateTimeField(null=True, blank=True) + deleted = models.BooleanField(default=False) + deleted_by = models.ForeignKey(User, null=True, blank=True, related_name='deleted_answers') + locked = models.BooleanField(default=False) + locked_by = models.ForeignKey(User, null=True, blank=True, related_name='locked_answers') + locked_at = models.DateTimeField(null=True, blank=True) + # Denormalised data + score = models.IntegerField(default=0) + vote_up_count = models.IntegerField(default=0) + vote_down_count = models.IntegerField(default=0) + comment_count = models.PositiveIntegerField(default=0) + offensive_flag_count = models.SmallIntegerField(default=0) + last_edited_at = models.DateTimeField(null=True, blank=True) + last_edited_by = models.ForeignKey(User, null=True, blank=True, related_name='last_edited_answers') + html = models.TextField() + comments = generic.GenericRelation(Comment) + votes = generic.GenericRelation(Vote) + flagged_items = generic.GenericRelation(FlaggedItem) + + objects = AnswerManager() + + def get_user_vote(self, user): + votes = self.votes.filter(user=user) + if votes.count() > 0: + return votes[0] + else: + return None + + def get_latest_revision(self): + return self.revisions.all()[0] + + def get_question_title(self): + return self.question.title + + def get_absolute_url(self): + return '%s%s#%s' % (reverse('question', args=[self.question.id]), self.question.title, self.id) + + class Meta: + db_table = u'answer' + + def __unicode__(self): + return self.html + +class AnswerRevision(models.Model): + """A revision of an Answer.""" + answer = models.ForeignKey(Answer, related_name='revisions') + revision = models.PositiveIntegerField() + author = models.ForeignKey(User, related_name='answer_revisions') + revised_at = models.DateTimeField() + summary = models.CharField(max_length=300, blank=True) + text = models.TextField() + + def get_absolute_url(self): + return '/answers/%s/revisions' % (self.answer.id) + + def get_question_title(self): + return self.answer.question.title + + class Meta: + db_table = u'answer_revision' + ordering = ('-revision',) + + def save(self, **kwargs): + """Looks up the next available revision number if not set.""" + if not self.revision: + self.revision = AnswerRevision.objects.filter( + answer=self.answer).values_list('revision', + flat=True)[0] + 1 + super(AnswerRevision, self).save(**kwargs) + +class FavoriteQuestion(models.Model): + """A favorite Question of a User.""" + question = models.ForeignKey(Question) + user = models.ForeignKey(User, related_name='user_favorite_questions') + added_at = models.DateTimeField(default=datetime.datetime.now) + class Meta: + db_table = u'favorite_question' + def __unicode__(self): + return '[%s] favorited at %s' %(self.user, self.added_at) + +class Badge(models.Model): + """Awarded for notable actions performed on the site by Users.""" + GOLD = 1 + SILVER = 2 + BRONZE = 3 + TYPE_CHOICES = ( + (GOLD, u'閲戠墝'), + (SILVER, u'閾剁墝'), + (BRONZE, u'閾滅墝'), + ) + + name = models.CharField(max_length=50) + type = models.SmallIntegerField(choices=TYPE_CHOICES) + slug = models.SlugField(max_length=50, blank=True) + description = models.CharField(max_length=300) + multiple = models.BooleanField(default=False) + # Denormalised data + awarded_count = models.PositiveIntegerField(default=0) + + class Meta: + db_table = u'badge' + ordering = ('name',) + unique_together = ('name', 'type') + + def __unicode__(self): + return u'%s: %s' % (self.get_type_display(), self.name) + + def save(self, **kwargs): + if not self.slug: + self.slug = self.name#slugify(self.name) + super(Badge, self).save(**kwargs) + + def get_absolute_url(self): + return '%s%s/' % (reverse('badge', args=[self.id]), self.slug) + +class Award(models.Model): + """The awarding of a Badge to a User.""" + user = models.ForeignKey(User, related_name='award_user') + badge = models.ForeignKey(Badge, related_name='award_badge') + content_type = models.ForeignKey(ContentType) + object_id = models.PositiveIntegerField() + content_object = generic.GenericForeignKey('content_type', 'object_id') + awarded_at = models.DateTimeField(default=datetime.datetime.now) + notified = models.BooleanField(default=False) + objects = AwardManager() + + def __unicode__(self): + return u'[%s] is awarded a badge [%s] at %s' % (self.user.username, self.badge.name, self.awarded_at) + + class Meta: + db_table = u'award' + +class Repute(models.Model): + """The reputation histories for user""" + user = models.ForeignKey(User) + positive = models.SmallIntegerField(default=0) + negative = models.SmallIntegerField(default=0) + question = models.ForeignKey(Question) + reputed_at = models.DateTimeField(default=datetime.datetime.now) + reputation_type = models.SmallIntegerField(choices=TYPE_REPUTATION) + reputation = models.IntegerField(default=1) + objects = ReputeManager() + + def __unicode__(self): + return u'[%s]\' reputation changed at %s' % (self.user.username, self.reputed_at) + + class Meta: + db_table = u'repute' + +class Activity(models.Model): + """ + We keep some history data for user activities + """ + user = models.ForeignKey(User) + activity_type = models.SmallIntegerField(choices=TYPE_ACTIVITY) + active_at = models.DateTimeField(default=datetime.datetime.now) + content_type = models.ForeignKey(ContentType) + object_id = models.PositiveIntegerField() + content_object = generic.GenericForeignKey('content_type', 'object_id') + is_auditted = models.BooleanField(default=False) + + def __unicode__(self): + return u'[%s] was active at %s' % (self.user.username, self.active_at) + + class Meta: + db_table = u'activity' + +class Book(models.Model): + """ + Model for book info + """ + user = models.ForeignKey(User) + title = models.CharField(max_length=255) + short_name = models.CharField(max_length=255) + author = models.CharField(max_length=255) + price = models.DecimalField(max_digits=6, decimal_places=2) + pages = models.SmallIntegerField() + published_at = models.DateTimeField() + publication = models.CharField(max_length=255) + cover_img = models.CharField(max_length=255) + tagnames = models.CharField(max_length=125) + added_at = models.DateTimeField() + last_edited_at = models.DateTimeField() + questions = models.ManyToManyField(Question, related_name='book', db_table='book_question') + + def get_absolute_url(self): + return '%s' % reverse('book', args=[self.short_name]) + + def __unicode__(self): + return self.title + class Meta: + db_table = u'book' + +class BookAuthorInfo(models.Model): + """ + Model for book author info + """ + user = models.ForeignKey(User) + book = models.ForeignKey(Book) + blog_url = models.CharField(max_length=255) + added_at = models.DateTimeField() + last_edited_at = models.DateTimeField() + + class Meta: + db_table = u'book_author_info' + +class BookAuthorRss(models.Model): + """ + Model for book author blog rss + """ + user = models.ForeignKey(User) + book = models.ForeignKey(Book) + title = models.CharField(max_length=255) + url = models.CharField(max_length=255) + rss_created_at = models.DateTimeField() + added_at = models.DateTimeField() + + class Meta: + db_table = u'book_author_rss' + +# User extend properties +QUESTIONS_PER_PAGE_CHOICES = ( + (10, u'10'), + (30, u'30'), + (50, u'50'), +) + +User.add_to_class('reputation', models.PositiveIntegerField(default=1)) +User.add_to_class('gravatar', models.CharField(max_length=32)) +User.add_to_class('favorite_questions', + models.ManyToManyField(Question, through=FavoriteQuestion, + related_name='favorited_by')) +User.add_to_class('badges', models.ManyToManyField(Badge, through=Award, + related_name='awarded_to')) +User.add_to_class('gold', models.SmallIntegerField(default=0)) +User.add_to_class('silver', models.SmallIntegerField(default=0)) +User.add_to_class('bronze', models.SmallIntegerField(default=0)) +User.add_to_class('questions_per_page', + models.SmallIntegerField(choices=QUESTIONS_PER_PAGE_CHOICES, default=10)) +User.add_to_class('last_seen', + models.DateTimeField(default=datetime.datetime.now)) +User.add_to_class('real_name', models.CharField(max_length=100, blank=True)) +User.add_to_class('website', models.URLField(max_length=200, blank=True)) +User.add_to_class('location', models.CharField(max_length=100, blank=True)) +User.add_to_class('date_of_birth', models.DateField(null=True, blank=True)) +User.add_to_class('about', models.TextField(blank=True)) + +# custom signal +tags_updated = django.dispatch.Signal(providing_args=["question"]) +edit_question_or_answer = django.dispatch.Signal(providing_args=["instance", "modified_by"]) +delete_post_or_answer = django.dispatch.Signal(providing_args=["instance", "deleted_by"]) +mark_offensive = django.dispatch.Signal(providing_args=["instance", "mark_by"]) +user_updated = django.dispatch.Signal(providing_args=["instance", "updated_by"]) +def get_messages(self): + messages = [] + for m in self.message_set.all(): + messages.append(m.message) + return messages + +def delete_messages(self): + self.message_set.all().delete() + +def get_profile_url(self): + """Returns the URL for this User's profile.""" + return '%s%s/' % (reverse('user', args=[self.id]), self.username) +User.add_to_class('get_profile_url', get_profile_url) +User.add_to_class('get_messages', get_messages) +User.add_to_class('delete_messages', delete_messages) + +def calculate_gravatar_hash(instance, **kwargs): + """Calculates a User's gravatar hash from their email address.""" + if kwargs.get('raw', False): + return + instance.gravatar = hashlib.md5(instance.email).hexdigest() + +def record_ask_event(instance, created, **kwargs): + if created: + activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ASK_QUESTION) + activity.save() + +def record_answer_event(instance, created, **kwargs): + if created: + activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ANSWER) + activity.save() + +def record_comment_event(instance, created, **kwargs): + if created: + from django.contrib.contenttypes.models import ContentType + question_type = ContentType.objects.get_for_model(Question) + question_type_id = question_type.id + type = TYPE_ACTIVITY_COMMENT_QUESTION if instance.content_type_id == question_type_id else TYPE_ACTIVITY_COMMENT_ANSWER + activity = Activity(user=instance.user, active_at=instance.added_at, content_object=instance, activity_type=type) + activity.save() + +def record_revision_question_event(instance, created, **kwargs): + if created and instance.revision <> 1: + activity = Activity(user=instance.author, active_at=instance.revised_at, content_object=instance, activity_type=TYPE_ACTIVITY_UPDATE_QUESTION) + activity.save() + +def record_revision_answer_event(instance, created, **kwargs): + if created and instance.revision <> 1: + activity = Activity(user=instance.author, active_at=instance.revised_at, content_object=instance, activity_type=TYPE_ACTIVITY_UPDATE_ANSWER) + activity.save() + +def record_award_event(instance, created, **kwargs): + """ + After we awarded a badge to user, we need to record this activity and notify user. + We also recaculate awarded_count of this badge and user information. + """ + if created: + activity = Activity(user=instance.user, active_at=instance.awarded_at, content_object=instance, + activity_type=TYPE_ACTIVITY_PRIZE) + activity.save() + + instance.badge.awarded_count += 1 + instance.badge.save() + + if instance.badge.type == Badge.GOLD: + instance.user.gold += 1 + if instance.badge.type == Badge.SILVER: + instance.user.silver += 1 + if instance.badge.type == Badge.BRONZE: + instance.user.bronze += 1 + instance.user.save() + +def notify_award_message(instance, created, **kwargs): + """ + Notify users when they have been awarded badges by using Django message. + """ + if created: + user = instance.user + user.message_set.create(message=u"%s" % instance.badge.name) + +def record_answer_accepted(instance, created, **kwargs): + """ + when answer is accepted, we record this for question author - who accepted it. + """ + if not created and instance.accepted: + activity = Activity(user=instance.question.author, active_at=datetime.datetime.now(), \ + content_object=instance, activity_type=TYPE_ACTIVITY_MARK_ANSWER) + activity.save() + +def update_last_seen(instance, created, **kwargs): + """ + when user has activities, we update 'last_seen' time stamp for him + """ + user = instance.user + user.last_seen = datetime.datetime.now() + user.save() + +def record_vote(instance, created, **kwargs): + """ + when user have voted + """ + if created: + if instance.vote == 1: + vote_type = TYPE_ACTIVITY_VOTE_UP + else: + vote_type = TYPE_ACTIVITY_VOTE_DOWN + + activity = Activity(user=instance.user, active_at=instance.voted_at, content_object=instance, activity_type=vote_type) + activity.save() + +def record_cancel_vote(instance, **kwargs): + """ + when user canceled vote, the vote will be deleted. + """ + activity = Activity(user=instance.user, active_at=datetime.datetime.now(), content_object=instance, activity_type=TYPE_ACTIVITY_CANCEL_VOTE) + activity.save() + +def record_delete_question(instance, delete_by, **kwargs): + """ + when user deleted the question + """ + if instance.__class__ == "Question": + activity_type = TYPE_ACTIVITY_DELETE_QUESTION + else: + activity_type = TYPE_ACTIVITY_DELETE_ANSWER + + activity = Activity(user=delete_by, active_at=datetime.datetime.now(), content_object=instance, activity_type=activity_type) + activity.save() + +def record_mark_offensive(instance, mark_by, **kwargs): + activity = Activity(user=mark_by, active_at=datetime.datetime.now(), content_object=instance, activity_type=TYPE_ACTIVITY_MARK_OFFENSIVE) + activity.save() + +def record_update_tags(question, **kwargs): + """ + when user updated tags of the question + """ + activity = Activity(user=question.author, active_at=datetime.datetime.now(), content_object=question, activity_type=TYPE_ACTIVITY_UPDATE_TAGS) + activity.save() + +def record_favorite_question(instance, created, **kwargs): + """ + when user add the question in him favorite questions list. + """ + if created: + activity = Activity(user=instance.user, active_at=datetime.datetime.now(), content_object=instance, activity_type=TYPE_ACTIVITY_FAVORITE) + activity.save() + +def record_user_full_updated(instance, **kwargs): + activity = Activity(user=instance, active_at=datetime.datetime.now(), content_object=instance, activity_type=TYPE_ACTIVITY_USER_FULL_UPDATED) + activity.save() + +#signal for User modle save changes +pre_save.connect(calculate_gravatar_hash, sender=User) +post_save.connect(record_ask_event, sender=Question) +post_save.connect(record_answer_event, sender=Answer) +post_save.connect(record_comment_event, sender=Comment) +post_save.connect(record_revision_question_event, sender=QuestionRevision) +post_save.connect(record_revision_answer_event, sender=AnswerRevision) +post_save.connect(record_award_event, sender=Award) +post_save.connect(notify_award_message, sender=Award) +post_save.connect(record_answer_accepted, sender=Answer) +post_save.connect(update_last_seen, sender=Activity) +post_save.connect(record_vote, sender=Vote) +post_delete.connect(record_cancel_vote, sender=Vote) +delete_post_or_answer.connect(record_delete_question, sender=Question) +delete_post_or_answer.connect(record_delete_question, sender=Answer) +mark_offensive.connect(record_mark_offensive, sender=Question) +mark_offensive.connect(record_mark_offensive, sender=Answer) +tags_updated.connect(record_update_tags, sender=Question) +post_save.connect(record_favorite_question, sender=FavoriteQuestion) +user_updated.connect(record_user_full_updated, sender=User) \ No newline at end of file diff --git a/forum/templatetags/__init__.py b/forum/templatetags/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/forum/templatetags/extra_filters.py b/forum/templatetags/extra_filters.py new file mode 100644 index 0000000000..744fa7624e --- /dev/null +++ b/forum/templatetags/extra_filters.py @@ -0,0 +1,83 @@ +锘縡rom django import template +from forum import auth + +register = template.Library() + +@register.filter +def can_vote_up(user): + return auth.can_vote_up(user) + +@register.filter +def can_flag_offensive(user): + return auth.can_flag_offensive(user) + +@register.filter +def can_add_comments(user): + return auth.can_add_comments(user) + +@register.filter +def can_vote_down(user): + return auth.can_vote_down(user) + +@register.filter +def can_retag_questions(user): + return auth.can_retag_questions(user) + +@register.filter +def can_edit_post(user, post): + return auth.can_edit_post(user, post) + +@register.filter +def can_delete_comment(user, comment): + return auth.can_delete_comment(user, comment) + +@register.filter +def can_view_offensive_flags(user): + return auth.can_view_offensive_flags(user) + +@register.filter +def can_close_question(user, question): + return auth.can_close_question(user, question) + +@register.filter +def can_lock_posts(user): + return auth.can_lock_posts(user) + +@register.filter +def can_accept_answer(user, question, answer): + return auth.can_accept_answer(user, question, answer) + +@register.filter +def can_reopen_question(user, question): + return auth.can_reopen_question(user, question) + +@register.filter +def can_delete_post(user, post): + return auth.can_delete_post(user, post) + +@register.filter +def can_view_user_edit(request_user, target_user): + return auth.can_view_user_edit(request_user, target_user) + +@register.filter +def can_view_user_votes(request_user, target_user): + return auth.can_view_user_votes(request_user, target_user) + +@register.filter +def can_view_user_preferences(request_user, target_user): + return auth.can_view_user_preferences(request_user, target_user) + +@register.filter +def is_user_self(request_user, target_user): + return auth.is_user_self(request_user, target_user) + +@register.filter +def cnprog_intword(number): + try: + if 1000 <= number < 10000: + string = str(number)[0:1] + return "%sk" % string + else: + return number + except: + return number \ No newline at end of file diff --git a/forum/templatetags/extra_tags.py b/forum/templatetags/extra_tags.py new file mode 100644 index 0000000000..7c53c2cba7 --- /dev/null +++ b/forum/templatetags/extra_tags.py @@ -0,0 +1,232 @@ +锘縤mport time +import datetime +import math +import re +import logging +from django import template +from django.utils.encoding import smart_unicode +from django.utils.safestring import mark_safe +from django.utils.timesince import timesince +from forum.const import * + +register = template.Library() + +GRAVATAR_TEMPLATE = ('') + +@register.simple_tag +def gravatar(user, size): + """ + Creates an ```` for a user's Gravatar with a given size. + + This tag can accept a User object, or a dict containing the + appropriate values. + """ + try: + gravatar = user['gravatar'] + except (TypeError, AttributeError, KeyError): + gravatar = user.gravatar + return mark_safe(GRAVATAR_TEMPLATE % { + 'size': size, + 'gravatar_hash': gravatar, + }) + +MAX_FONTSIZE = 18 +MIN_FONTSIZE = 12 +@register.simple_tag +def tag_font_size(max_size, min_size, current_size): + """ + do a logarithmic mapping calcuation for a proper size for tagging cloud + Algorithm from http://blogs.dekoh.com/dev/2007/10/29/choosing-a-good-font-size-variation-algorithm-for-your-tag-cloud/ + """ + #avoid invalid calculation + if current_size == 0: + current_size = 1 + try: + weight = (math.log10(current_size) - math.log10(min_size)) / (math.log10(max_size) - math.log10(min_size)) + except: + weight = 0 + return MIN_FONTSIZE + round((MAX_FONTSIZE - MIN_FONTSIZE) * weight) + + +LEADING_PAGE_RANGE_DISPLAYED = TRAILING_PAGE_RANGE_DISPLAYED = 5 +LEADING_PAGE_RANGE = TRAILING_PAGE_RANGE = 4 +NUM_PAGES_OUTSIDE_RANGE = 1 +ADJACENT_PAGES = 2 +@register.inclusion_tag("paginator.html") +def cnprog_paginator(context): + """ + custom paginator tag + Inspired from http://blog.localkinegrinds.com/2007/09/06/digg-style-pagination-in-django/ + """ + if (context["is_paginated"]): + " Initialize variables " + in_leading_range = in_trailing_range = False + pages_outside_leading_range = pages_outside_trailing_range = range(0) + + if (context["pages"] <= LEADING_PAGE_RANGE_DISPLAYED): + in_leading_range = in_trailing_range = True + page_numbers = [n for n in range(1, context["pages"] + 1) if n > 0 and n <= context["pages"]] + elif (context["page"] <= LEADING_PAGE_RANGE): + in_leading_range = True + page_numbers = [n for n in range(1, LEADING_PAGE_RANGE_DISPLAYED + 1) if n > 0 and n <= context["pages"]] + pages_outside_leading_range = [n + context["pages"] for n in range(0, -NUM_PAGES_OUTSIDE_RANGE, -1)] + elif (context["page"] > context["pages"] - TRAILING_PAGE_RANGE): + in_trailing_range = True + page_numbers = [n for n in range(context["pages"] - TRAILING_PAGE_RANGE_DISPLAYED + 1, context["pages"] + 1) if n > 0 and n <= context["pages"]] + pages_outside_trailing_range = [n + 1 for n in range(0, NUM_PAGES_OUTSIDE_RANGE)] + else: + page_numbers = [n for n in range(context["page"] - ADJACENT_PAGES, context["page"] + ADJACENT_PAGES + 1) if n > 0 and n <= context["pages"]] + pages_outside_leading_range = [n + context["pages"] for n in range(0, -NUM_PAGES_OUTSIDE_RANGE, -1)] + pages_outside_trailing_range = [n + 1 for n in range(0, NUM_PAGES_OUTSIDE_RANGE)] + + extend_url = context.get('extend_url', '') + return { + "base_url": context["base_url"], + "is_paginated": context["is_paginated"], + "previous": context["previous"], + "has_previous": context["has_previous"], + "next": context["next"], + "has_next": context["has_next"], + "page": context["page"], + "pages": context["pages"], + "page_numbers": page_numbers, + "in_leading_range" : in_leading_range, + "in_trailing_range" : in_trailing_range, + "pages_outside_leading_range": pages_outside_leading_range, + "pages_outside_trailing_range": pages_outside_trailing_range, + "extend_url" : extend_url + } + +@register.inclusion_tag("pagesize.html") +def cnprog_pagesize(context): + """ + display the pagesize selection boxes for paginator + """ + if (context["is_paginated"]): + return { + "base_url": context["base_url"], + "pagesize" : context["pagesize"], + "is_paginated": context["is_paginated"] + } + +@register.simple_tag +def get_score_badge(user): + BADGE_TEMPLATE = '%(reputation)s' + if user.gold > 0 : + BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, ' ' + '' + '%(gold)s' + '') + if user.silver > 0: + BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, ' ' + '' + '%(silver)s' + '') + if user.bronze > 0: + BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, ' ' + '' + '%(bronze)s' + '') + BADGE_TEMPLATE = smart_unicode(BADGE_TEMPLATE, encoding='utf-8', strings_only=False, errors='strict') + return mark_safe(BADGE_TEMPLATE % { + 'reputation' : user.reputation, + 'gold' : user.gold, + 'silver' : user.silver, + 'bronze' : user.bronze, + }) + +@register.simple_tag +def get_score_badge_by_details(rep, gold, silver, bronze): + BADGE_TEMPLATE = '%(reputation)s' + if gold > 0 : + BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '' + '' + '%(gold)s' + '') + if silver > 0: + BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '' + '' + '%(silver)s' + '') + if bronze > 0: + BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '' + '' + '%(bronze)s' + '') + BADGE_TEMPLATE = smart_unicode(BADGE_TEMPLATE, encoding='utf-8', strings_only=False, errors='strict') + return mark_safe(BADGE_TEMPLATE % { + 'reputation' : rep, + 'gold' : gold, + 'silver' : silver, + 'bronze' : bronze, + }) + +@register.simple_tag +def get_user_vote_image(dic, key, arrow): + if dic.has_key(key): + if int(dic[key]) == int(arrow): + return '-on' + return '' + +@register.simple_tag +def get_age(birthday): + current_time = datetime.datetime(*time.localtime()[0:6]) + diff = current_time - birthday + return diff.days / 365 + +@register.simple_tag +def get_total_count(up_count, down_count): + return up_count + down_count + +@register.simple_tag +def format_number(value): + strValue = str(value) + if len(strValue) <= 3: + return strValue + result = '' + first = '' + pattern = re.compile('(-?\d+)(\d{3})') + m = re.match(pattern, strValue) + while m != None: + first = m.group(1) + second = m.group(2) + result = ',' + second + result + strValue = first + ',' + second + m = re.match(pattern, strValue) + return first + result + +@register.simple_tag +def convert2tagname_list(question): + question['tagnames'] = [name for name in question['tagnames'].split(u' ')] + return '' + +@register.simple_tag +def diff_date(date, limen=2): + current_time = datetime.datetime(*time.localtime()[0:6]) + diff = current_time - date + diff_days = diff.days + if diff_days > limen: + return date + else: + return timesince(date) + u'鍓' + +@register.simple_tag +def get_latest_changed_timestamp(): + try: + from time import localtime, strftime + from os import path + from django.conf import settings + root = settings.SITE_SRC_ROOT + dir = ( + root, + '%s/forum' % root, + '%s/templates' % root, + ) + stamp = (path.getmtime(d) for d in dir) + latest = max(stamp) + timestr = strftime("%H:%M %b-%d-%Y %Z", localtime(latest)) + except: + timestr = '' + return timestr \ No newline at end of file diff --git a/forum/user.py b/forum/user.py new file mode 100644 index 0000000000..7afe1c36ef --- /dev/null +++ b/forum/user.py @@ -0,0 +1,74 @@ +锘# coding=utf-8 +class UserView: + def __init__(self, id, tab_title, tab_description, page_title, view_name, template_file, data_size=0): + self.id = id + self.tab_title = tab_title + self.tab_description = tab_description + self.page_title = page_title + self.view_name = view_name + self.template_file = template_file + self.data_size = data_size + + +USER_TEMPLATE_VIEWS = ( + UserView( + id = 'stats', + tab_title = u'姒傝', + tab_description = u'鐢ㄦ埛姒傝', + page_title = u'姒傝-鐢ㄦ埛璧勬枡', + view_name = 'user_stats', + template_file = 'user_stats.html' + ), + UserView( + id = 'recent', + tab_title = u'鏈杩戞椿鍔', + tab_description = u'鐢ㄦ埛鏈杩戠殑娲诲姩鐘跺喌', + page_title = u'鏈杩戞椿鍔 - 鐢ㄦ埛璧勬枡', + view_name = 'user_recent', + template_file = 'user_recent.html', + data_size = 50 + ), + UserView( + id = 'responses', + tab_title = u'鍥炲簲', + tab_description = u'鍏朵粬鐢ㄦ埛鐨勫洖澶嶅拰璇勮', + page_title = u'鍥炲簲 - 鐢ㄦ埛璧勬枡', + view_name = 'user_responses', + template_file = 'user_responses.html', + data_size = 50 + ), + UserView( + id = 'reputation', + tab_title = u'绉垎', + tab_description = u'鐢ㄦ埛绀惧尯绉垎', + page_title = u'绉垎 - 鐢ㄦ埛璧勬枡', + view_name = 'user_reputation', + template_file = 'user_reputation.html' + ), + UserView( + id = 'favorites', + tab_title = u'鏀惰棌', + tab_description = u'鐢ㄦ埛鏀惰棌鐨勯棶棰', + page_title = u'鏀惰棌 - 鐢ㄦ埛璧勬枡', + view_name = 'user_favorites', + template_file = 'user_favorites.html', + data_size = 50 + ), + UserView( + id = 'votes', + tab_title = u'鎶曠エ', + tab_description = u'鐢ㄦ埛鎵鏈夋姇绁', + page_title = u'鎶曠エ - 鐢ㄦ埛璧勬枡', + view_name = 'user_votes', + template_file = 'user_votes.html', + data_size = 50 + ), + UserView( + id = 'preferences', + tab_title = u'璁剧疆', + tab_description = u'鐢ㄦ埛鍙傛暟璁剧疆', + page_title = u'璁剧疆 - 鐢ㄦ埛璧勬枡', + view_name = 'user_preferences', + template_file = 'user_preferences.html' + ) +) \ No newline at end of file diff --git a/forum/views.py b/forum/views.py new file mode 100644 index 0000000000..49ad6c1992 --- /dev/null +++ b/forum/views.py @@ -0,0 +1,1945 @@ +# encoding:utf-8 +import os.path +import time, datetime, calendar, random +import logging +from urllib import quote, unquote +from django.conf import settings +from django.core.files.storage import default_storage +from django.shortcuts import render_to_response, get_object_or_404 +from django.contrib.auth.decorators import login_required +from django.http import HttpResponseRedirect, HttpResponse,Http404 +from django.core.paginator import Paginator, EmptyPage, InvalidPage +from django.template import RequestContext +from django.utils.html import * +from django.utils import simplejson +from django.core import serializers +from django.db import transaction +from django.contrib.contenttypes.models import ContentType + +from utils.html import sanitize_html +from markdown2 import Markdown +#from lxml.html.diff import htmldiff +from forum.diff import textDiff as htmldiff +from forum.forms import * +from forum.models import * +from forum.auth import * +from forum.const import * +from forum.user import * +from forum import auth + +# used in index page +INDEX_PAGE_SIZE = 20 +INDEX_AWARD_SIZE = 15 +INDEX_TAGS_SIZE = 100 +# used in tags list +DEFAULT_PAGE_SIZE = 60 +# used in questions +QUESTIONS_PAGE_SIZE = 10 +# used in users +USERS_PAGE_SIZE = 35 +# used in answers +ANSWERS_PAGE_SIZE = 10 +markdowner = Markdown(html4tags=True) +question_type = ContentType.objects.get_for_model(Question) +answer_type = ContentType.objects.get_for_model(Answer) +comment_type = ContentType.objects.get_for_model(Comment) +question_revision_type = ContentType.objects.get_for_model(QuestionRevision) +answer_revision_type = ContentType.objects.get_for_model(AnswerRevision) +repute_type =ContentType.objects.get_for_model(Repute) +question_type_id = question_type.id +answer_type_id = answer_type.id +comment_type_id = comment_type.id +question_revision_type_id = question_revision_type.id +answer_revision_type_id = answer_revision_type.id +repute_type_id = repute_type.id +def _get_tags_cache_json(): + tags = Tag.objects.filter(deleted=False).all() + tags_list = [] + for tag in tags: + dic = {'n': tag.name, 'c': tag.used_count } + tags_list.append(dic) + tags = simplejson.dumps(tags_list) + return tags + +def index(request): + view_id = request.GET.get('sort', None) + view_dic = { + "latest":"-last_activity_at", + "hottest":"-answer_count", + "mostvoted":"-score", + "trans": "-last_activity_at" + } + try: + orderby = view_dic[view_id] + except KeyError: + view_id = "latest" + orderby = "-last_activity_at" + # group questions by author_id of 28,29 + if view_id == 'trans': + questions = Question.objects.get_translation_questions(orderby, INDEX_PAGE_SIZE) + else: + questions = Question.objects.get_questions_by_pagesize(orderby, INDEX_PAGE_SIZE) + # RISK - inner join queries + questions = questions.select_related() + tags = Tag.objects.get_valid_tags(INDEX_TAGS_SIZE) + + awards = Award.objects.get_recent_awards() + + return render_to_response('index.html', { + "questions" : questions, + "tab_id" : view_id, + "tags" : tags, + "awards" : awards[:INDEX_AWARD_SIZE], + }, context_instance=RequestContext(request)) + +def about(request): + return render_to_response('about.html', context_instance=RequestContext(request)) + +def faq(request): + return render_to_response('faq.html', context_instance=RequestContext(request)) + +def privacy(request): + return render_to_response('privacy.html', context_instance=RequestContext(request)) + +def unanswered(request): + return questions(request, unanswered=True) + +def questions(request, tagname=None, unanswered=False): + """ + List of Questions, Tagged questions, and Unanswered questions. + """ + # template file + # "questions.html" or "unanswered.html" + template_file = "questions.html" + # Set flag to False by default. If it is equal to True, then need to be saved. + pagesize_changed = False + # get pagesize from session, if failed then get default value + pagesize = request.session.get("pagesize") + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + + view_id = request.GET.get('sort', None) + view_dic = {"latest":"-added_at", "active":"-last_activity_at", "hottest":"-answer_count", "mostvoted":"-score" } + try: + orderby = view_dic[view_id] + except KeyError: + view_id = "latest" + orderby = "-added_at" + + # check if request is from tagged questions + if tagname is not None: + objects = Question.objects.get_questions_by_tag(tagname, orderby) + elif unanswered: + #check if request is from unanswered questions + template_file = "unanswered.html" + objects = Question.objects.get_unanswered_questions(orderby) + else: + objects = Question.objects.get_questions(orderby) + + # RISK - inner join queries + objects = objects.select_related(depth=1); + objects_list = Paginator(objects, pagesize) + questions = objects_list.page(page) + + # Get related tags from this page objects + related_tags = Tag.objects.get_tags_by_questions(questions.object_list) + + return render_to_response(template_file, { + "questions" : questions, + "tab_id" : view_id, + "questions_count" : objects_list.count, + "tags" : related_tags, + "searchtag" : tagname, + "is_unanswered" : unanswered, + "context" : { + 'is_paginated' : True, + 'pages': objects_list.num_pages, + 'page': page, + 'has_previous': questions.has_previous(), + 'has_next': questions.has_next(), + 'previous': questions.previous_page_number(), + 'next': questions.next_page_number(), + 'base_url' : request.path + '?sort=%s&' % view_id, + 'pagesize' : pagesize + }}, context_instance=RequestContext(request)) + +#TODO: allow anynomus user to ask question by providing email and username. +@login_required +def ask(request): + if request.method == "POST": + form = AskForm(request.POST) + if form.is_valid(): + added_at = datetime.datetime.now() + html = sanitize_html(markdowner.convert(form.cleaned_data['text'])) + question = Question( + title = strip_tags(form.cleaned_data['title']), + author = request.user, + added_at = added_at, + last_activity_at = added_at, + last_activity_by = request.user, + wiki = form.cleaned_data['wiki'], + tagnames = form.cleaned_data['tags'].strip(), + html = html, + summary = strip_tags(html)[:120] + ) + if question.wiki: + question.last_edited_by = question.author + question.last_edited_at = added_at + question.wikified_at = added_at + + question.save() + + # create the first revision + QuestionRevision.objects.create( + question = question, + revision = 1, + title = question.title, + author = request.user, + revised_at = added_at, + tagnames = question.tagnames, + summary = CONST['default_version'], + text = form.cleaned_data['text'] + ) + + return HttpResponseRedirect(question.get_absolute_url()) + + else: + form = AskForm() + + tags = _get_tags_cache_json() + return render_to_response('ask.html', { + 'form' : form, + 'tags' : tags, + }, context_instance=RequestContext(request)) + +def question(request, id): + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + view_id = request.GET.get('sort', 'votes') + view_dic = {"latest":"-added_at", "oldest":"added_at", "votes":"-score" } + try: + orderby = view_dic[view_id] + except KeyError: + view_id = "votes" + orderby = "-score" + + question = get_object_or_404(Question, id=id) + if question.deleted and not can_view_deleted_post(request.user, question): + raise Http404 + answer_form = AnswerForm(question) + answers = Answer.objects.get_answers_from_question(question, request.user) + answers = answers.select_related(depth=1) + + favorited = question.has_favorite_by_user(request.user) + question_vote = question.votes.select_related().filter(user=request.user) + if question_vote is not None and question_vote.count() > 0: + question_vote = question_vote[0] + + user_answer_votes = {} + for answer in answers: + vote = answer.get_user_vote(request.user) + if vote is not None and not user_answer_votes.has_key(answer.id): + vote_value = -1 + if vote.is_upvote(): + vote_value = 1 + user_answer_votes[answer.id] = vote_value + + + if answers is not None: + answers = answers.order_by("-accepted", orderby) + objects_list = Paginator(answers, ANSWERS_PAGE_SIZE) + page_objects = objects_list.page(page) + # update view count + Question.objects.update_view_count(question) + return render_to_response('question.html', { + "question" : question, + "question_vote" : question_vote, + "question_comment_count":question.comments.count(), + "answer" : answer_form, + "answers" : page_objects.object_list, + "user_answer_votes": user_answer_votes, + "tags" : question.tags.all(), + "tab_id" : view_id, + "favorited" : favorited, + "similar_questions" : Question.objects.get_similar_questions(question), + "context" : { + 'is_paginated' : True, + 'pages': objects_list.num_pages, + 'page': page, + 'has_previous': page_objects.has_previous(), + 'has_next': page_objects.has_next(), + 'previous': page_objects.previous_page_number(), + 'next': page_objects.next_page_number(), + 'base_url' : request.path + '?sort=%s&' % view_id, + 'extend_url' : "#sort-top" + } + }, context_instance=RequestContext(request)) + +@login_required +def close(request, id): + question = get_object_or_404(Question, id=id) + if not can_close_question(request.user, question): + return HttpResponse('Permission denied.') + if request.method == 'POST': + form = CloseForm(request.POST) + if form.is_valid(): + reason = form.cleaned_data['reason'] + question.closed = True + question.closed_by = request.user + question.closed_at = datetime.datetime.now() + question.close_reason = reason + question.save() + return HttpResponseRedirect(question.get_absolute_url()) + else: + form = CloseForm() + return render_to_response('close.html', { + 'form' : form, + 'question' : question, + }, context_instance=RequestContext(request)) + +@login_required +def reopen(request, id): + question = get_object_or_404(Question, id=id) + # open question + if not can_reopen_question(request.user, question): + return HttpResponse('Permission denied.') + if request.method == 'POST' : + Question.objects.filter(id=question.id).update(closed=False, + closed_by=None, closed_at=None, close_reason=None) + return HttpResponseRedirect(question.get_absolute_url()) + else: + return render_to_response('reopen.html', { + 'question' : question, + }, context_instance=RequestContext(request)) + +@login_required +def edit_question(request, id): + question = get_object_or_404(Question, id=id) + if question.deleted and not can_view_deleted_post(request.user, question): + raise Http404 + if can_edit_post(request.user, question): + return _edit_question(request, question) + elif can_retag_questions(request.user): + return _retag_question(request, question) + else: + raise Http404 + +def _retag_question(request, question): + if request.method == 'POST': + form = RetagQuestionForm(question, request.POST) + if form.is_valid(): + if form.has_changed(): + latest_revision = question.get_latest_revision() + retagged_at = datetime.datetime.now() + # Update the Question itself + Question.objects.filter(id=question.id).update( + tagnames = form.cleaned_data['tags'], + last_edited_at = retagged_at, + last_edited_by = request.user, + last_activity_at = retagged_at, + last_activity_by = request.user + ) + # Update the Question's tag associations + tags_updated = Question.objects.update_tags(question, + form.cleaned_data['tags'], request.user) + # Create a new revision + QuestionRevision.objects.create( + question = question, + title = latest_revision.title, + author = request.user, + revised_at = retagged_at, + tagnames = form.cleaned_data['tags'], + summary = CONST['retagged'], + text = latest_revision.text + ) + # send tags updated singal + tags_updated.send(sender=question.__class__, question=question) + + return HttpResponseRedirect(question.get_absolute_url()) + else: + form = RetagQuestionForm(question) + return render_to_response('question_retag.html', { + 'question': question, + 'form' : form, + 'tags' : _get_tags_cache_json(), + }, context_instance=RequestContext(request)) + + +def _edit_question(request, question): + latest_revision = question.get_latest_revision() + revision_form = None + if request.method == 'POST': + if 'select_revision' in request.POST: + # user has changed revistion number + revision_form = RevisionForm(question, latest_revision, request.POST) + if revision_form.is_valid(): + # Replace with those from the selected revision + form = EditQuestionForm(question, + QuestionRevision.objects.get(question=question, + revision=revision_form.cleaned_data['revision'])) + else: + form = EditQuestionForm(question, latest_revision, request.POST) + else: + # Always check modifications against the latest revision + form = EditQuestionForm(question, latest_revision, request.POST) + if form.is_valid(): + html = sanitize_html(markdowner.convert(form.cleaned_data['text'])) + if form.has_changed(): + edited_at = datetime.datetime.now() + tags_changed = (latest_revision.tagnames != + form.cleaned_data['tags']) + tags_updated = False + # Update the Question itself + updated_fields = { + 'title': form.cleaned_data['title'], + 'last_edited_at': edited_at, + 'last_edited_by': request.user, + 'last_activity_at': edited_at, + 'last_activity_by': request.user, + 'tagnames': form.cleaned_data['tags'], + 'summary': strip_tags(html)[:120], + 'html': html, + } + + # only save when it's checked + # because wiki doesn't allow to be edited if last version has been enabled already + # and we make sure this in forms. + if ('wiki' in form.cleaned_data and + form.cleaned_data['wiki']): + updated_fields['wiki'] = True + updated_fields['wikified_at'] = edited_at + + Question.objects.filter( + id=question.id).update(**updated_fields) + # Update the Question's tag associations + if tags_changed: + tags_updated = Question.objects.update_tags( + question, form.cleaned_data['tags'], request.user) + # Create a new revision + revision = QuestionRevision( + question = question, + title = form.cleaned_data['title'], + author = request.user, + revised_at = edited_at, + tagnames = form.cleaned_data['tags'], + text = form.cleaned_data['text'], + ) + if form.cleaned_data['summary']: + revision.summary = form.cleaned_data['summary'] + else: + revision.summary = 'No.%s Revision' % latest_revision.revision + revision.save() + + return HttpResponseRedirect(question.get_absolute_url()) + else: + + revision_form = RevisionForm(question, latest_revision) + form = EditQuestionForm(question, latest_revision) + return render_to_response('question_edit.html', { + 'question': question, + 'revision_form': revision_form, + 'form' : form, + 'tags' : _get_tags_cache_json() + }, context_instance=RequestContext(request)) + + +@login_required +def edit_answer(request, id): + answer = get_object_or_404(Answer, id=id) + if answer.deleted and not can_view_deleted_post(request.user, answer): + raise Http404 + elif not can_edit_post(request.user, answer): + raise Http404 + else: + latest_revision = answer.get_latest_revision() + if request.method == "POST": + if 'select_revision' in request.POST: + # user has changed revistion number + revision_form = RevisionForm(answer, latest_revision, request.POST) + if revision_form.is_valid(): + # Replace with those from the selected revision + form = EditAnswerForm(answer, + AnswerRevision.objects.get(answer=answer, + revision=revision_form.cleaned_data['revision'])) + else: + form = EditAnswerForm(answer, latest_revision, request.POST) + else: + form = EditAnswerForm(answer, latest_revision, request.POST) + if form.is_valid(): + html = sanitize_html(markdowner.convert(form.cleaned_data['text'])) + if form.has_changed(): + edited_at = datetime.datetime.now() + updated_fields = { + 'last_edited_at': edited_at, + 'last_edited_by': request.user, + 'html': html, + } + Answer.objects.filter(id=answer.id).update(**updated_fields) + + revision = AnswerRevision( + answer = answer, + author = request.user, + revised_at = edited_at, + text = form.cleaned_data['text'] + ) + + if form.cleaned_data['summary']: + revision.summary = form.cleaned_data['summary'] + else: + revision.summary = 'No.%s Revision' % latest_revision.revision + revision.save() + + answer.question.last_activity_at = edited_at + answer.question.last_activity_by = request.user + answer.question.save() + + return HttpResponseRedirect(answer.get_absolute_url()) + else: + revision_form = RevisionForm(answer, latest_revision) + form = EditAnswerForm(answer, latest_revision) + return render_to_response('answer_edit.html', { + 'answer': answer, + 'revision_form': revision_form, + 'form' : form, + }, context_instance=RequestContext(request)) + +QUESTION_REVISION_TEMPLATE = ('

%(title)s

\n' + '
%(html)s
\n' + '
%(tags)s
') +def question_revisions(request, id): + post = get_object_or_404(Question, id=id) + revisions = list(post.revisions.all()) + for i, revision in enumerate(revisions): + revision.html = QUESTION_REVISION_TEMPLATE % { + 'title': revision.title, + 'html': sanitize_html(markdowner.convert(revision.text)), + 'tags': ' '.join(['' % tag + for tag in revision.tagnames.split(' ')]), + } + if i > 0: + revisions[i - 1].diff = htmldiff(revision.html, + revisions[i - 1].html) + else: + revisions[i - 1].diff = QUESTION_REVISION_TEMPLATE % { + 'title': revisions[0].title, + 'html': sanitize_html(markdowner.convert(revisions[0].text)), + 'tags': ' '.join(['' % tag + for tag in revisions[0].tagnames.split(' ')]), + } + revisions[i - 1].summary = None + return render_to_response('revisions_question.html', { + 'post': post, + 'revisions': revisions, + }, context_instance=RequestContext(request)) + +ANSWER_REVISION_TEMPLATE = ('
%(html)s
') +def answer_revisions(request, id): + post = get_object_or_404(Answer, id=id) + revisions = list(post.revisions.all()) + for i, revision in enumerate(revisions): + revision.html = ANSWER_REVISION_TEMPLATE % { + 'html': sanitize_html(markdowner.convert(revision.text)) + } + if i > 0: + revisions[i - 1].diff = htmldiff(revision.html, + revisions[i - 1].html) + else: + revisions[i - 1].diff = revisions[i-1].text + revisions[i - 1].summary = None + return render_to_response('revisions_answer.html', { + 'post': post, + 'revisions': revisions, + }, context_instance=RequestContext(request)) + +#TODO: allow anynomus +@login_required +def answer(request, id): + question = get_object_or_404(Question, id=id) + if request.method == "POST": + form = AnswerForm(question, request.POST) + if form.is_valid(): + update_time = datetime.datetime.now() + answer = Answer( + question = question, + author = request.user, + added_at = update_time, + wiki = form.cleaned_data['wiki'], + html = sanitize_html(markdowner.convert(form.cleaned_data['text'])), + ) + if answer.wiki: + answer.last_edited_by = answer.author + answer.last_edited_at = update_time + answer.wikified_at = update_time + + answer.save() + Question.objects.update_answer_count(question) + + question = get_object_or_404(Question, id=id) + question.last_activity_at = update_time + question.last_activity_by = request.user + question.save() + + AnswerRevision.objects.create( + answer = answer, + revision = 1, + author = request.user, + revised_at = update_time, + summary = CONST['default_version'], + text = form.cleaned_data['text'] + ) + + return HttpResponseRedirect(question.get_absolute_url()) + +def tags(request): + stag = "" + is_paginated = True + sortby = request.GET.get('sort', 'used') + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + + if request.method == "GET": + stag = request.GET.get("q", "").strip() + if stag is not None: + objects_list = Paginator(Tag.objects.filter(deleted=False).exclude(used_count=0).extra(where=['name like %s'], params=['%' + stag + '%']), DEFAULT_PAGE_SIZE) + else: + if sortby == "name": + objects_list = Paginator(Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by("name"), DEFAULT_PAGE_SIZE) + else: + objects_list = Paginator(Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by("-used_count"), DEFAULT_PAGE_SIZE) + + try: + tags = objects_list.page(page) + except (EmptyPage, InvalidPage): + tags = objects_list.page(objects_list.num_pages) + + return render_to_response('tags.html', { + "tags" : tags, + "stag" : stag, + "tab_id" : sortby, + "keywords" : stag, + "context" : { + 'is_paginated' : is_paginated, + 'pages': objects_list.num_pages, + 'page': page, + 'has_previous': tags.has_previous(), + 'has_next': tags.has_next(), + 'previous': tags.previous_page_number(), + 'next': tags.next_page_number(), + 'base_url' : '/tags/?sort=%s&' % sortby + } + + }, context_instance=RequestContext(request)) + +def tag(request, tag): + return questions(request, tagname=tag) + +def vote(request, id): + """ + vote_type: + acceptAnswer : 0, + questionUpVote : 1, + questionDownVote : 2, + favorite : 4, + answerUpVote: 5, + answerDownVote:6, + offensiveQuestion : 7, + offensiveAnswer:8, + removeQuestion: 9, + removeAnswer:10 + + accept answer code: + response_data['allowed'] = -1, Accept his own answer 0, no allowed - Anonymous 1, Allowed - by default + response_data['success'] = 0, failed 1, Success - by default + response_data['status'] = 0, By default 1, Answer has been accepted already(Cancel) + + vote code: + allowed = -3, Don't have enough votes left + -2, Don't have enough reputation score + -1, Vote his own post + 0, no allowed - Anonymous + 1, Allowed - by default + status = 0, By default + 1, Cancel + 2, Vote is too old to be canceled + + offensive code: + allowed = -3, Don't have enough flags left + -2, Don't have enough reputation score to do this + 0, not allowed + 1, allowed + status = 0, by default + 1, can't do it again + """ + response_data = { + "allowed": 1, + "success": 1, + "status" : 0, + "count" : 0, + "message" : '' + } + + def can_vote(vote_score, user): + if vote_score == 1: + return can_vote_up(request.user) + else: + return can_vote_down(request.user) + + try: + if not request.user.is_authenticated(): + response_data['allowed'] = 0 + response_data['success'] = 0 + + elif request.is_ajax(): + question = get_object_or_404(Question, id=id) + vote_type = request.POST.get('type') + + #accept answer + if vote_type == '0': + answer_id = request.POST.get('postId') + answer = get_object_or_404(Answer, id=answer_id) + # make sure question author is current user + if question.author == request.user: + # answer user who is also question author is not allow to accept answer + if answer.author == question.author: + response_data['success'] = 0 + response_data['allowed'] = -1 + # check if answer has been accepted already + elif answer.accepted: + onAnswerAcceptCanceled(answer, request.user) + response_data['status'] = 1 + else: + # set other answers in this question not accepted first + for answer_of_question in Answer.objects.get_answers_from_question(question, request.user): + if answer_of_question != answer and answer_of_question.accepted: + onAnswerAcceptCanceled(answer_of_question, request.user) + + #make sure retrieve data again after above author changes, they may have related data + answer = get_object_or_404(Answer, id=answer_id) + onAnswerAccept(answer, request.user) + else: + response_data['allowed'] = 0 + response_data['success'] = 0 + # favorite + elif vote_type == '4': + has_favorited = False + fav_questions = FavoriteQuestion.objects.filter(question=question) + # if the same question has been favorited before, then delete it + if fav_questions is not None: + for item in fav_questions: + if item.user == request.user: + item.delete() + response_data['status'] = 1 + response_data['count'] = len(fav_questions) - 1 + if response_data['count'] < 0: + response_data['count'] = 0 + has_favorited = True + # if above deletion has not been executed, just insert a new favorite question + if not has_favorited: + new_item = FavoriteQuestion(question=question, user=request.user) + new_item.save() + response_data['count'] = FavoriteQuestion.objects.filter(question=question).count() + Question.objects.update_favorite_count(question) + + elif vote_type in ['1', '2', '5', '6']: + post_id = id + post = question + vote_score = 1 + if vote_type in ['5', '6']: + answer_id = request.POST.get('postId') + answer = get_object_or_404(Answer, id=answer_id) + post_id = answer_id + post = answer + if vote_type in ['2', '6']: + vote_score = -1 + + if post.author == request.user: + response_data['allowed'] = -1 + elif not can_vote(vote_score, request.user): + response_data['allowed'] = -2 + elif post.votes.filter(user=request.user).count() > 0: + vote = post.votes.filter(user=request.user)[0] + # unvote should be less than certain time + if (datetime.datetime.now().day - vote.voted_at.day) >= VOTE_RULES['scope_deny_unvote_days']: + response_data['status'] = 2 + else: + voted = vote.vote + if voted > 0: + # cancel upvote + onUpVotedCanceled(vote, post, request.user) + + else: + # cancel downvote + onDownVotedCanceled(vote, post, request.user) + + response_data['status'] = 1 + response_data['count'] = post.score + elif Vote.objects.get_votes_count_today_from_user(request.user) >= VOTE_RULES['scope_votes_per_user_per_day']: + response_data['allowed'] = -3 + else: + vote = Vote(user=request.user, content_object=post, vote=vote_score, voted_at=datetime.datetime.now()) + if vote_score > 0: + # upvote + onUpVoted(vote, post, request.user) + else: + # downvote + onDownVoted(vote, post, request.user) + + votes_left = VOTE_RULES['scope_votes_per_user_per_day'] - Vote.objects.get_votes_count_today_from_user(request.user) + if votes_left <= VOTE_RULES['scope_warn_votes_left']: + response_data['message'] = u'%s votes left' % votes_left + response_data['count'] = post.score + elif vote_type in ['7', '8']: + post = question + post_id = id + if vote_type == '8': + post_id = request.POST.get('postId') + post = get_object_or_404(Answer, id=post_id) + + if FlaggedItem.objects.get_flagged_items_count_today(request.user) >= VOTE_RULES['scope_flags_per_user_per_day']: + response_data['allowed'] = -3 + elif not can_flag_offensive(request.user): + response_data['allowed'] = -2 + elif post.flagged_items.filter(user=request.user).count() > 0: + response_data['status'] = 1 + else: + item = FlaggedItem(user=request.user, content_object=post, flagged_at=datetime.datetime.now()) + onFlaggedItem(item, post, request.user) + response_data['count'] = post.offensive_flag_count + # send signal when question or answer be marked offensive + mark_offensive.send(sender=post.__class__, instance=post, mark_by=request.user) + elif vote_type in ['9', '10']: + post = question + post_id = id + if vote_type == '10': + post_id = request.POST.get('postId') + post = get_object_or_404(Answer, id=post_id) + + if not can_delete_post(request.user, post): + response_data['allowed'] = -2 + elif post.deleted: + onDeleteCanceled(post, request.user) + response_data['status'] = 1 + else: + onDeleted(post, request.user) + delete_post_or_answer.send(sender=post.__class__, instance=post, delete_by=request.user) + else: + response_data['success'] = 0 + response_data['message'] = u'Request mode is not supported. Please try again.' + + data = simplejson.dumps(response_data) + + except Exception, e: + response_data['message'] = str(e) + data = simplejson.dumps(response_data) + return HttpResponse(data, mimetype="application/json") + +def users(request): + is_paginated = True + sortby = request.GET.get('sort', 'reputation') + suser = request.REQUEST.get('q', "") + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + + if suser == "": + if sortby == "newest": + objects_list = Paginator(User.objects.all().order_by('-date_joined'), USERS_PAGE_SIZE) + elif sortby == "last": + objects_list = Paginator(User.objects.all().order_by('date_joined'), USERS_PAGE_SIZE) + elif sortby == "user": + objects_list = Paginator(User.objects.all().order_by('username'), USERS_PAGE_SIZE) + # default + else: + objects_list = Paginator(User.objects.all().order_by('-reputation'), USERS_PAGE_SIZE) + base_url = '/users/?sort=%s&' % sortby + else: + sortby = "reputation" + objects_list = Paginator(User.objects.extra(where=['username like %s'], params=['%' + suser + '%']).order_by('-reputation'), USERS_PAGE_SIZE) + base_url = '/users/?name=%s&sort=%s&' % (suser, sortby) + + try: + users = objects_list.page(page) + except (EmptyPage, InvalidPage): + users = objects_list.page(objects_list.num_pages) + + return render_to_response('users.html', { + "users" : users, + "suser" : suser, + "keywords" : suser, + "tab_id" : sortby, + "context" : { + 'is_paginated' : is_paginated, + 'pages': objects_list.num_pages, + 'page': page, + 'has_previous': users.has_previous(), + 'has_next': users.has_next(), + 'previous': users.previous_page_number(), + 'next': users.next_page_number(), + 'base_url' : base_url + } + + }, context_instance=RequestContext(request)) + +def user(request, id): + sort = request.GET.get('sort', 'stats') + user_view = dict((v.id, v) for v in USER_TEMPLATE_VIEWS).get(sort, USER_TEMPLATE_VIEWS[0]) + from forum import views + func = getattr(views, user_view.view_name) + return func(request, id, user_view) + +@login_required +def edit_user(request, id): + user = get_object_or_404(User, id=id) + if request.user != user: + raise Http404 + if request.method == "POST": + form = EditUserForm(user, request.POST) + if form.is_valid(): + user.email = sanitize_html(form.cleaned_data['email']) + user.real_name = sanitize_html(form.cleaned_data['realname']) + user.website = sanitize_html(form.cleaned_data['website']) + user.location = sanitize_html(form.cleaned_data['city']) + user.date_of_birth = sanitize_html(form.cleaned_data['birthday']) + if len(user.date_of_birth) == 0: + user.date_of_birth = '1900-01-01' + user.about = sanitize_html(form.cleaned_data['about']) + + user.save() + # send user updated singal if full fields have been updated + if user.email and user.real_name and user.website and user.location and \ + user.date_of_birth and user.about: + user_updated.send(sender=user.__class__, instance=user, updated_by=user) + return HttpResponseRedirect(user.get_profile_url()) + else: + form = EditUserForm(user) + return render_to_response('user_edit.html', { + 'form' : form, + }, context_instance=RequestContext(request)) + +def user_stats(request, user_id, user_view): + user = get_object_or_404(User, id=user_id) + questions = Question.objects.extra( + select={ + 'vote_count' : 'question.score', + 'favorited_myself' : 'SELECT count(*) FROM favorite_question f WHERE f.user_id = %s AND f.question_id = question.id', + 'la_user_id' : 'auth_user.id', + 'la_username' : 'auth_user.username', + 'la_user_gold' : 'auth_user.gold', + 'la_user_silver' : 'auth_user.silver', + 'la_user_bronze' : 'auth_user.bronze', + 'la_user_reputation' : 'auth_user.reputation' + }, + select_params=[user_id], + tables=['question', 'auth_user'], + where=['question.deleted = 0 AND question.author_id=%s AND question.last_activity_by_id = auth_user.id'], + params=[user_id], + order_by=['-vote_count', '-last_activity_at'] + ).values('vote_count', + 'favorited_myself', + 'id', + 'title', + 'author_id', + 'added_at', + 'answer_accepted', + 'answer_count', + 'comment_count', + 'view_count', + 'favourite_count', + 'summary', + 'tagnames', + 'vote_up_count', + 'vote_down_count', + 'last_activity_at', + 'la_user_id', + 'la_username', + 'la_user_gold', + 'la_user_silver', + 'la_user_bronze', + 'la_user_reputation')[:100] + + answered_questions = Question.objects.extra( + select={ + 'vote_up_count' : 'answer.vote_up_count', + 'vote_down_count' : 'answer.vote_down_count', + 'answer_id' : 'answer.id', + 'accepted' : 'answer.accepted', + 'vote_count' : 'answer.score', + 'comment_count' : 'answer.comment_count' + }, + tables=['question', 'answer'], + where=['answer.deleted=0 AND answer.author_id=%s AND answer.question_id=question.id'], + params=[user_id], + order_by=['-vote_count', '-answer_id'], + select_params=[user_id] + ).distinct().values('comment_count', + 'id', + 'answer_id', + 'title', + 'author_id', + 'accepted', + 'vote_count', + 'answer_count', + 'vote_up_count', + 'vote_down_count')[:100] + up_votes = Vote.objects.get_up_vote_count_from_user(user) + down_votes = Vote.objects.get_down_vote_count_from_user(user) + votes_today = Vote.objects.get_votes_count_today_from_user(user) + votes_total = VOTE_RULES['scope_votes_per_user_per_day'] + tags = user.created_tags.all().order_by('-used_count')[:50] + awards = Award.objects.extra( + select={'id': 'badge.id', 'count': 'count(badge_id)', 'name':'badge.name', 'description': 'badge.description', 'type': 'badge.type'}, + tables=['award', 'badge'], + order_by=['-awarded_at'], + where=['user_id=%s AND badge_id=badge.id'], + params=[user.id] + ).values('id', 'count', 'name', 'description', 'type') + total_awards = awards.count() + awards.query.group_by = ['badge_id'] + + return render_to_response(user_view.template_file,{ + "tab_name" : user_view.id, + "tab_description" : user_view.tab_description, + "page_title" : user_view.page_title, + "view_user" : user, + "questions" : questions, + "answered_questions" : answered_questions, + "up_votes" : up_votes, + "down_votes" : down_votes, + "total_votes": up_votes + down_votes, + "votes_today_left": votes_total-votes_today, + "votes_total_per_day": votes_total, + "tags" : tags, + "awards": awards, + "total_awards" : total_awards, + }, context_instance=RequestContext(request)) + +def user_recent(request, user_id, user_view): + user = get_object_or_404(User, id=user_id) + def get_type_name(type_id): + for item in TYPE_ACTIVITY: + if type_id in item: + return item[1] + + class Event: + def __init__(self, time, type, title, summary, answer_id, question_id): + self.time = time + self.type = get_type_name(type) + self.type_id = type + self.title = title + self.summary = summary + self.title_link = u'/questions/%s/%s#%s' %(question_id, title, answer_id)\ + if int(answer_id) > 0 else u'/questions/%s/%s' %(question_id, title) + class AwardEvent: + def __init__(self, time, type, id): + self.time = time + self.type = get_type_name(type) + self.type_id = type + self.badge = get_object_or_404(Badge, id=id) + + activities = [] + # ask questions + questions = Activity.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'active_at' : 'activity.active_at', + 'activity_type' : 'activity.activity_type' + }, + tables=['activity', 'question'], + where=['activity.content_type_id = %s AND activity.object_id = question.id AND \ + activity.user_id = %s AND activity.activity_type = %s'], + params=[question_type_id, user_id, TYPE_ACTIVITY_ASK_QUESTION], + order_by=['-activity.active_at'] + ).values( + 'title', + 'question_id', + 'active_at', + 'activity_type' + ) + if len(questions) > 0: + questions = [(Event(q['active_at'], q['activity_type'], q['title'], '', '0', \ + q['question_id'])) for q in questions] + activities.extend(questions) + + # answers + answers = Activity.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'answer_id' : 'answer.id', + 'active_at' : 'activity.active_at', + 'activity_type' : 'activity.activity_type' + }, + tables=['activity', 'answer', 'question'], + where=['activity.content_type_id = %s AND activity.object_id = answer.id AND \ + answer.question_id=question.id AND activity.user_id=%s AND activity.activity_type=%s'], + params=[answer_type_id, user_id, TYPE_ACTIVITY_ANSWER], + order_by=['-activity.active_at'] + ).values( + 'title', + 'question_id', + 'answer_id', + 'active_at', + 'activity_type' + ) + if len(answers) > 0: + answers = [(Event(q['active_at'], q['activity_type'], q['title'], '', q['answer_id'], \ + q['question_id'])) for q in answers] + activities.extend(answers) + + # question comments + comments = Activity.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'comment.object_id', + 'added_at' : 'comment.added_at', + 'activity_type' : 'activity.activity_type' + }, + tables=['activity', 'question', 'comment'], + + where=['activity.content_type_id = %s AND activity.object_id = comment.id AND \ + activity.user_id = comment.user_id AND comment.object_id=question.id AND \ + comment.content_type_id=%s AND activity.user_id = %s AND activity.activity_type=%s'], + params=[comment_type_id, question_type_id, user_id, TYPE_ACTIVITY_COMMENT_QUESTION], + order_by=['-comment.added_at'] + ).values( + 'title', + 'question_id', + 'added_at', + 'activity_type' + ) + + if len(comments) > 0: + comments = [(Event(q['added_at'], q['activity_type'], q['title'], '', '0', \ + q['question_id'])) for q in comments] + activities.extend(comments) + + # answer comments + comments = Activity.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'answer_id' : 'answer.id', + 'added_at' : 'comment.added_at', + 'activity_type' : 'activity.activity_type' + }, + tables=['activity', 'question', 'answer', 'comment'], + + where=['activity.content_type_id = %s AND activity.object_id = comment.id AND \ + activity.user_id = comment.user_id AND comment.object_id=answer.id AND \ + comment.content_type_id=%s AND question.id = answer.question_id AND \ + activity.user_id = %s AND activity.activity_type=%s'], + params=[comment_type_id, answer_type_id, user_id, TYPE_ACTIVITY_COMMENT_ANSWER], + order_by=['-comment.added_at'] + ).values( + 'title', + 'question_id', + 'answer_id', + 'added_at', + 'activity_type' + ) + + if len(comments) > 0: + comments = [(Event(q['added_at'], q['activity_type'], q['title'], '', q['answer_id'], \ + q['question_id'])) for q in comments] + activities.extend(comments) + + # question revisions + revisions = Activity.objects.extra( + select={ + 'title' : 'question_revision.title', + 'question_id' : 'question_revision.question_id', + 'added_at' : 'activity.active_at', + 'activity_type' : 'activity.activity_type', + 'summary' : 'question_revision.summary' + }, + tables=['activity', 'question_revision'], + where=['activity.content_type_id = %s AND activity.object_id = question_revision.id AND \ + activity.user_id = question_revision.author_id AND activity.user_id = %s AND \ + activity.activity_type=%s'], + params=[question_revision_type_id, user_id, TYPE_ACTIVITY_UPDATE_QUESTION], + order_by=['-activity.active_at'] + ).values( + 'title', + 'question_id', + 'added_at', + 'activity_type', + 'summary' + ) + + if len(revisions) > 0: + revisions = [(Event(q['added_at'], q['activity_type'], q['title'], q['summary'], '0', \ + q['question_id'])) for q in revisions] + activities.extend(revisions) + + # answer revisions + revisions = Activity.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'answer_id' : 'answer.id', + 'added_at' : 'activity.active_at', + 'activity_type' : 'activity.activity_type', + 'summary' : 'answer_revision.summary' + }, + tables=['activity', 'answer_revision', 'question', 'answer'], + + where=['activity.content_type_id = %s AND activity.object_id = answer_revision.id AND \ + activity.user_id = answer_revision.author_id AND activity.user_id = %s AND \ + answer_revision.answer_id=answer.id AND answer.question_id = question.id AND \ + activity.activity_type=%s'], + params=[answer_revision_type_id, user_id, TYPE_ACTIVITY_UPDATE_ANSWER], + order_by=['-activity.active_at'] + ).values( + 'title', + 'question_id', + 'added_at', + 'answer_id', + 'activity_type', + 'summary' + ) + + if len(revisions) > 0: + revisions = [(Event(q['added_at'], q['activity_type'], q['title'], q['summary'], \ + q['answer_id'], q['question_id'])) for q in revisions] + activities.extend(revisions) + + # accepted answers + accept_answers = Activity.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'added_at' : 'activity.active_at', + 'activity_type' : 'activity.activity_type', + }, + tables=['activity', 'answer', 'question'], + where=['activity.content_type_id = %s AND activity.object_id = answer.id AND \ + activity.user_id = question.author_id AND activity.user_id = %s AND \ + answer.question_id=question.id AND activity.activity_type=%s'], + params=[answer_type_id, user_id, TYPE_ACTIVITY_MARK_ANSWER], + order_by=['-activity.active_at'] + ).values( + 'title', + 'question_id', + 'added_at', + 'activity_type', + ) + if len(accept_answers) > 0: + accept_answers = [(Event(q['added_at'], q['activity_type'], q['title'], '', '0', \ + q['question_id'])) for q in accept_answers] + activities.extend(accept_answers) + #award history + awards = Activity.objects.extra( + select={ + 'badge_id' : 'badge.id', + 'awarded_at': 'award.awarded_at', + 'activity_type' : 'activity.activity_type' + }, + tables=['activity', 'award', 'badge'], + where=['activity.user_id = award.user_id AND activity.user_id = %s AND \ + award.badge_id=badge.id AND activity.object_id=award.id AND activity.activity_type=%s'], + params=[user_id, TYPE_ACTIVITY_PRIZE], + order_by=['-activity.active_at'] + ).values( + 'badge_id', + 'awarded_at', + 'activity_type' + ) + if len(awards) > 0: + awards = [(AwardEvent(q['awarded_at'], q['activity_type'], q['badge_id'])) for q in awards] + activities.extend(awards) + + activities.sort(lambda x,y: cmp(y.time, x.time)) + + return render_to_response(user_view.template_file,{ + "tab_name" : user_view.id, + "tab_description" : user_view.tab_description, + "page_title" : user_view.page_title, + "view_user" : user, + "activities" : activities[:user_view.data_size] + }, context_instance=RequestContext(request)) + +def user_responses(request, user_id, user_view): + """ + We list answers for question, comments, and answer accepted by others for this user. + """ + class Response: + def __init__(self, type, title, question_id, answer_id, time, username, user_id, content): + self.type = type + self.title = title + self.titlelink = u'/questions/%s/%s#%s' % (question_id, title, answer_id) + self.time = time + self.userlink = u'/users/%s/%s/' % (user_id, username) + self.username = username + self.content = u'%s ...' % strip_tags(content)[:300] + + def __unicode__(self): + return u'%s %s' % (self.type, self.titlelink) + + user = get_object_or_404(User, id=user_id) + responses = [] + answers = Answer.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'answer_id' : 'answer.id', + 'added_at' : 'answer.added_at', + 'html' : 'answer.html', + 'username' : 'auth_user.username', + 'user_id' : 'auth_user.id' + }, + select_params=[user_id], + tables=['answer', 'question', 'auth_user'], + where=['answer.question_id = question.id AND answer.deleted=0 AND question.deleted = 0 AND \ + question.author_id = %s AND answer.author_id <> %s AND answer.author_id=auth_user.id'], + params=[user_id, user_id], + order_by=['-answer.id'] + ).values( + 'title', + 'question_id', + 'answer_id', + 'added_at', + 'html', + 'username', + 'user_id' + ) + if len(answers) > 0: + answers = [(Response(TYPE_RESPONSE['QUESTION_ANSWERED'], a['title'], a['question_id'], + a['answer_id'], a['added_at'], a['username'], a['user_id'], a['html'])) for a in answers] + responses.extend(answers) + + + # question comments + comments = Comment.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'comment.object_id', + 'added_at' : 'comment.added_at', + 'comment' : 'comment.comment', + 'username' : 'auth_user.username', + 'user_id' : 'auth_user.id' + }, + tables=['question', 'auth_user', 'comment'], + where=['question.deleted = 0 AND question.author_id = %s AND comment.object_id=question.id AND \ + comment.content_type_id=%s AND comment.user_id <> %s AND comment.user_id = auth_user.id'], + params=[user_id, question_type_id, user_id], + order_by=['-comment.added_at'] + ).values( + 'title', + 'question_id', + 'added_at', + 'comment', + 'username', + 'user_id' + ) + + if len(comments) > 0: + comments = [(Response(TYPE_RESPONSE['QUESTION_COMMENTED'], c['title'], c['question_id'], + '', c['added_at'], c['username'], c['user_id'], c['comment'])) for c in comments] + responses.extend(comments) + + # answer comments + comments = Comment.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'answer_id' : 'answer.id', + 'added_at' : 'comment.added_at', + 'comment' : 'comment.comment', + 'username' : 'auth_user.username', + 'user_id' : 'auth_user.id' + }, + tables=['answer', 'auth_user', 'comment', 'question'], + where=['answer.deleted = 0 AND answer.author_id = %s AND comment.object_id=answer.id AND \ + comment.content_type_id=%s AND comment.user_id <> %s AND comment.user_id = auth_user.id \ + AND question.id = answer.question_id'], + params=[user_id, answer_type_id, user_id], + order_by=['-comment.added_at'] + ).values( + 'title', + 'question_id', + 'answer_id', + 'added_at', + 'comment', + 'username', + 'user_id' + ) + + if len(comments) > 0: + comments = [(Response(TYPE_RESPONSE['ANSWER_COMMENTED'], c['title'], c['question_id'], + c['answer_id'], c['added_at'], c['username'], c['user_id'], c['comment'])) for c in comments] + responses.extend(comments) + + # answer has been accepted + answers = Answer.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'answer_id' : 'answer.id', + 'added_at' : 'answer.accepted_at', + 'html' : 'answer.html', + 'username' : 'auth_user.username', + 'user_id' : 'auth_user.id' + }, + select_params=[user_id], + tables=['answer', 'question', 'auth_user'], + where=['answer.question_id = question.id AND answer.deleted=0 AND question.deleted = 0 AND \ + answer.author_id = %s AND answer.accepted=1 AND question.author_id=auth_user.id'], + params=[user_id], + order_by=['-answer.id'] + ).values( + 'title', + 'question_id', + 'answer_id', + 'added_at', + 'html', + 'username', + 'user_id' + ) + if len(answers) > 0: + answers = [(Response(TYPE_RESPONSE['ANSWER_ACCEPTED'], a['title'], a['question_id'], + a['answer_id'], a['added_at'], a['username'], a['user_id'], a['html'])) for a in answers] + responses.extend(answers) + + # sort posts by time + responses.sort(lambda x,y: cmp(y.time, x.time)) + + return render_to_response(user_view.template_file,{ + "tab_name" : user_view.id, + "tab_description" : user_view.tab_description, + "page_title" : user_view.page_title, + "view_user" : user, + "responses" : responses[:user_view.data_size], + + }, context_instance=RequestContext(request)) + +def user_votes(request, user_id, user_view): + user = get_object_or_404(User, id=user_id) + if not can_view_user_votes(request.user, user): + raise Http404 + votes = [] + question_votes = Vote.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'answer_id' : 0, + 'voted_at' : 'vote.voted_at', + 'vote' : 'vote', + }, + select_params=[user_id], + tables=['vote', 'question', 'auth_user'], + where=['vote.content_type_id = %s AND vote.user_id = %s AND vote.object_id = question.id AND vote.user_id=auth_user.id'], + params=[question_type_id, user_id], + order_by=['-vote.id'] + ).values( + 'title', + 'question_id', + 'answer_id', + 'voted_at', + 'vote', + ) + if(len(question_votes) > 0): + votes.extend(question_votes) + + answer_votes = Vote.objects.extra( + select={ + 'title' : 'question.title', + 'question_id' : 'question.id', + 'answer_id' : 'answer.id', + 'voted_at' : 'vote.voted_at', + 'vote' : 'vote', + }, + select_params=[user_id], + tables=['vote', 'answer', 'question', 'auth_user'], + where=['vote.content_type_id = %s AND vote.user_id = %s AND vote.object_id = answer.id AND answer.question_id = question.id AND vote.user_id=auth_user.id'], + params=[answer_type_id, user_id], + order_by=['-vote.id'] + ).values( + 'title', + 'question_id', + 'answer_id', + 'voted_at', + 'vote', + ) + if(len(answer_votes) > 0): + votes.extend(answer_votes) + votes.sort(lambda x,y: cmp(y['voted_at'], x['voted_at'])) + return render_to_response(user_view.template_file,{ + "tab_name" : user_view.id, + "tab_description" : user_view.tab_description, + "page_title" : user_view.page_title, + "view_user" : user, + "votes" : votes[:user_view.data_size] + + }, context_instance=RequestContext(request)) + +def user_reputation(request, user_id, user_view): + user = get_object_or_404(User, id=user_id) + reputation = Repute.objects.extra( + select={'positive': 'sum(positive)', 'negative': 'sum(negative)', 'question_id':'question_id', 'title': 'question.title'}, + tables=['repute', 'question'], + order_by=['-reputed_at'], + where=['user_id=%s AND question_id=question.id'], + params=[user.id] + ).values('positive', 'negative', 'question_id', 'title', 'reputed_at', 'reputation') + + reputation.query.group_by = ['question_id'] + + + rep_list = [] + for rep in Repute.objects.filter(user=user).order_by('reputed_at'): + dic = '[%s,%s]' % (calendar.timegm(rep.reputed_at.timetuple()) * 1000, rep.reputation) + rep_list.append(dic) + reps = ','.join(rep_list) + reps = '[%s]' % reps + + return render_to_response(user_view.template_file,{ + "tab_name" : user_view.id, + "tab_description" : user_view.tab_description, + "page_title" : user_view.page_title, + "view_user" : user, + "reputation" : reputation, + "reps" : reps + }, context_instance=RequestContext(request)) + +def user_favorites(request, user_id, user_view): + user = get_object_or_404(User, id=user_id) + questions = Question.objects.extra( + select={ + 'vote_count' : 'question.vote_up_count + question.vote_down_count', + 'favorited_myself' : 'SELECT count(*) FROM favorite_question f WHERE f.user_id = %s AND f.question_id = question.id', + 'la_user_id' : 'auth_user.id', + 'la_username' : 'auth_user.username', + 'la_user_gold' : 'auth_user.gold', + 'la_user_silver' : 'auth_user.silver', + 'la_user_bronze' : 'auth_user.bronze', + 'la_user_reputation' : 'auth_user.reputation' + }, + select_params=[user_id], + tables=['question', 'auth_user', 'favorite_question'], + where=['question.deleted = 0 AND question.last_activity_by_id = auth_user.id AND favorite_question.question_id = question.id AND favorite_question.user_id = %s'], + params=[user_id], + order_by=['-vote_count', '-question.id'] + ).values('vote_count', + 'favorited_myself', + 'id', + 'title', + 'author_id', + 'added_at', + 'answer_accepted', + 'answer_count', + 'comment_count', + 'view_count', + 'favourite_count', + 'summary', + 'tagnames', + 'vote_up_count', + 'vote_down_count', + 'last_activity_at', + 'la_user_id', + 'la_username', + 'la_user_gold', + 'la_user_silver', + 'la_user_bronze', + 'la_user_reputation') + return render_to_response(user_view.template_file,{ + "tab_name" : user_view.id, + "tab_description" : user_view.tab_description, + "page_title" : user_view.page_title, + "questions" : questions[:user_view.data_size], + "view_user" : user + }, context_instance=RequestContext(request)) + + +def user_preferences(request, user_id, user_view): + user = get_object_or_404(User, id=user_id) + return render_to_response(user_view.template_file,{ + "tab_name" : user_view.id, + "tab_description" : user_view.tab_description, + "page_title" : user_view.page_title, + "view_user" : user, + }, context_instance=RequestContext(request)) + +def question_comments(request, id): + question = get_object_or_404(Question, id=id) + user = request.user + return __comments(request, question, 'question', user) + +def answer_comments(request, id): + answer = get_object_or_404(Answer, id=id) + user = request.user + return __comments(request, answer, 'answer', user) + +def __comments(request, obj, type, user): + # only support get comments by ajax now + if request.is_ajax(): + if request.method == "GET": + return __generate_comments_json(obj, type, user) + elif request.method == "POST": + comment_data = request.POST.get('comment') + comment = Comment(content_object=obj, comment=comment_data, user=request.user) + comment.save() + obj.comment_count = obj.comment_count + 1 + obj.save() + return __generate_comments_json(obj, type, user) + +def __generate_comments_json(obj, type, user): + comments = obj.comments.all().order_by('-id') + # {"Id":6,"PostId":38589,"CreationDate":"an hour ago","Text":"hello there!","UserDisplayName":"Jarrod Dixon","UserUrl":"/users/3/jarrod-dixon","DeleteUrl":null} + json_comments = [] + for comment in comments: + comment_user = comment.user + delete_url = "" + if user != None and auth.can_delete_comment(user, comment): + #/posts/392845/comments/219852/delete + delete_url = "/" + type + "s/%s/comments/%s/delete/" % (obj.id, comment.id) + json_comments.append({"id" : comment.id, + "object_id" : obj.id, + "add_date" : comment.added_at.strftime('%Y-%m-%d'), + "text" : comment.comment, + "user_display_name" : comment_user.username, + "user_url" : "/users/%s/%s" % (comment_user.id, comment_user.username), + "delete_url" : delete_url + }) + + data = simplejson.dumps(json_comments) + return HttpResponse(data, mimetype="application/json") + +def delete_question_comment(request, question_id, comment_id): + if request.is_ajax(): + question = get_object_or_404(Question, id=question_id) + comment = get_object_or_404(Comment, id=comment_id) + + question.comments.remove(comment) + question.comment_count = question.comment_count - 1 + question.save() + user = request.user + return __generate_comments_json(question, 'question', user) + +def delete_answer_comment(request, answer_id, comment_id): + if request.is_ajax(): + answer = get_object_or_404(Answer, id=answer_id) + comment = get_object_or_404(Comment, id=comment_id) + + answer.comments.remove(comment) + answer.comment_count = answer.comment_count - 1 + answer.save() + user = request.user + return __generate_comments_json(answer, 'answer', user) + +def logout(request): + url = request.GET.get('next') + return render_to_response('logout.html', { + 'next' : url, + }, context_instance=RequestContext(request)) + +def badges(request): + badges = Badge.objects.all().order_by('type') + my_badges = [] + if request.user.is_authenticated(): + my_badges = Award.objects.filter(user=request.user) + my_badges.query.group_by = ['badge_id'] + + return render_to_response('badges.html', { + 'badges' : badges, + 'mybadges' : my_badges, + }, context_instance=RequestContext(request)) + +def badge(request, id): + badge = get_object_or_404(Badge, id=id) + awards = Award.objects.extra( + select={'id': 'auth_user.id', 'name': 'auth_user.username', 'rep':'auth_user.reputation', 'gold': 'auth_user.gold', 'silver': 'auth_user.silver', 'bronze': 'auth_user.bronze'}, + tables=['award', 'auth_user'], + where=['badge_id=%s AND user_id=auth_user.id'], + params=[id] + ).values('id').distinct() + + return render_to_response('badge.html', { + 'awards' : awards, + 'badge' : badge, + }, context_instance=RequestContext(request)) + +def read_message(request): + if request.method == "POST": + if request.POST['formdata'] == 'required': + request.session['message_silent'] = 1 + + if request.user.is_authenticated(): + request.user.delete_messages() + return HttpResponse('') + +def upload(request): + class FileTypeNotAllow(Exception): + pass + class FileSizeNotAllow(Exception): + pass + class UploadPermissionNotAuthorized(Exception): + pass + + #%s + xml_template = "%s" + + try: + f = request.FILES['file-upload'] + # check upload permission + if not can_upload_files(request.user): + raise UploadPermissionNotAuthorized + + # check file type + file_name_suffix = os.path.splitext(f.name)[1].lower() + if not file_name_suffix in settings.ALLOW_FILE_TYPES: + raise FileTypeNotAllow + + # genetate new file name + new_file_name = str(time.time()).replace('.', str(random.randint(0,100000))) + file_name_suffix + # use default storage to store file + default_storage.save(new_file_name, f) + # check file size + # byte + size = default_storage.size(new_file_name) + if size > settings.ALLOW_MAX_FILE_SIZE: + default_storage.delete(new_file_name) + raise FileSizeNotAllow + + result = xml_template % ('Good', '', default_storage.url(new_file_name)) + except UploadPermissionNotAuthorized: + result = xml_template % ('', u"涓婁紶鍥剧墖鍙檺浜庣Н鍒+60浠ヤ笂娉ㄥ唽鐢ㄦ埛!", '') + except FileTypeNotAllow: + result = xml_template % ('', u"鍙厑璁镐笂浼'jpg', 'jpeg', 'gif', 'bmp', 'png', 'tiff'绫诲瀷鐨勬枃浠讹紒", '') + except FileSizeNotAllow: + result = xml_template % ('', u"鍙厑璁镐笂浼%sK澶у皬鐨勬枃浠讹紒" % settings.ALLOW_MAX_FILE_SIZE / 1024, '') + except Exception: + result = xml_template % ('', u"鍦ㄦ枃浠朵笂浼犺繃绋嬩腑浜х敓浜嗛敊璇紝璇疯仈绯荤鐞嗗憳锛岃阿璋_^", '') + + return HttpResponse(result, mimetype="application/xml") + +def books(request): + return HttpResponseRedirect("/books/mysql-zhaoyang") + +def book(request, short_name, unanswered=False): + """ + 1. questions list + 2. book info + 3. author info and blog rss items + """ + """ + List of Questions, Tagged questions, and Unanswered questions. + """ + books = Book.objects.extra(where=['short_name = %s'], params=[short_name]) + match_count = len(books) + if match_count == 0 : + raise Http404 + else: + # the book info + book = books[0] + # get author info + author_info = BookAuthorInfo.objects.get(book=book) + # get author rss info + author_rss = BookAuthorRss.objects.filter(book=book) + + # get pagesize from session, if failed then get default value + user_page_size = request.session.get("pagesize", QUESTIONS_PAGE_SIZE) + # set pagesize equal to logon user specified value in database + if request.user.is_authenticated() and request.user.questions_per_page > 0: + user_page_size = request.user.questions_per_page + + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + + view_id = request.GET.get('sort', None) + view_dic = {"latest":"-added_at", "active":"-last_activity_at", "hottest":"-answer_count", "mostvoted":"-score" } + try: + orderby = view_dic[view_id] + except KeyError: + view_id = "latest" + orderby = "-added_at" + + # check if request is from tagged questions + if unanswered: + # check if request is from unanswered questions + # Article.objects.filter(publications__id__exact=1) + objects = Question.objects.filter(book__id__exact=book.id, deleted=False, answer_count=0).order_by(orderby) + else: + objects = Question.objects.filter(book__id__exact=book.id, deleted=False).order_by(orderby) + + # RISK - inner join queries + objects = objects.select_related(); + objects_list = Paginator(objects, user_page_size) + questions = objects_list.page(page) + + return render_to_response('book.html', { + "book" : book, + "author_info" : author_info, + "author_rss" : author_rss, + "questions" : questions, + "context" : { + 'is_paginated' : True, + 'pages': objects_list.num_pages, + 'page': page, + 'has_previous': questions.has_previous(), + 'has_next': questions.has_next(), + 'previous': questions.previous_page_number(), + 'next': questions.next_page_number(), + 'base_url' : request.path + '?sort=%s&' % view_id, + 'pagesize' : user_page_size + } + }, context_instance=RequestContext(request)) + +@login_required +def ask_book(request, short_name): + if request.method == "POST": + form = AskForm(request.POST) + if form.is_valid(): + added_at = datetime.datetime.now() + html = sanitize_html(markdowner.convert(form.cleaned_data['text'])) + question = Question( + title = strip_tags(form.cleaned_data['title']), + author = request.user, + added_at = added_at, + last_activity_at = added_at, + last_activity_by = request.user, + wiki = form.cleaned_data['wiki'], + tagnames = form.cleaned_data['tags'].strip(), + html = html, + summary = strip_tags(html)[:120] + ) + if question.wiki: + question.last_edited_by = question.author + question.last_edited_at = added_at + question.wikified_at = added_at + + question.save() + + # create the first revision + QuestionRevision.objects.create( + question = question, + revision = 1, + title = question.title, + author = request.user, + revised_at = added_at, + tagnames = question.tagnames, + summary = CONST['default_version'], + text = form.cleaned_data['text'] + ) + + books = Book.objects.extra(where=['short_name = %s'], params=[short_name]) + match_count = len(books) + if match_count == 1: + # the book info + book = books[0] + book.questions.add(question) + + return HttpResponseRedirect(question.get_absolute_url()) + else: + form = AskForm() + + tags = _get_tags_cache_json() + return render_to_response('ask.html', { + 'form' : form, + 'tags' : tags, + }, context_instance=RequestContext(request)) + +def search(request): + """ + Search by question, user and tag keywords. + For questions now we only search keywords in question title. + """ + if request.method == "GET": + keywords = request.GET.get("q") + search_type = request.GET.get("t") + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + if keywords is None: + return HttpResponseRedirect('/') + if search_type == 'tag': + return HttpResponseRedirect('/tags/?q=%s&page=%s' % (keywords.strip(), page)) + elif search_type == "user": + return HttpResponseRedirect('/users/?q=%s&page=%s' % (keywords.strip(), page)) + elif search_type == "question": + + template_file = "questions.html" + # Set flag to False by default. If it is equal to True, then need to be saved. + pagesize_changed = False + # get pagesize from session, if failed then get default value + user_page_size = request.session.get("pagesize", QUESTIONS_PAGE_SIZE) + # set pagesize equal to logon user specified value in database + if request.user.is_authenticated() and request.user.questions_per_page > 0: + user_page_size = request.user.questions_per_page + + try: + page = int(request.GET.get('page', '1')) + # get new pagesize from UI selection + pagesize = int(request.GET.get('pagesize', user_page_size)) + if pagesize <> user_page_size: + pagesize_changed = True + + except ValueError: + page = 1 + pagesize = user_page_size + + # save this pagesize to user database + if pagesize_changed: + request.session["pagesize"] = pagesize + if request.user.is_authenticated(): + user = request.user + user.questions_per_page = pagesize + user.save() + + view_id = request.GET.get('sort', None) + view_dic = {"latest":"-added_at", "active":"-last_activity_at", "hottest":"-answer_count", "mostvoted":"-score" } + try: + orderby = view_dic[view_id] + except KeyError: + view_id = "latest" + orderby = "-added_at" + + objects = Question.objects.filter(deleted=False).extra(where=['title like %s'], params=['%' + keywords + '%']).order_by(orderby) + + # RISK - inner join queries + objects = objects.select_related(); + objects_list = Paginator(objects, pagesize) + questions = objects_list.page(page) + + # Get related tags from this page objects + related_tags = [] + for question in questions.object_list: + tags = list(question.tags.all()) + for tag in tags: + if tag not in related_tags: + related_tags.append(tag) + + return render_to_response(template_file, { + "questions" : questions, + "tab_id" : view_id, + "questions_count" : objects_list.count, + "tags" : related_tags, + "searchtag" : None, + "searchtitle" : keywords, + "keywords" : keywords, + "is_unanswered" : False, + "context" : { + 'is_paginated' : True, + 'pages': objects_list.num_pages, + 'page': page, + 'has_previous': questions.has_previous(), + 'has_next': questions.has_next(), + 'previous': questions.previous_page_number(), + 'next': questions.next_page_number(), + 'base_url' : request.path + '?t=question&q=%s&sort=%s&' % (keywords, view_id), + 'pagesize' : pagesize + }}, context_instance=RequestContext(request)) + + else: + raise Http404 + diff --git a/locale/zh_cn/LC_MESSAGES/django.mo b/locale/zh_cn/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..f8f70df4f7893ac1568ad5412f0b565ca962b77a GIT binary patch literal 6605 zcmai1Yfv549Y5MsD_XTa`c{u^W3=YpKzt>L(JPRImPZOio6dBm%e@P%+`EgrdxO|^ z2BHv92r(gvc`1n`W>N!GZ9;g2`lKHxWjr-63@=Yd}b{u%f+;77nGfNQRYF5uHZn)fWQ5tspz{NDm^0{#(r zKk!4~Exk>{2Op1#{UL>2YB}ljNJ!J0B;Aj z13w1-0!Vtz62@)={u~$s?gRb^IH&OD8ySmZ{4*f_*a&_gnjHty{Bht{fPVs#{2UOX z*(X5a=~^iHCGZ{~@pBSL^DhE70e=sC40sL5_y%w@@W;R=;QPRLfZKr@oZJdL52WuO z18aak09o{Y6i9Y`2y6i6fS{5+4AMw$g~Dfm#9t@yk!u)x6ic2XMhy%e*p2vKEY26cq2%n`I~|Cek+jX?^5r3 zf#1h?ACUB429iDh0@D2d0%`sANGh`D4uvt`y%=u=()V^X&H`!O5#TxCc_7Jaf^jtO zr@(uF&jIU!uK;QOUx4=mKLUbEcIQ{Y4R9^661W~n^E!briM<3QxkrFx*D2tmz!@Ov z`4~uY{s)W$Z$^=je@_5OjtQjN>;?7#KLAz$w?P>3_A-!odKXCZ{|ej;{11@yu0xP1 zPs)H~=ZnDa0egXD-&r87n*k#1;(8drlq1n=69y0Brn!%)4`dg`gyfM=NNrKuR9|pM zTxIy(h&RwZIVaiWXr9`rDj zD7zasT^#opa6f>XuC=%+AJ*eWsfY`%hu7nHdIa~axKUz77u6BPjCkBq^o6nSsxh_A zyKtA|rh1~9rc10sb%zv4eG^u zt~rjCG&EPIH8yYP)XkbI-etJ$T;rzR#kFM8%9?JR7sP65Th~(En2^ykExH|*B324f z`U{5RlJ-DC#fHu;B{#79ZTcIM)Cn8AEIY;9HHWw8 zy2%~gbh&HE#d=0F(p*cWY~69x2D8g~vRyOV^uYg} zjkPO22|X*`u9PGd2VS#8D#hVvwlhT}yX`tJGPn?clw@6S7f{9$CMO<^D3L6&TFh9b zW^&VV15X0O;(Vv0+dO5N>s%qr<(k=@v5+3iFT>=N129x;(HuR_Dx;(XBgupMWFcP+ zuo_sD3d5pY2v!B=V5}!Qc+xUk4LieItQXdELnJKk(hya}UNH-mRyLhl-MLCBNOKL# zQ9v>t1*)n+)27T&>d&Bmg7pzfjIso-wx;LB~Kz*G^c~2g|g9?&5ZME z6FiA*4J3+X7;xbh$>=iRTN~DDK{#a;WPTSK0dn$aUcT{Ww(Yq#Hod5UGS&Cf0!m}I+|NK+kvUnRKtfLl|@%x>%{pk zFrU%7gMZiVHhc~PK{)$h~j|N;)|@X zh`{Bf1t}=3C~oRJ2uZtTA-$ApB^V;RU`U}ysBJN4CzA%KIFnMX?sLGS2I?4qbLr>MFJ_ zPcPhX@0GNEn)gCbA?-d-Oqi`HOP3puI0`L~kr*%QI`M$H{TYy2GB; z(@86%Gqj)ZI0`Fw>$ZUcPu<< zhYd1TlZrh9T{tb2^BsxGA11a{^Jl6Xn`#>BOB!{O6RUIDj8yFDY?~8nw#s?Qj)vw~ zB~H9_#E4a4gDU46OG`J!$~MLxD&u93mY0@3SXx$EiixpCeK$^P;k;ediN;u6L#!&n zw>Om6)jarbgWt?Nf=Ws>bT3rY)Fi zwq><8J=UyinQ~s6sNc4eOs=S{eJX9lExTnkG?~K3a+~Tp9 z{lin<^nP#Tl0R@b-_z$0?e!*(d6(W@oE`BlyzZT#IdZ~3d-kXU|JAtxZ=rALM9p(R!XLdXi{Cpj<(=$NuNFst<6YP%B6joIL(MWEa^aBnkso zbDb^Dz6M(43TXq&O%LZ^nwMrtg;>5gdd?rXBvoR9WRS#0&HoI;4-Dnz$K-OU5`?be zbKv0FJ^mXf7Eeu3$OMH~=Z5l=mzH`4bJG{R@nd-KPxTA^t6F<%B0n*nTR7$SPRe7p ze_}8{IY|rrBX27${?v5ta$gadMVzas3I-8NUyw^8KJ|l?CD~LtaA3$E?16T#zt5Yv zTpUM#;5GONOY>)uOOz@3g`>z1xs)_1+V>BGbN|9yn2qq9_Qrpmo9S0-L{?s%dz1Jb znas_eL25(H(%zw^y~Fv5D`5y_aTFxZkLBi$`J)#piz5k+z)1g~U#|5=&cgwygJgf9 z$A5oTPCzJV^1&>IvfTml~9TA%`VQq z32|cCd*}R@N3PDPz!#CZe;@K7H#?h~KjigY%*`Io&CDpL`-lDa&UyVq%NY#Ay)=4M zWk5l_EM}RIVKEojk0vM#V#)(Kfy4Y|T|w3YoFJq3O~Es1960wTUh+?#Sv)%H%^xB! z6|>Q-lCRX^RCNORj&vjY(I$`sh;VNDRq2iTuq?9Pfg!n$ED>yaLo?n$zc>E2H#Oq* z9~CqYUh$5}0rzm+LasHq;I4m8IIV5Q#S(0U;?I!elFD(ClGZoYOW~uh1c^FQz}(Of4Mr> zOCgRf4q`v#4eZ72=t`QcI25fRY{w9RVuPJBB_y$;b4TVCmdgAOxelA`GOkwyZvSvW zhCepv&5eLISzWSOco&ZNlf#hbADY55@&`HV4IEgUS@2(<^!j@96VoUj5x93w=NI;| rBErPJEsa|`588T{dXD86_6FxEYKEhe{!p)2A7m}{lA+5>eZ%bkZ&mEw literal 0 HcmV?d00001 diff --git a/locale/zh_cn/LC_MESSAGES/django.po b/locale/zh_cn/LC_MESSAGES/django.po new file mode 100644 index 0000000000..07eaa93d1b --- /dev/null +++ b/locale/zh_cn/LC_MESSAGES/django.po @@ -0,0 +1,416 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2008-12-31 16:00+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: .\settings.py:32 +msgid "account/" +msgstr "" + +#: .\settings.py:32 .\django_authopenid\urls.py:9 +#: .\django_authopenid\urls.py:11 +msgid "signin/" +msgstr "" + +#: .\django_authopenid\forms.py:67 .\django_authopenid\views.py:93 +msgid "i-names are not supported" +msgstr "i-names涓嶆敮鎸併" + +#: .\django_authopenid\forms.py:100 .\django_authopenid\forms.py:156 +#: .\django_authopenid\forms.py:205 +msgid "" +"Usernames can only contain letters, numbers and " +"underscores" +msgstr "鐢ㄦ埛鍚嶆牸寮忔湁璇傚彧鏈夊瓧姣嶏紝鏁板瓧鍜屼笅鍒掔嚎鏄厑璁哥殑銆" + +#: .\django_authopenid\forms.py:107 +msgid "" +"This username does not exist in our database. Please " +"choose another." +msgstr "鐢ㄦ埛鍚嶄笉瀛樺湪銆傝閲嶆柊杈撳叆銆" + +#: .\django_authopenid\forms.py:124 .\django_authopenid\forms.py:229 +msgid "" +"Please enter a valid username and password. Note that " +"both fields are case-sensitive." +msgstr "璇疯緭鍏ョ敤鎴峰悕鍜屽瘑鐮併傛敞鎰忓尯鍒嗗ぇ灏忓啓銆" + +#: .\django_authopenid\forms.py:128 .\django_authopenid\forms.py:233 +msgid "This account is inactive." +msgstr "鐢ㄦ埛宸插喕缁撱" + +#: .\django_authopenid\forms.py:168 +msgid "This username is already taken. Please choose another." +msgstr "鐢ㄦ埛鍚嶅凡缁忚娉ㄥ唽锛岃閫夌敤涓涓柊鐨勫笎鍙枫" + +#: .\django_authopenid\forms.py:182 +msgid "" +"This email is already registered in our database. Please " +"choose another." +msgstr "鐢靛瓙閭欢宸茶娉ㄥ唽銆傝浣跨敤涓涓柊鐨勯偖浠跺湴鍧銆" + +#: .\django_authopenid\forms.py:212 +msgid "" +"This username don't exist. Please choose another." +msgstr "鐢ㄦ埛鍚嶄笉瀛樺湪" + +#: .\django_authopenid\forms.py:328 +msgid "" +"Old password is incorrect. Please enter the correct " +"password." +msgstr "鏃у瘑鐮侀敊璇" + +#: .\django_authopenid\forms.py:340 +msgid "new passwords do not match" +msgstr "鏂板瘑鐮佷笉鍖归厤" + +#: .\django_authopenid\forms.py:432 +msgid "Incorrect username." +msgstr "鐢ㄦ埛鍚嶄笉姝g‘" + +#: .\django_authopenid\urls.py:10 +msgid "signout/" +msgstr "" + +#: .\django_authopenid\urls.py:11 +msgid "complete/" +msgstr "" + +#: .\django_authopenid\urls.py:13 +msgid "register/" +msgstr "" + +#: .\django_authopenid\urls.py:14 +msgid "signup/" +msgstr "" + +#: .\django_authopenid\urls.py:15 +msgid "sendpw/" +msgstr "" + +#: .\django_authopenid\urls.py:16 .\django_authopenid\urls.py:21 +msgid "password/" +msgstr "" + +#: .\django_authopenid\urls.py:16 +msgid "confirm/" +msgstr "" + +#: .\django_authopenid\urls.py:22 +msgid "email/" +msgstr "" + +#: .\django_authopenid\urls.py:23 +msgid "openid/" +msgstr "" + +#: .\django_authopenid\urls.py:24 +msgid "delete/" +msgstr "" + +#: .\django_authopenid\views.py:99 +#, python-format +msgid "闈炴硶OpenID鍦板潃锛 %s" +msgstr "" + +#: .\django_authopenid\views.py:366 +msgid "Welcome" +msgstr "娆㈣繋" + +#: .\django_authopenid\views.py:456 +msgid "Password changed." +msgstr "瀵嗙爜宸叉洿鏂般" + +#: .\django_authopenid\views.py:488 +msgid "Email changed." +msgstr "閭欢鍦板潃宸叉洿鏂般" + +#: .\django_authopenid\views.py:519 .\django_authopenid\views.py:671 +#, python-format +msgid "No OpenID %s found associated in our database" +msgstr "璇penID %s 涓嶅湪绯荤粺涓" + +#: .\django_authopenid\views.py:523 .\django_authopenid\views.py:678 +#, python-format +msgid "The OpenID %s isn't associated to current user logged in" +msgstr "OpenID %s 娌℃湁鍜屽綋鍓嶇櫥褰曠敤鎴风粦瀹氥" + +#: .\django_authopenid\views.py:531 +msgid "Email Changed." +msgstr "閭欢鍦板潃宸叉洿鏂般" + +#: .\django_authopenid\views.py:606 +msgid "This OpenID is already associated with another account." +msgstr "杩欎釜OpenID宸茬粡缁戝畾鍒板彟澶栦竴涓笎鍙枫" + +#: .\django_authopenid\views.py:611 +#, python-format +msgid "OpenID %s is now associated with your account." +msgstr "OpenID %s 宸茬粡缁戝畾鍒版偍鐨勫笎鍙枫" + +#: .\django_authopenid\views.py:681 +msgid "Account deleted." +msgstr "甯愬彿宸插垹闄ゃ" + +#: .\django_authopenid\views.py:721 +msgid "Request for new password" +msgstr "鎵惧洖瀵嗙爜" + +#: .\django_authopenid\views.py:734 +msgid "A new password has been sent to your email address." +msgstr "鏂扮殑瀵嗙爜宸茬粡鍙戦佸埌鎮ㄧ殑閭欢甯愬彿銆" + +#: .\django_authopenid\views.py:764 +#, python-format +msgid "" +"Could not change password. Confirmation key '%s' is not " +"registered." +msgstr "涓嶈兘淇敼瀵嗙爜銆傜‘璁や俊鎭 '%s' 鏈夎銆" + +#: .\django_authopenid\views.py:773 +msgid "" +"Can not change password. User don't exist anymore in our " +"database." +msgstr "涓嶈兘淇敼瀵嗙爜銆傜敤鎴峰笎鍙蜂笉瀛樺湪銆" + +#: .\django_authopenid\views.py:782 +#, python-format +msgid "Password changed for %s. You may now sign in." +msgstr "甯愬彿 %s 鐨勫瘑鐮佸凡缁忎慨鏀广傛偍鐜板湪鍙互鐢ㄥ畠鏉ョ櫥褰曘" + +#: .\templates\authopenid\changeemail.html.py:8 +msgid "Account: change email" +msgstr "淇敼鐢靛瓙閭欢" + +#: .\templates\authopenid\changeemail.html.py:10 +msgid "" +"This is where you can change the email address associated with your account. " +"Please keep this email address up to date so we can send you a password-" +"reset email if you request one." +msgstr "" +"鎮ㄥ彲浠ュ湪杩欓噷淇敼鎮ㄧ殑鐢靛瓙閭欢锛岃纭繚杩欎釜閭欢鍦板潃鏈夋晥-鎵惧洖瀵嗙爜灏嗗彂閫佹柊瀵嗙爜鍒版偍" +"鐨勯偖浠跺湴鍧銆" + +#: .\templates\authopenid\changeemail.html.py:12 +#: .\templates\authopenid\changeopenid.html.py:9 +#: .\templates\authopenid\changepw.html.py:15 +#: .\templates\authopenid\complete.html.py:26 +#: .\templates\authopenid\complete.html.py:36 +#: .\templates\authopenid\delete.html.py:10 +#: .\templates\authopenid\delete.html.py:20 +#: .\templates\authopenid\sendpw.html.py:11 +#: .\templates\authopenid\signup.html.py:15 +msgid "Please correct errors below:" +msgstr "璇锋敼姝d互涓嬮敊璇細" + +#: .\templates\authopenid\changeemail.html.py:29 +#: .\templates\authopenid\complete.html.py:52 +msgid "Email" +msgstr "鐢靛瓙閭欢" + +#: .\templates\authopenid\changeemail.html.py:30 +#: .\templates\authopenid\complete.html.py:68 +msgid "Password" +msgstr "瀵嗙爜" + +#: .\templates\authopenid\changeemail.html.py:32 +msgid "Change email" +msgstr "淇敼鐢靛瓙閭欢" + +#: .\templates\authopenid\changeopenid.html.py:5 +msgid "Account: change OpenID URL" +msgstr "淇敼OpenID鍦板潃" + +#: .\templates\authopenid\changeopenid.html.py:7 +msgid "" +"This is where you can change your OpenID URL. Make sure you remember it!" +msgstr "璇蜂慨鏀规偍鐨凮penID鍦板潃锛岃涓嶈蹇樿杩欎釜鍦板潃锛" + +#: .\templates\authopenid\changeopenid.html.py:24 +msgid "OpenID URL:" +msgstr "OpenID鍦板潃锛" + +#: .\templates\authopenid\changeopenid.html.py:25 +msgid "Change OpenID" +msgstr "淇敼OpenID" + +#: .\templates\authopenid\changepw.html.py:11 +msgid "Account: change password" +msgstr "淇敼瀵嗙爜" + +#: .\templates\authopenid\changepw.html.py:13 +msgid "This is where you can change your password. Make sure you remember it!" +msgstr "璇蜂慨鏀规偍鐨勫瘑鐮侊紝鍒囪涓嶈蹇樿锛" + +#: .\templates\authopenid\changepw.html.py:23 +msgid "Current password" +msgstr "鏃у瘑鐮" + +#: .\templates\authopenid\changepw.html.py:24 +msgid "New password" +msgstr "鏂板瘑鐮" + +#: .\templates\authopenid\changepw.html.py:25 +msgid "New password again" +msgstr "閲嶅瀵嗙爜" + +#: .\templates\authopenid\changepw.html.py:26 +msgid "Change password" +msgstr "淇敼瀵嗙爜" + +#: .\templates\authopenid\complete.html.py:12 +msgid "Your OpenID is verified! " +msgstr "鎮ㄧ殑OpenID甯愬彿宸茬粡楠岃瘉閫氳繃" + + +#: .\templates\authopenid\complete.html.py:17 +msgid "Associate your OpenID" +msgstr "缁戝畾鎮ㄧ殑OpenID" + +#: .\templates\authopenid\complete.html.py:18 +msgid "" +"\n" +"\t

If you're joining Sitename, associate your OpenID with " +"a new account. If you're already a member, associate with your existing " +"account.

\n" +"\t" +msgstr "" +"\n" +"\t

杈撳叆鎮ㄧ殑鏂板笎鍙锋垨鑰呮寚瀹氬凡缁忓瓨鍦ㄧ殑甯愬彿銆

\n" +"\t" + +#: .\templates\authopenid\complete.html.py:50 +msgid "A new account" +msgstr "鏂板笎鍙" + +#: .\templates\authopenid\complete.html.py:51 +#: .\templates\authopenid\complete.html.py:67 +#: .\templates\authopenid\sendpw.html.py:24 +msgid "Username" +msgstr "鐢ㄦ埛鍚" + +#: .\templates\authopenid\complete.html.py:66 +msgid "An exisiting account" +msgstr "宸茬粡瀛樺湪鐨勫笎鍙" + +#: .\templates\authopenid\delete.html.py:6 +msgid "Account: delete account" +msgstr "鍒犻櫎甯愬彿" + +#: .\templates\authopenid\delete.html.py:8 +msgid "" +"Note: After deleting your account, anyone will be able to register this " +"username." +msgstr "娉ㄦ剰锛氬垹闄ゆ偍鐨勫笎鍙峰悗锛屼换浣曞叾浠栦汉鍙互鍐嶆敞鍐岃繖涓笎鍙枫" + +#: .\templates\authopenid\delete.html.py:12 +msgid "Check confirm box, if you want delete your account." +msgstr "濡傛灉纭畾鍒犻櫎锛岃閫変腑澶氶夋銆" + +#: .\templates\authopenid\delete.html.py:15 +msgid "Password:" +msgstr "瀵嗙爜锛" + +#: .\templates\authopenid\delete.html.py:27 +msgid "I am sure I want to delete my account." +msgstr "鎴戠‘璁よ鍒犻櫎杩欎釜甯愬彿銆" + +#: .\templates\authopenid\delete.html.py:28 +msgid "Password/OpenID URL" +msgstr "瀵嗙爜/OpenID鍦板潃" + +#: .\templates\authopenid\delete.html.py:28 +msgid "(required for your security)" +msgstr "锛堝繀闇锛" + +#: .\templates\authopenid\delete.html.py:30 +msgid "Delete account permanently" +msgstr "姘镐箙鍒犻櫎甯愬彿" + +#: .\templates\authopenid\sendpw.html.py:7 +msgid "Account: Send a new password" +msgstr "鍙戦佷竴涓柊鐨勫瘑鐮" + +#: .\templates\authopenid\sendpw.html.py:9 +msgid "" +"Lost your password ? Here you can ask to reset your password. Enter the " +"username you use and you will get a confirmation email with your new " +"password. This new password will be activated only after you have clicked on " +"the link in the email." +msgstr "" +"涓㈠け浜嗘偍鐨勫瘑鐮侊紵浣犲彲浠ュ湪杩欓噷閲嶈瀵嗙爜銆傝緭鍏ョ敤鎴峰悕浣犱細鏀跺埌鏂扮殑瀵嗙爜鐨勯偖浠躲傚瘑鐮" +"鍙湁鎮ㄥ湪婵娲婚偖浠朵腑鐨勯摼鎺ユ墠浼氳婵娲汇" + +#: .\templates\authopenid\sendpw.html.py:26 +msgid "Send new password" +msgstr "鍙戦佹柊瀵嗙爜" + +#: .\templates\authopenid\settings.html.py:29 +msgid "Give your account a new password." +msgstr "淇敼瀵嗙爜" + +#: .\templates\authopenid\settings.html.py:31 +msgid "Add or update the email address associated with your account." +msgstr "娣诲姞鎴栬呮洿鏂版偍鐨勯偖浠跺湴鍧銆" + +#: .\templates\authopenid\settings.html.py:34 +msgid "Change openid associated to your account" +msgstr "淇敼鍜屼綘甯愬彿缁戝畾鐨凮penID鍦板潃" + +#: .\templates\authopenid\settings.html.py:38 +msgid "Erase your username and all your data from website" +msgstr "鍒犻櫎鎮ㄧ殑甯愬彿鍜屾墍鏈夊唴瀹" + +#: .\templates\authopenid\signup.html.py:7 +msgid "" +"\n" +"

Join

\n" +"

There are two ways to join: with an email + username, or with OpenID." +"
Enter information only for the type of sign up you want to do.

\n" +" " +msgstr "" + +#: .\templates\authopenid\signup.html.py:13 +msgid "Regular Signup" +msgstr "" + +#: .\templates\authopenid\signup.html.py:29 +msgid "Choose a Username:" +msgstr "" + +#: .\templates\authopenid\signup.html.py:31 +msgid "Enter Your Email Address:" +msgstr "" + +#: .\templates\authopenid\signup.html.py:32 +msgid "Choose a Password:" +msgstr "" + +#: .\templates\authopenid\signup.html.py:33 +msgid "Confirm Your Password:" +msgstr "" + +#: .\templates\authopenid\signup.html.py:35 +msgid "Sign up" +msgstr "" + +#: .\templates\authopenid\signup.html.py:39 +msgid "OpenID Signup" +msgstr "" + +#: .\templates\authopenid\signup.html.py:42 +msgid "Sign in with OpenID" +msgstr "" diff --git a/manage.py b/manage.py new file mode 100644 index 0000000000..b8c4be8eb9 --- /dev/null +++ b/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +try: + import settings # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/middleware/__init__.py b/middleware/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/middleware/pagesize.py b/middleware/pagesize.py new file mode 100644 index 0000000000..bb6c7aa39f --- /dev/null +++ b/middleware/pagesize.py @@ -0,0 +1,29 @@ +# used in questions +QUESTIONS_PAGE_SIZE = 10 +class QuestionsPageSizeMiddleware(object): + def process_request(self, request): + # Set flag to False by default. If it is equal to True, then need to be saved. + pagesize_changed = False + # get pagesize from session, if failed then get default value + user_page_size = request.session.get("pagesize", QUESTIONS_PAGE_SIZE) + # set pagesize equal to logon user specified value in database + if request.user.is_authenticated() and request.user.questions_per_page > 0: + user_page_size = request.user.questions_per_page + + try: + # get new pagesize from UI selection + pagesize = int(request.GET.get('pagesize', user_page_size)) + if pagesize <> user_page_size: + pagesize_changed = True + + except ValueError: + pagesize = user_page_size + + # save this pagesize to user database + if pagesize_changed: + if request.user.is_authenticated(): + user = request.user + user.questions_per_page = pagesize + user.save() + # put pagesize into session + request.session["pagesize"] = pagesize \ No newline at end of file diff --git a/settings.py b/settings.py new file mode 100644 index 0000000000..4aa70254f0 --- /dev/null +++ b/settings.py @@ -0,0 +1,125 @@ +# Django settings for lanai project. +import os.path + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +#David Cramer debug toolbar +INTERNAL_IPS = ('127.0.0.1',) +DEBUG_TOOLBAR_PANELS = ( + 'debug_toolbar.panels.sql.SQLDebugPanel', + 'debug_toolbar.panels.headers.HeaderDebugPanel', + 'debug_toolbar.panels.cache.CacheDebugPanel', + 'debug_toolbar.panels.profiler.ProfilerDebugPanel', + 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel', + 'debug_toolbar.panels.templates.TemplatesDebugPanel', +) + +DEBUG_TOOLBAR_CONFIG = { + "INTERCEPT_REDIRECTS":False +} + +#for OpenID auth +ugettext = lambda s: s +LOGIN_URL = '/%s%s' % (ugettext('account/'), ugettext('signin/')) + +#system will send admins email about error stacktrace if DEBUG=False +ADMINS = ( + ('Mike Chen', 'chagel@gmail.com'), +) +MANAGERS = ADMINS + +DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. +DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. +DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. + +SERVER_EMAIL = 'webmaster@cnprog.com' +DEFAULT_FROM_EMAIL = 'webmaster@cnprog.com' +EMAIL_HOST_USER = '' +EMAIL_HOST_PASSWORD = '' +EMAIL_SUBJECT_PREFIX = '[cnprog.com]' +EMAIL_HOST='smtp.gmail.com' +EMAIL_PORT='587' +EMAIL_USE_TLS=True + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'Asia/Chongqing Asia/Chungking' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +#LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'zh-cn' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + + +# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a +# trailing slash. +# Examples: "http://foo.com/media/", "/media/". +ADMIN_MEDIA_PREFIX = '/admin/media/' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = '$oo^&_m&qwbib=(_4m_n*zn-d=g#s0he5fx9xonnym#8p6yigm' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.load_template_source', + 'django.template.loaders.app_directories.load_template_source', +# 'django.template.loaders.eggs.load_template_source', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.gzip.GZipMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.locale.LocaleMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.middleware.transaction.TransactionMiddleware', + #'django.middleware.sqlprint.SqlPrintingMiddleware', + 'middleware.pagesize.QuestionsPageSizeMiddleware', + #'debug_toolbar.middleware.DebugToolbarMiddleware', +) + +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.core.context_processors.request', + 'django.core.context_processors.auth', +) + +ROOT_URLCONF = 'urls' + +TEMPLATE_DIRS = ( + os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'), +) + +FILE_UPLOAD_TEMP_DIR = os.path.join(os.path.dirname(__file__), 'tmp').replace('\\','/') +FILE_UPLOAD_HANDLERS = ("django.core.files.uploadhandler.MemoryFileUploadHandler", + "django.core.files.uploadhandler.TemporaryFileUploadHandler",) +DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' +# for user upload +ALLOW_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff') +# unit byte +ALLOW_MAX_FILE_SIZE = 1024 * 1024 + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.admin', + 'django.contrib.humanize', + 'forum', + 'django_authopenid', + 'debug_toolbar' , +) + +# User settings +from settings_local import * + diff --git a/settings_local.py.dist b/settings_local.py.dist new file mode 100644 index 0000000000..96f28b4e72 --- /dev/null +++ b/settings_local.py.dist @@ -0,0 +1,21 @@ +SITE_SRC_ROOT = '/Users/sailing/Development/cnprog_beta2' + +#for logging +import logging +LOG_FILENAME = '/Users/sailing/Development/cnprog_beta2/django.lanai.log' +logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,) + + +DATABASE_NAME = 'cnprog' # Or path to database file if using sqlite3. +DATABASE_USER = 'root' # Not used with sqlite3. +DATABASE_PASSWORD = '' # Not used with sqlite3. + + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = '/Users/sailing/Development/cnprog_beta2/templates/upfiles/' + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = 'http://127.0.0.1:8000/upfiles/' diff --git a/sql_scripts/cnprog.xml b/sql_scripts/cnprog.xml new file mode 100644 index 0000000000..95f9b36260 --- /dev/null +++ b/sql_scripts/cnprog.xml @@ -0,0 +1,1498 @@ + + + + + +/Users/sailing/Development/cnprog_beta2/sql_scripts + + +ENGINE=MyISAM AUTO_INCREMENT=103 DEFAULT CHARSET=latin1 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + +content_type_id + + +user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +author_id + + +deleted_by_id + + +last_edited_by_id + + +locked_by_id + + +question_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + +answer_id + + +author_id + + + + +ENGINE=InnoDB DEFAULT CHARSET=utf8 + + +
+ + +
+ + +name + + + + +ENGINE=InnoDB DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + + + + + + + + + +group_id, permission_id + + +permission_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + + + + +user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + + + + + + +content_type_id + + +content_type_id, codename + + + + +ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +username + + + + +ENGINE=InnoDB DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + + + + + + + + + +group_id + + +user_id, group_id + + + + +ENGINE=InnoDB DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + + + + + + + + + +permission_id + + +user_id, permission_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +badge_id + + +user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +slug + + +name, type + + + + + + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + +short_name + + +user_id + + + + + + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +user_id + + +book_id + + + + + + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +user_id + + +book_id + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + +book_id + + +question_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +content_type_id + + +user_id + + +content_type_id, object_id, user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +content_type_id + + +user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + +ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + + + +ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + + + + +user_id + + + + +ENGINE=InnoDB DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + + + + + + +user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +app_label, model + + + + +ENGINE=InnoDB DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + +ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + +ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +question_id + + +user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +content_type_id, object_id, user_id + + +content_type_id + + +user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +author_id + + +closed_by_id + + +deleted_by_id + + +last_activity_by_id + + +last_edited_by_id + + +locked_by_id + + + + +ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +author_id + + +question_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + + + + + + + + + +question_id, tag_id + + +tag_id + + + + +ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +question_id + + +user_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + + + + + + +name + + +created_by_id + + + + +ENGINE=InnoDB DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + + + + + + + + + +user_id + + +badge_id + + + + +ENGINE=InnoDB DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + + + + + + + + + + + +user_id + + +question_id + + + + +ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + + + + + + + + +content_type_id, object_id, user_id + + +content_type_id + + +user_id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +db.doc.option.mgr + + + + + + + + + + + + + diff --git a/sql_scripts/cnprog_new_install.sql b/sql_scripts/cnprog_new_install.sql new file mode 100644 index 0000000000..ac33a6ba91 --- /dev/null +++ b/sql_scripts/cnprog_new_install.sql @@ -0,0 +1,811 @@ +-- MySQL Administrator dump 1.4 +-- +-- ------------------------------------------------------ +-- Server version 5.0.67 + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; + + +-- +-- Create schema cnprog +-- + +CREATE DATABASE IF NOT EXISTS cnprog; +USE cnprog; + +-- +-- Definition of table `cnprog`.`answer` +-- + +DROP TABLE IF EXISTS `cnprog`.`answer`; +CREATE TABLE `cnprog`.`answer` ( + `id` int(11) NOT NULL auto_increment, + `question_id` int(11) NOT NULL, + `author_id` int(11) NOT NULL, + `added_at` datetime NOT NULL, + `wiki` tinyint(1) NOT NULL, + `wikified_at` datetime default NULL, + `accepted` tinyint(1) NOT NULL, + `deleted` tinyint(1) NOT NULL, + `deleted_by_id` int(11) default NULL, + `locked` tinyint(1) NOT NULL, + `locked_by_id` int(11) default NULL, + `locked_at` datetime default NULL, + `score` int(11) NOT NULL, + `vote_up_count` int(11) NOT NULL, + `vote_down_count` int(11) NOT NULL, + `comment_count` int(10) unsigned NOT NULL, + `offensive_flag_count` smallint(6) NOT NULL, + `last_edited_at` datetime default NULL, + `last_edited_by_id` int(11) default NULL, + `html` longtext NOT NULL, + PRIMARY KEY (`id`), + KEY `answer_question_id` (`question_id`), + KEY `answer_author_id` (`author_id`), + KEY `answer_deleted_by_id` (`deleted_by_id`), + KEY `answer_locked_by_id` (`locked_by_id`), + KEY `answer_last_edited_by_id` (`last_edited_by_id`), + CONSTRAINT `author_id_refs_id_192b0170` FOREIGN KEY (`author_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `deleted_by_id_refs_id_192b0170` FOREIGN KEY (`deleted_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `last_edited_by_id_refs_id_192b0170` FOREIGN KEY (`last_edited_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `locked_by_id_refs_id_192b0170` FOREIGN KEY (`locked_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `question_id_refs_id_7d6550c9` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8; + +-- +-- Definition of table `cnprog`.`auth_group` +-- + +DROP TABLE IF EXISTS `cnprog`.`auth_group`; +CREATE TABLE `cnprog`.`auth_group` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(80) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`auth_group` +-- + +-- +-- Definition of table `cnprog`.`auth_group_permissions` +-- + +DROP TABLE IF EXISTS `cnprog`.`auth_group_permissions`; +CREATE TABLE `cnprog`.`auth_group_permissions` ( + `id` int(11) NOT NULL auto_increment, + `group_id` int(11) NOT NULL, + `permission_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `group_id` (`group_id`,`permission_id`), + KEY `permission_id_refs_id_5886d21f` (`permission_id`), + CONSTRAINT `group_id_refs_id_3cea63fe` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`), + CONSTRAINT `permission_id_refs_id_5886d21f` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`auth_group_permissions` +-- + +-- +-- Definition of table `cnprog`.`auth_message` +-- + +DROP TABLE IF EXISTS `cnprog`.`auth_message`; +CREATE TABLE `cnprog`.`auth_message` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `message` longtext NOT NULL, + PRIMARY KEY (`id`), + KEY `auth_message_user_id` (`user_id`), + CONSTRAINT `user_id_refs_id_650f49a6` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`auth_message` +-- + +-- +-- Definition of table `cnprog`.`auth_permission` +-- + +DROP TABLE IF EXISTS `cnprog`.`auth_permission`; +CREATE TABLE `cnprog`.`auth_permission` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + `content_type_id` int(11) NOT NULL, + `codename` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `content_type_id` (`content_type_id`,`codename`), + KEY `auth_permission_content_type_id` (`content_type_id`), + CONSTRAINT `content_type_id_refs_id_728de91f` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=76 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`auth_permission` +-- +INSERT INTO `cnprog`.`auth_permission` VALUES (1,'Can add permission',1,'add_permission'), + (2,'Can change permission',1,'change_permission'), + (3,'Can delete permission',1,'delete_permission'), + (4,'Can add group',2,'add_group'), + (5,'Can change group',2,'change_group'), + (6,'Can delete group',2,'delete_group'), + (7,'Can add user',3,'add_user'), + (8,'Can change user',3,'change_user'), + (9,'Can delete user',3,'delete_user'), + (10,'Can add message',4,'add_message'), + (11,'Can change message',4,'change_message'), + (12,'Can delete message',4,'delete_message'), + (13,'Can add content type',5,'add_contenttype'), + (14,'Can change content type',5,'change_contenttype'), + (15,'Can delete content type',5,'delete_contenttype'), + (16,'Can add session',6,'add_session'), + (17,'Can change session',6,'change_session'), + (18,'Can delete session',6,'delete_session'), + (19,'Can add site',7,'add_site'), + (20,'Can change site',7,'change_site'), + (21,'Can delete site',7,'delete_site'), + (25,'Can add answer',9,'add_answer'), + (26,'Can change answer',9,'change_answer'), + (27,'Can delete answer',9,'delete_answer'), + (28,'Can add comment',10,'add_comment'), + (29,'Can change comment',10,'change_comment'), + (30,'Can delete comment',10,'delete_comment'), + (31,'Can add tag',11,'add_tag'), + (32,'Can change tag',11,'change_tag'), + (33,'Can delete tag',11,'delete_tag'), + (37,'Can add nonce',13,'add_nonce'), + (38,'Can change nonce',13,'change_nonce'), + (39,'Can delete nonce',13,'delete_nonce'), + (40,'Can add association',14,'add_association'), + (41,'Can change association',14,'change_association'), + (42,'Can delete association',14,'delete_association'), + (43,'Can add nonce',15,'add_nonce'), + (44,'Can change nonce',15,'change_nonce'), + (45,'Can delete nonce',15,'delete_nonce'), + (46,'Can add association',16,'add_association'), + (47,'Can change association',16,'change_association'), + (48,'Can delete association',16,'delete_association'), + (49,'Can add user association',17,'add_userassociation'), + (50,'Can change user association',17,'change_userassociation'), + (51,'Can delete user association',17,'delete_userassociation'), + (52,'Can add user password queue',18,'add_userpasswordqueue'), + (53,'Can change user password queue',18,'change_userpasswordqueue'), + (54,'Can delete user password queue',18,'delete_userpasswordqueue'), + (55,'Can add log entry',19,'add_logentry'), + (56,'Can change log entry',19,'change_logentry'), + (57,'Can delete log entry',19,'delete_logentry'), + (58,'Can add question',20,'add_question'), + (59,'Can change question',20,'change_question'), + (60,'Can delete question',20,'delete_question'), + (61,'Can add vote',21,'add_vote'), + (62,'Can change vote',21,'change_vote'), + (63,'Can delete vote',21,'delete_vote'), + (64,'Can add flagged item',22,'add_flaggeditem'), + (65,'Can change flagged item',22,'change_flaggeditem'), + (66,'Can delete flagged item',22,'delete_flaggeditem'), + (67,'Can add favorite question',23,'add_favoritequestion'), + (68,'Can change favorite question',23,'change_favoritequestion'), + (69,'Can delete favorite question',23,'delete_favoritequestion'), + (70,'Can add badge',24,'add_badge'), + (71,'Can change badge',24,'change_badge'), + (72,'Can delete badge',24,'delete_badge'), + (73,'Can add award',25,'add_award'), + (74,'Can change award',25,'change_award'), + (75,'Can delete award',25,'delete_award'); + +-- +-- Definition of table `cnprog`.`auth_user` +-- + +DROP TABLE IF EXISTS `cnprog`.`auth_user`; +CREATE TABLE `cnprog`.`auth_user` ( + `id` int(11) NOT NULL auto_increment, + `username` varchar(30) NOT NULL, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(30) NOT NULL, + `email` varchar(75) NOT NULL, + `password` varchar(128) NOT NULL, + `is_staff` tinyint(1) NOT NULL, + `is_active` tinyint(1) NOT NULL, + `is_superuser` tinyint(1) NOT NULL, + `last_login` datetime NOT NULL, + `date_joined` datetime NOT NULL, + `gold` smallint(6) NOT NULL default '0', + `silver` smallint(5) unsigned NOT NULL default '0', + `bronze` smallint(5) unsigned NOT NULL default '0', + `reputation` int(10) unsigned default '1', + `gravatar` varchar(128) default NULL, + `questions_per_page` smallint(5) unsigned default '10', + `last_seen` datetime default NULL, + `real_name` varchar(100) default NULL, + `website` varchar(200) default NULL, + `location` varchar(100) default NULL, + `date_of_birth` datetime default NULL, + `about` text, + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`) +) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`auth_user` +-- +INSERT INTO `cnprog`.`auth_user` VALUES (2,'chagel','','','chagel@gmail.com','sha1$6a2fb$0d2ffe90bcba542fc962f57967a88e507799cc74',1,1,1,'2008-12-16 15:35:17','2008-12-11 20:12:53',0,0,0,1,'8c1efc4f4618aa68b18c88f2bcaa5564',10,NULL,NULL,NULL,NULL,NULL,NULL), + (3,'mike','','','ichagel@yahoo.com','sha1$f7ef5$1015ae6b2c8a2774a028419d3c57e13145b83284',0,1,0,'2008-12-15 12:56:23','2008-12-15 12:56:23',0,0,0,1,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL), + (4,'sailingcai','','','sailingcai@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-23 06:14:45','2008-12-20 15:19:21',1,2,3,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','',NULL,''), + (5,'sailingcai1','','','1@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21',NULL,NULL,NULL,NULL,NULL), + (6,'sailing2','','','2@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (7,'sailing3','','','3@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (8,'sailing4','','','4@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (9,'sailing5','','','5@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (10,'sailing6','','','6@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (11,'sailing7','','','7@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (12,'sailing8','','','8@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (13,'sailing9','','','9@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (14,'sailing10','','','10@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (15,'sailing11','','','11@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (16,'sailing12','','','12@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (17,'sailing13','','','13@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (18,'sailing14','','','14@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (19,'sailing15','','','15@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (20,'sailing16','','','16@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (21,'sailing17','','','17@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (22,'sailing18','','','18@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (23,'sailing19','','','19@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (24,'sailing20','','','20@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (25,'sailing21','','','21@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (26,'sailing22','','','22@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (27,'sailing23','','','23@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (28,'sailing24','','','24@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (29,'sailing25','','','25@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (30,'sailing26','','','26@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (31,'sailing27','','','27@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (32,'sailing28','','','28@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (33,'sailing29','','','29@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (34,'sailing30','','','30@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (35,'sailing31','','','31@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (36,'sailing32','','','32@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (37,'sailing33','','','33@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (38,'sailing34','','','34@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (39,'sailing35','','','35@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (40,'sailing36','','','36@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (41,'sailing37','','','37@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (42,'sailing38','','','38@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (43,'sailing39','','','39@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (44,'sailing40','','','40@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (45,'sailing41','','','41@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (46,'sailing42','','','42@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (47,'sailing43','','','43@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (48,'sailing44','','','44@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (49,'sailing45','','','45@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (50,'sailing46','','','46@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (51,'sailing47','','','47@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (52,'sailing48','','','48@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (53,'sailing49','','','49@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (54,'sailing50','','','50@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (55,'sailing51','','','51@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (56,'sailing52','','','52@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (57,'sailing53','','','53@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (58,'sailing54','','','54@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (59,'sailing55','','','55@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (60,'sailing56','','','56@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (61,'sailing57','','','57@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (62,'sailing58','','','58@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (63,'sailing59','','','59@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (64,'sailing60','','','60@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (65,'sailing61','','','61@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (66,'sailing62','','','62@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (67,'sailing63','','','63@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (68,'sailing64','','','64@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (69,'sailing65','','','65@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (70,'sailing66','','','66@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (71,'sailing67','','','67@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (72,'sailing68','','','68@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (73,'sailing69','','','69@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (74,'sailing70','','','70@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (75,'sailing71','','','71@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (76,'sailing72','','','72@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (77,'sailing73','','','73@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (78,'sailing74','','','74@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (79,'sailing75','','','75@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (80,'sailing76','','','76@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (81,'sailing77','','','77@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (82,'sailing78','','','78@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (83,'sailing79','','','79@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (84,'sailing80','','','80@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (85,'sailing81','','','81@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (86,'sailing82','','','82@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (87,'sailing83','','','83@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (88,'sailing84','','','84@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (89,'sailing85','','','85@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (90,'sailing86','','','86@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (91,'sailing87','','','87@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (92,'sailing88','','','88@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (93,'sailing89','','','89@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (94,'sailing90','','','90@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (95,'sailing91','','','91@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (96,'sailing92','','','92@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (97,'sailing93','','','93@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (98,'sailing94','','','94@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (99,'sailing95','','','95@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (100,'sailing96','','','96@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (101,'sailing97','','','97@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (102,'sailing98','','','98@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''), + (103,'sailing99','','','99@gmail.com','sha1$a417c$ca7d9f2ad55666bf98068cc392b6f62450b216e0',0,1,0,'2008-12-20 15:19:21','2008-12-20 15:19:21',0,0,0,1,'a1cb9864605a32760518b90a4f9a0e73',10,'2008-12-20 15:19:21','','','','0000-00-00 00:00:00',''); + +-- +-- Definition of table `cnprog`.`auth_user_groups` +-- + +DROP TABLE IF EXISTS `cnprog`.`auth_user_groups`; +CREATE TABLE `cnprog`.`auth_user_groups` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `group_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`,`group_id`), + KEY `group_id_refs_id_f116770` (`group_id`), + CONSTRAINT `group_id_refs_id_f116770` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`), + CONSTRAINT `user_id_refs_id_7ceef80f` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`auth_user_groups` +-- + +-- +-- Definition of table `cnprog`.`auth_user_user_permissions` +-- + +DROP TABLE IF EXISTS `cnprog`.`auth_user_user_permissions`; +CREATE TABLE `cnprog`.`auth_user_user_permissions` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `permission_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`,`permission_id`), + KEY `permission_id_refs_id_67e79cb` (`permission_id`), + CONSTRAINT `permission_id_refs_id_67e79cb` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`), + CONSTRAINT `user_id_refs_id_dfbab7d` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`auth_user_user_permissions` +-- + +-- +-- Definition of table `cnprog`.`award` +-- + +DROP TABLE IF EXISTS `cnprog`.`award`; +CREATE TABLE `cnprog`.`award` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `badge_id` int(11) NOT NULL, + `awarded_at` datetime NOT NULL, + `notified` tinyint(1) NOT NULL, + PRIMARY KEY (`id`), + KEY `award_user_id` (`user_id`), + KEY `award_badge_id` (`badge_id`), + CONSTRAINT `badge_id_refs_id_651af0e1` FOREIGN KEY (`badge_id`) REFERENCES `badge` (`id`), + CONSTRAINT `user_id_refs_id_2d83e9b6` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`award` +-- + +-- +-- Definition of table `cnprog`.`badge` +-- + +DROP TABLE IF EXISTS `cnprog`.`badge`; +CREATE TABLE `cnprog`.`badge` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + `type` smallint(6) NOT NULL, + `slug` varchar(50) NOT NULL, + `description` varchar(300) NOT NULL, + `multiple` tinyint(1) NOT NULL, + `awarded_count` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`,`type`), + KEY `badge_slug` (`slug`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`badge` +-- + +-- +-- Definition of table `cnprog`.`comment` +-- + +DROP TABLE IF EXISTS `cnprog`.`comment`; +CREATE TABLE `cnprog`.`comment` ( + `id` int(11) NOT NULL auto_increment, + `content_type_id` int(11) NOT NULL, + `object_id` int(10) unsigned NOT NULL, + `user_id` int(11) NOT NULL, + `comment` varchar(300) NOT NULL, + `added_at` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`), + KEY `comment_content_type_id` (`content_type_id`), + KEY `comment_user_id` (`user_id`), + CONSTRAINT `content_type_id_refs_id_13a5866c` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`), + CONSTRAINT `user_id_refs_id_6be725e8` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`comment` +-- + +-- +-- Definition of table `cnprog`.`django_admin_log` +-- + +DROP TABLE IF EXISTS `cnprog`.`django_admin_log`; +CREATE TABLE `cnprog`.`django_admin_log` ( + `id` int(11) NOT NULL auto_increment, + `action_time` datetime NOT NULL, + `user_id` int(11) NOT NULL, + `content_type_id` int(11) default NULL, + `object_id` longtext, + `object_repr` varchar(200) NOT NULL, + `action_flag` smallint(5) unsigned NOT NULL, + `change_message` longtext NOT NULL, + PRIMARY KEY (`id`), + KEY `django_admin_log_user_id` (`user_id`), + KEY `django_admin_log_content_type_id` (`content_type_id`), + CONSTRAINT `content_type_id_refs_id_288599e6` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`), + CONSTRAINT `user_id_refs_id_c8665aa` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`django_admin_log` +-- +INSERT INTO `cnprog`.`django_admin_log` VALUES (1,'2008-12-18 23:41:41',2,7,'1','cnprog.com',2,'宸蹭慨鏀 domain 鍜 name 銆'); + +-- +-- Definition of table `cnprog`.`django_authopenid_association` +-- + +DROP TABLE IF EXISTS `cnprog`.`django_authopenid_association`; +CREATE TABLE `cnprog`.`django_authopenid_association` ( + `id` int(11) NOT NULL auto_increment, + `server_url` longtext NOT NULL, + `handle` varchar(255) NOT NULL, + `secret` longtext NOT NULL, + `issued` int(11) NOT NULL, + `lifetime` int(11) NOT NULL, + `assoc_type` longtext NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`django_authopenid_association` +-- +INSERT INTO `cnprog`.`django_authopenid_association` VALUES (2,'https://www.google.com/accounts/o8/ud','AOQobUfcCH4sgjsBGGscrzxIa5UM4clofAB6nixx8Qq_NWco4ynn_Kc4','u5cva43abzdwF8CJOFZfkzfk7x8=\n',1229022261,1229022261,'HMAC-SHA1'), + (3,'https://api.screenname.aol.com/auth/openidServer','diAyLjAgayAwIGJhT2VvYkdDZ21RSHJ4QldzQnhTdjIxV3BVbz0%3D-j5HRXRB1VbPyg48jGKE1Q70dfv76lGHEPwd9071%2FJ7f6SSw5YhakrwWpsVXtr34T6iHwPDdo6RU%3D','EmQL3+5oR6mFKIaeBNy6hXyUJ/w=\n',1229282202,1229282202,'HMAC-SHA1'), + (4,'https://open.login.yahooapis.com/openid/op/auth','JcBeY.uWXu2YjzbuCQiqFzAb0MIc7ATeKiPO4eAp3vluPMqZp_NCxepvMLGrJjxxDKTaNnr06wepMos8ap6SQYZiTi51tZ05lMWnpZAiOA1hsq_WMlEL7G9YE66GEA9A','QXiuN6B7E8nP5QhyHI3IB26t4SA=\n',1229282256,1229282256,'HMAC-SHA1'), + (5,'http://openid.claimid.com/server','{HMAC-SHA1}{494575fd}{uLEbxQ==}','GvPbkgMHh0QVPH7mStCGuWb2AKY=\n',1229288957,1229288957,'HMAC-SHA1'), + (6,'http://www.blogger.com/openid-server.g','oida-1229424484019-158830626','8gaU4aKnIFCLKIkHdxZQp7ZGNck=\n',1229424478,1229424478,'HMAC-SHA1'); + +-- +-- Definition of table `cnprog`.`django_authopenid_nonce` +-- + +DROP TABLE IF EXISTS `cnprog`.`django_authopenid_nonce`; +CREATE TABLE `cnprog`.`django_authopenid_nonce` ( + `id` int(11) NOT NULL auto_increment, + `server_url` varchar(255) NOT NULL, + `timestamp` int(11) NOT NULL, + `salt` varchar(40) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8; + +-- +-- Definition of table `cnprog`.`django_authopenid_userassociation` +-- + +DROP TABLE IF EXISTS `cnprog`.`django_authopenid_userassociation`; +CREATE TABLE `cnprog`.`django_authopenid_userassociation` ( + `id` int(11) NOT NULL auto_increment, + `openid_url` varchar(255) NOT NULL, + `user_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`), + CONSTRAINT `user_id_refs_id_163d208d` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`django_authopenid_userassociation` +-- +INSERT INTO `cnprog`.`django_authopenid_userassociation` VALUES (2,'https://www.google.com/accounts/o8/id?id=AItOawl7CVVHl4DWtteqj4dd_A23zKRwPZgOOjw',2), + (3,'https://me.yahoo.com/a/f8f2zXF91okYL4iN2Zh4P542a5s-#f4af2',3), + (4,'https://me.yahoo.com/sailingcai#6fa4e',4); + +-- +-- Definition of table `cnprog`.`django_authopenid_userpasswordqueue` +-- + +DROP TABLE IF EXISTS `cnprog`.`django_authopenid_userpasswordqueue`; +CREATE TABLE `cnprog`.`django_authopenid_userpasswordqueue` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `new_password` varchar(30) NOT NULL, + `confirm_key` varchar(40) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`), + CONSTRAINT `user_id_refs_id_76bcaaa4` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`django_authopenid_userpasswordqueue` +-- + +-- +-- Definition of table `cnprog`.`django_content_type` +-- + +DROP TABLE IF EXISTS `cnprog`.`django_content_type`; +CREATE TABLE `cnprog`.`django_content_type` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(100) NOT NULL, + `app_label` varchar(100) NOT NULL, + `model` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `app_label` (`app_label`,`model`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`django_content_type` +-- +INSERT INTO `cnprog`.`django_content_type` VALUES (1,'permission','auth','permission'), + (2,'group','auth','group'), + (3,'user','auth','user'), + (4,'message','auth','message'), + (5,'content type','contenttypes','contenttype'), + (6,'session','sessions','session'), + (7,'site','sites','site'), + (9,'answer','forum','answer'), + (10,'comment','forum','comment'), + (11,'tag','forum','tag'), + (13,'nonce','django_openidconsumer','nonce'), + (14,'association','django_openidconsumer','association'), + (15,'nonce','django_authopenid','nonce'), + (16,'association','django_authopenid','association'), + (17,'user association','django_authopenid','userassociation'), + (18,'user password queue','django_authopenid','userpasswordqueue'), + (19,'log entry','admin','logentry'), + (20,'question','forum','question'), + (21,'vote','forum','vote'), + (22,'flagged item','forum','flaggeditem'), + (23,'favorite question','forum','favoritequestion'), + (24,'badge','forum','badge'), + (25,'award','forum','award'); + +-- +-- Definition of table `cnprog`.`django_session` +-- + +DROP TABLE IF EXISTS `cnprog`.`django_session`; +CREATE TABLE `cnprog`.`django_session` ( + `session_key` varchar(40) NOT NULL, + `session_data` longtext NOT NULL, + `expire_date` datetime NOT NULL, + PRIMARY KEY (`session_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Definition of table `cnprog`.`django_site` +-- + +DROP TABLE IF EXISTS `cnprog`.`django_site`; +CREATE TABLE `cnprog`.`django_site` ( + `id` int(11) NOT NULL auto_increment, + `domain` varchar(100) NOT NULL, + `name` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`django_site` +-- +INSERT INTO `cnprog`.`django_site` VALUES (1,'cnprog.com','CNProg.com'); + +-- +-- Definition of table `cnprog`.`favorite_question` +-- + +DROP TABLE IF EXISTS `cnprog`.`favorite_question`; +CREATE TABLE `cnprog`.`favorite_question` ( + `id` int(11) NOT NULL auto_increment, + `question_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `added_at` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `favorite_question_question_id` (`question_id`), + KEY `favorite_question_user_id` (`user_id`), + CONSTRAINT `question_id_refs_id_1ebe1cc3` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`), + CONSTRAINT `user_id_refs_id_52853822` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`favorite_question` +-- + +-- +-- Definition of table `cnprog`.`flagged_item` +-- + +DROP TABLE IF EXISTS `cnprog`.`flagged_item`; +CREATE TABLE `cnprog`.`flagged_item` ( + `id` int(11) NOT NULL auto_increment, + `content_type_id` int(11) NOT NULL, + `object_id` int(10) unsigned NOT NULL, + `user_id` int(11) NOT NULL, + `flagged_at` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`), + KEY `flagged_item_content_type_id` (`content_type_id`), + KEY `flagged_item_user_id` (`user_id`), + CONSTRAINT `content_type_id_refs_id_76e44d74` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`), + CONSTRAINT `user_id_refs_id_35e3c608` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`flagged_item` +-- + +-- +-- Definition of table `cnprog`.`question` +-- + +DROP TABLE IF EXISTS `cnprog`.`question`; +CREATE TABLE `cnprog`.`question` ( + `id` int(11) NOT NULL auto_increment, + `title` varchar(300) NOT NULL, + `author_id` int(11) NOT NULL, + `added_at` datetime NOT NULL, + `wiki` tinyint(1) NOT NULL, + `wikified_at` datetime default NULL, + `answer_accepted` tinyint(1) NOT NULL, + `closed` tinyint(1) NOT NULL, + `closed_by_id` int(11) default NULL, + `closed_at` datetime default NULL, + `close_reason` smallint(6) default NULL, + `deleted` tinyint(1) NOT NULL, + `deleted_at` datetime default NULL, + `deleted_by_id` int(11) default NULL, + `locked` tinyint(1) NOT NULL, + `locked_by_id` int(11) default NULL, + `locked_at` datetime default NULL, + `vote_up_count` int(11) NOT NULL, + `vote_down_count` int(11) NOT NULL, + `score` int(11) NOT NULL, + `answer_count` int(10) unsigned NOT NULL, + `comment_count` int(10) unsigned NOT NULL, + `view_count` int(10) unsigned NOT NULL, + `offensive_flag_count` smallint(6) NOT NULL, + `favourite_count` int(10) unsigned NOT NULL, + `last_edited_at` datetime default NULL, + `last_edited_by_id` int(11) default NULL, + `last_activity_at` datetime NOT NULL, + `last_activity_by_id` int(11) NOT NULL, + `tagnames` varchar(125) NOT NULL, + `summary` varchar(180) NOT NULL, + `html` longtext NOT NULL, + PRIMARY KEY (`id`), + KEY `question_author_id` (`author_id`), + KEY `question_closed_by_id` (`closed_by_id`), + KEY `question_deleted_by_id` (`deleted_by_id`), + KEY `question_locked_by_id` (`locked_by_id`), + KEY `question_last_edited_by_id` (`last_edited_by_id`), + KEY `question_last_activity_by_id` (`last_activity_by_id`), + CONSTRAINT `author_id_refs_id_56e9d00c` FOREIGN KEY (`author_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `closed_by_id_refs_id_56e9d00c` FOREIGN KEY (`closed_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `deleted_by_id_refs_id_56e9d00c` FOREIGN KEY (`deleted_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `last_activity_by_id_refs_id_56e9d00c` FOREIGN KEY (`last_activity_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `last_edited_by_id_refs_id_56e9d00c` FOREIGN KEY (`last_edited_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `locked_by_id_refs_id_56e9d00c` FOREIGN KEY (`locked_by_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; + +-- +-- Definition of table `cnprog`.`question_tags` +-- + +DROP TABLE IF EXISTS `cnprog`.`question_tags`; +CREATE TABLE `cnprog`.`question_tags` ( + `id` int(11) NOT NULL auto_increment, + `question_id` int(11) NOT NULL, + `tag_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `question_id` (`question_id`,`tag_id`), + KEY `tag_id_refs_id_43fcb953` (`tag_id`), + CONSTRAINT `question_id_refs_id_266147c6` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`), + CONSTRAINT `tag_id_refs_id_43fcb953` FOREIGN KEY (`tag_id`) REFERENCES `tag` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8; + +-- +-- Definition of table `cnprog`.`tag` +-- + +DROP TABLE IF EXISTS `cnprog`.`tag`; +CREATE TABLE `cnprog`.`tag` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(255) NOT NULL, + `created_by_id` int(11) NOT NULL, + `used_count` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`), + KEY `tag_created_by_id` (`created_by_id`), + CONSTRAINT `created_by_id_refs_id_47205d6d` FOREIGN KEY (`created_by_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; + +-- +-- Definition of table `cnprog`.`user_badge` +-- + +DROP TABLE IF EXISTS `cnprog`.`user_badge`; +CREATE TABLE `cnprog`.`user_badge` ( + `id` int(10) unsigned NOT NULL auto_increment, + `user_id` int(10) unsigned NOT NULL, + `badge_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Definition of table `cnprog`.`user_favorite_questions` +-- + +DROP TABLE IF EXISTS `cnprog`.`user_favorite_questions`; +CREATE TABLE `cnprog`.`user_favorite_questions` ( + `id` int(10) unsigned NOT NULL auto_increment, + `user_id` int(10) unsigned NOT NULL, + `question_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`user_favorite_questions` +-- + +DROP TABLE IF EXISTS `cnprog`.`vote`; +CREATE TABLE `cnprog`.`vote` ( + `id` int(11) NOT NULL auto_increment, + `content_type_id` int(11) NOT NULL, + `object_id` int(10) unsigned NOT NULL, + `user_id` int(11) NOT NULL, + `vote` smallint(6) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`), + KEY `vote_content_type_id` (`content_type_id`), + KEY `vote_user_id` (`user_id`), + CONSTRAINT `content_type_id_refs_id_50124414` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`), + CONSTRAINT `user_id_refs_id_760a4df0` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `cnprog`.`vote` +-- + + + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/sql_scripts/cnprog_new_install_2009_02_28.sql b/sql_scripts/cnprog_new_install_2009_02_28.sql new file mode 100644 index 0000000000..80b9fced84 --- /dev/null +++ b/sql_scripts/cnprog_new_install_2009_02_28.sql @@ -0,0 +1,456 @@ +SET FOREIGN_KEY_CHECKS = 0; + +CREATE TABLE `activity` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `activity_type` smallint(6) NOT NULL, + `active_at` datetime NOT NULL, + `content_type_id` int(11) NOT NULL, + `object_id` int(10) unsigned NOT NULL, + `is_auditted` tinyint(1) default '0', + PRIMARY KEY (`id`), + KEY `activity_user_id` (`user_id`), + KEY `activity_content_type_id` (`content_type_id`) +) ENGINE=MyISAM AUTO_INCREMENT=103 DEFAULT CHARSET=utf8; + + +CREATE TABLE `answer` ( + `id` int(11) NOT NULL auto_increment, + `question_id` int(11) NOT NULL, + `author_id` int(11) NOT NULL, + `added_at` datetime NOT NULL, + `wiki` tinyint(1) NOT NULL, + `wikified_at` datetime default NULL, + `accepted` tinyint(1) NOT NULL, + `deleted` tinyint(1) NOT NULL, + `deleted_by_id` int(11) default NULL, + `locked` tinyint(1) NOT NULL, + `locked_by_id` int(11) default NULL, + `locked_at` datetime default NULL, + `score` int(11) NOT NULL, + `comment_count` int(10) unsigned NOT NULL, + `offensive_flag_count` smallint(6) NOT NULL, + `last_edited_at` datetime default NULL, + `last_edited_by_id` int(11) default NULL, + `html` longtext NOT NULL, + `vote_up_count` int(11) NOT NULL, + `vote_down_count` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `answer_question_id` (`question_id`), + KEY `answer_author_id` (`author_id`), + KEY `answer_deleted_by_id` (`deleted_by_id`), + KEY `answer_locked_by_id` (`locked_by_id`), + KEY `answer_last_edited_by_id` (`last_edited_by_id`), + CONSTRAINT `author_id_refs_id_192b0170` FOREIGN KEY (`author_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `deleted_by_id_refs_id_192b0170` FOREIGN KEY (`deleted_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `last_edited_by_id_refs_id_192b0170` FOREIGN KEY (`last_edited_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `locked_by_id_refs_id_192b0170` FOREIGN KEY (`locked_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `question_id_refs_id_7d6550c9` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8; + + +CREATE TABLE `answer_revision` ( + `id` int(11) NOT NULL auto_increment, + `answer_id` int(11) NOT NULL, + `revision` int(10) unsigned NOT NULL, + `author_id` int(11) NOT NULL, + `revised_at` datetime NOT NULL, + `summary` varchar(300) collate utf8_unicode_ci NOT NULL, + `text` longtext collate utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `answer_revision_answer_id` (`answer_id`), + KEY `answer_revision_author_id` (`author_id`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; + + +CREATE TABLE `auth_group` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(80) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `auth_group_permissions` ( + `id` int(11) NOT NULL auto_increment, + `group_id` int(11) NOT NULL, + `permission_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `group_id` (`group_id`,`permission_id`), + KEY `permission_id_refs_id_5886d21f` (`permission_id`), + CONSTRAINT `group_id_refs_id_3cea63fe` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`), + CONSTRAINT `permission_id_refs_id_5886d21f` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `auth_message` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `message` longtext NOT NULL, + PRIMARY KEY (`id`), + KEY `auth_message_user_id` (`user_id`), + CONSTRAINT `user_id_refs_id_650f49a6` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8; + + +CREATE TABLE `auth_permission` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + `content_type_id` int(11) NOT NULL, + `codename` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `content_type_id` (`content_type_id`,`codename`), + KEY `auth_permission_content_type_id` (`content_type_id`), + CONSTRAINT `content_type_id_refs_id_728de91f` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8; + + +CREATE TABLE `auth_user` ( + `id` int(11) NOT NULL auto_increment, + `username` varchar(30) NOT NULL, + `first_name` varchar(30) NOT NULL, + `last_name` varchar(30) NOT NULL, + `email` varchar(75) NOT NULL, + `password` varchar(128) NOT NULL, + `is_staff` tinyint(1) NOT NULL, + `is_active` tinyint(1) NOT NULL, + `is_superuser` tinyint(1) NOT NULL, + `last_login` datetime NOT NULL, + `date_joined` datetime NOT NULL, + `gold` smallint(6) NOT NULL default '0', + `silver` smallint(5) unsigned NOT NULL default '0', + `bronze` smallint(5) unsigned NOT NULL default '0', + `reputation` int(10) unsigned default '1', + `gravatar` varchar(128) default NULL, + `questions_per_page` smallint(5) unsigned default '10', + `last_seen` datetime default NULL, + `real_name` varchar(100) default NULL, + `website` varchar(200) default NULL, + `location` varchar(100) default NULL, + `date_of_birth` datetime default NULL, + `about` text, + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`) +) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8; + + +CREATE TABLE `auth_user_groups` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `group_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`,`group_id`), + KEY `group_id_refs_id_f116770` (`group_id`), + CONSTRAINT `group_id_refs_id_f116770` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`), + CONSTRAINT `user_id_refs_id_7ceef80f` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `auth_user_user_permissions` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `permission_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`,`permission_id`), + KEY `permission_id_refs_id_67e79cb` (`permission_id`), + CONSTRAINT `permission_id_refs_id_67e79cb` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`), + CONSTRAINT `user_id_refs_id_dfbab7d` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `award` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `badge_id` int(11) NOT NULL, + `awarded_at` datetime NOT NULL, + `notified` tinyint(1) NOT NULL, + `content_type_id` int(11) default NULL, + `object_id` int(10) default NULL, + PRIMARY KEY (`id`), + KEY `award_user_id` (`user_id`), + KEY `award_badge_id` (`badge_id`), + CONSTRAINT `badge_id_refs_id_651af0e1` FOREIGN KEY (`badge_id`) REFERENCES `badge` (`id`), + CONSTRAINT `user_id_refs_id_2d83e9b6` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; + + +CREATE TABLE `badge` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + `type` smallint(6) NOT NULL, + `slug` varchar(50) NOT NULL, + `description` varchar(300) NOT NULL, + `multiple` tinyint(1) NOT NULL, + `awarded_count` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`,`type`), + KEY `badge_slug` (`slug`) +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8; + + +CREATE TABLE `comment` ( + `id` int(11) NOT NULL auto_increment, + `content_type_id` int(11) NOT NULL, + `object_id` int(10) unsigned NOT NULL, + `user_id` int(11) NOT NULL, + `comment` varchar(300) NOT NULL, + `added_at` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `comment_content_type_id` (`content_type_id`), + KEY `comment_user_id` (`user_id`), + KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`), + CONSTRAINT `content_type_id_refs_id_13a5866c` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`), + CONSTRAINT `user_id_refs_id_6be725e8` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; + + +CREATE TABLE `django_admin_log` ( + `id` int(11) NOT NULL auto_increment, + `action_time` datetime NOT NULL, + `user_id` int(11) NOT NULL, + `content_type_id` int(11) default NULL, + `object_id` longtext, + `object_repr` varchar(200) NOT NULL, + `action_flag` smallint(5) unsigned NOT NULL, + `change_message` longtext NOT NULL, + PRIMARY KEY (`id`), + KEY `django_admin_log_user_id` (`user_id`), + KEY `django_admin_log_content_type_id` (`content_type_id`), + CONSTRAINT `content_type_id_refs_id_288599e6` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`), + CONSTRAINT `user_id_refs_id_c8665aa` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + + +CREATE TABLE `django_authopenid_association` ( + `id` int(11) NOT NULL auto_increment, + `server_url` longtext NOT NULL, + `handle` varchar(255) NOT NULL, + `secret` longtext NOT NULL, + `issued` int(11) NOT NULL, + `lifetime` int(11) NOT NULL, + `assoc_type` longtext NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + + +CREATE TABLE `django_authopenid_nonce` ( + `id` int(11) NOT NULL auto_increment, + `server_url` varchar(255) NOT NULL, + `timestamp` int(11) NOT NULL, + `salt` varchar(40) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8; + + +CREATE TABLE `django_authopenid_userassociation` ( + `id` int(11) NOT NULL auto_increment, + `openid_url` varchar(255) NOT NULL, + `user_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`), + CONSTRAINT `user_id_refs_id_163d208d` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + + +CREATE TABLE `django_authopenid_userpasswordqueue` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `new_password` varchar(30) NOT NULL, + `confirm_key` varchar(40) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_id` (`user_id`), + CONSTRAINT `user_id_refs_id_76bcaaa4` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `django_content_type` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(100) NOT NULL, + `app_label` varchar(100) NOT NULL, + `model` varchar(100) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `app_label` (`app_label`,`model`) +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8; + + +CREATE TABLE `django_session` ( + `session_key` varchar(40) NOT NULL, + `session_data` longtext NOT NULL, + `expire_date` datetime NOT NULL, + PRIMARY KEY (`session_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `django_site` ( + `id` int(11) NOT NULL auto_increment, + `domain` varchar(100) NOT NULL, + `name` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + + +CREATE TABLE `favorite_question` ( + `id` int(11) NOT NULL auto_increment, + `question_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `added_at` datetime NOT NULL, + PRIMARY KEY (`id`), + KEY `favorite_question_question_id` (`question_id`), + KEY `favorite_question_user_id` (`user_id`), + CONSTRAINT `question_id_refs_id_1ebe1cc3` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`), + CONSTRAINT `user_id_refs_id_52853822` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + + +CREATE TABLE `flagged_item` ( + `id` int(11) NOT NULL auto_increment, + `content_type_id` int(11) NOT NULL, + `object_id` int(10) unsigned NOT NULL, + `user_id` int(11) NOT NULL, + `flagged_at` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`), + KEY `flagged_item_content_type_id` (`content_type_id`), + KEY `flagged_item_user_id` (`user_id`), + CONSTRAINT `content_type_id_refs_id_76e44d74` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`), + CONSTRAINT `user_id_refs_id_35e3c608` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + + +CREATE TABLE `question` ( + `id` int(11) NOT NULL auto_increment, + `title` varchar(300) NOT NULL, + `author_id` int(11) NOT NULL, + `added_at` datetime NOT NULL, + `wiki` tinyint(1) NOT NULL, + `wikified_at` datetime default NULL, + `answer_accepted` tinyint(1) NOT NULL, + `closed` tinyint(1) NOT NULL, + `closed_by_id` int(11) default NULL, + `closed_at` datetime default NULL, + `close_reason` smallint(6) default NULL, + `deleted` tinyint(1) NOT NULL, + `deleted_at` datetime default NULL, + `deleted_by_id` int(11) default NULL, + `locked` tinyint(1) NOT NULL, + `locked_by_id` int(11) default NULL, + `locked_at` datetime default NULL, + `score` int(11) NOT NULL, + `answer_count` int(10) unsigned NOT NULL, + `comment_count` int(10) unsigned NOT NULL, + `view_count` int(10) unsigned NOT NULL, + `offensive_flag_count` smallint(6) NOT NULL, + `favourite_count` int(10) unsigned NOT NULL, + `last_edited_at` datetime default NULL, + `last_edited_by_id` int(11) default NULL, + `last_activity_at` datetime NOT NULL, + `last_activity_by_id` int(11) NOT NULL, + `tagnames` varchar(125) NOT NULL, + `summary` varchar(180) NOT NULL, + `html` longtext NOT NULL, + `vote_up_count` int(11) NOT NULL, + `vote_down_count` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `question_author_id` (`author_id`), + KEY `question_closed_by_id` (`closed_by_id`), + KEY `question_deleted_by_id` (`deleted_by_id`), + KEY `question_locked_by_id` (`locked_by_id`), + KEY `question_last_edited_by_id` (`last_edited_by_id`), + KEY `question_last_activity_by_id` (`last_activity_by_id`), + CONSTRAINT `author_id_refs_id_56e9d00c` FOREIGN KEY (`author_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `closed_by_id_refs_id_56e9d00c` FOREIGN KEY (`closed_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `deleted_by_id_refs_id_56e9d00c` FOREIGN KEY (`deleted_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `last_activity_by_id_refs_id_56e9d00c` FOREIGN KEY (`last_activity_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `last_edited_by_id_refs_id_56e9d00c` FOREIGN KEY (`last_edited_by_id`) REFERENCES `auth_user` (`id`), + CONSTRAINT `locked_by_id_refs_id_56e9d00c` FOREIGN KEY (`locked_by_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; + + +CREATE TABLE `question_revision` ( + `id` int(11) NOT NULL auto_increment, + `question_id` int(11) NOT NULL, + `revision` int(10) unsigned NOT NULL, + `title` varchar(300) NOT NULL, + `author_id` int(11) NOT NULL, + `revised_at` datetime NOT NULL, + `tagnames` varchar(125) NOT NULL, + `summary` varchar(300) NOT NULL, + `text` longtext NOT NULL, + PRIMARY KEY (`id`), + KEY `question_revision_question_id` (`question_id`), + KEY `question_revision_author_id` (`author_id`) +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; + + +CREATE TABLE `question_tags` ( + `id` int(11) NOT NULL auto_increment, + `question_id` int(11) NOT NULL, + `tag_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `question_id` (`question_id`,`tag_id`), + KEY `tag_id_refs_id_43fcb953` (`tag_id`), + CONSTRAINT `question_id_refs_id_266147c6` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`), + CONSTRAINT `tag_id_refs_id_43fcb953` FOREIGN KEY (`tag_id`) REFERENCES `tag` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; + + +CREATE TABLE `repute` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `positive` smallint(6) NOT NULL, + `negative` smallint(6) NOT NULL, + `question_id` int(11) NOT NULL, + `reputed_at` datetime NOT NULL, + `reputation_type` smallint(6) NOT NULL, + `reputation` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `repute_user_id` (`user_id`), + KEY `repute_question_id` (`question_id`) +) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; + + +CREATE TABLE `tag` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(255) NOT NULL, + `created_by_id` int(11) NOT NULL, + `used_count` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`), + KEY `tag_created_by_id` (`created_by_id`), + CONSTRAINT `created_by_id_refs_id_47205d6d` FOREIGN KEY (`created_by_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; + + +CREATE TABLE `user_badge` ( + `id` int(10) unsigned NOT NULL auto_increment, + `user_id` int(10) unsigned NOT NULL, + `badge_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `user_favorite_questions` ( + `id` int(10) unsigned NOT NULL auto_increment, + `user_id` int(10) unsigned NOT NULL, + `question_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `vote` ( + `id` int(11) NOT NULL auto_increment, + `content_type_id` int(11) NOT NULL, + `object_id` int(10) unsigned NOT NULL, + `user_id` int(11) NOT NULL, + `vote` smallint(6) NOT NULL, + `voted_at` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`), + KEY `vote_content_type_id` (`content_type_id`), + KEY `vote_user_id` (`user_id`), + CONSTRAINT `content_type_id_refs_id_50124414` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`), + CONSTRAINT `user_id_refs_id_760a4df0` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; + + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/sql_scripts/cnprog_new_install_2009_03_31.sql b/sql_scripts/cnprog_new_install_2009_03_31.sql new file mode 100644 index 0000000000..c2c69f3625 --- /dev/null +++ b/sql_scripts/cnprog_new_install_2009_03_31.sql @@ -0,0 +1,891 @@ +USE cnprog; + + +/************ Update: Tables ***************/ + +/******************** Add Table: activity ************************/ + +/* Build Table Structure */ +CREATE TABLE activity +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + activity_type SMALLINT NOT NULL, + active_at DATETIME NOT NULL, + content_type_id INTEGER NOT NULL, + object_id INTEGER UNSIGNED NOT NULL, + is_auditted TINYINT NULL DEFAULT 0 +) ENGINE=MyISAM AUTO_INCREMENT=103 DEFAULT CHARSET=latin1; + +/* Table Items: activity */ + +/* Add Indexes for: activity */ +CREATE INDEX activity_content_type_id ON activity (content_type_id); +CREATE INDEX activity_user_id ON activity (user_id); + +/******************** Add Table: answer ************************/ + +/* Build Table Structure */ +CREATE TABLE answer +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + question_id INTEGER NOT NULL, + author_id INTEGER NOT NULL, + added_at DATETIME NOT NULL, + wiki TINYINT NOT NULL, + wikified_at DATETIME NULL, + accepted TINYINT NOT NULL, + deleted TINYINT NOT NULL, + deleted_by_id INTEGER NULL, + locked TINYINT NOT NULL, + locked_by_id INTEGER NULL, + locked_at DATETIME NULL, + score INTEGER NOT NULL, + comment_count INTEGER UNSIGNED NOT NULL, + offensive_flag_count SMALLINT NOT NULL, + last_edited_at DATETIME NULL, + last_edited_by_id INTEGER NULL, + html LONGTEXT NOT NULL, + vote_up_count INTEGER NOT NULL, + vote_down_count INTEGER NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8; + +/* Table Items: answer */ + +/* Add Indexes for: answer */ +CREATE INDEX answer_author_id ON answer (author_id); +CREATE INDEX answer_deleted_by_id ON answer (deleted_by_id); +CREATE INDEX answer_last_edited_by_id ON answer (last_edited_by_id); +CREATE INDEX answer_locked_by_id ON answer (locked_by_id); +CREATE INDEX answer_question_id ON answer (question_id); + +/******************** Add Table: answer_revision ************************/ + +/* Build Table Structure */ +CREATE TABLE answer_revision +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + answer_id INTEGER NOT NULL, + revision INTEGER UNSIGNED NOT NULL, + author_id INTEGER NOT NULL, + revised_at DATETIME NOT NULL, + summary TEXT NOT NULL, + `text` LONGTEXT NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +/* Table Items: answer_revision */ + +/* Add Indexes for: answer_revision */ +CREATE INDEX answer_revision_answer_id ON answer_revision (answer_id); +CREATE INDEX answer_revision_author_id ON answer_revision (author_id); + +/******************** Add Table: auth_group ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_group +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(80) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: auth_group */ + +/* Add Indexes for: auth_group */ +CREATE UNIQUE INDEX name ON auth_group (name); + +/******************** Add Table: auth_group_permissions ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_group_permissions +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + group_id INTEGER NOT NULL, + permission_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: auth_group_permissions */ + +/* Add Indexes for: auth_group_permissions */ +CREATE UNIQUE INDEX group_id ON auth_group_permissions (group_id, permission_id); +CREATE INDEX permission_id_refs_id_5886d21f ON auth_group_permissions (permission_id); + +/******************** Add Table: auth_message ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_message +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + message LONGTEXT NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8; + +/* Table Items: auth_message */ + +/* Add Indexes for: auth_message */ +CREATE INDEX auth_message_user_id ON auth_message (user_id); + +/******************** Add Table: auth_permission ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_permission +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50) NOT NULL, + content_type_id INTEGER NOT NULL, + codename VARCHAR(100) NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8; + +/* Table Items: auth_permission */ + +/* Add Indexes for: auth_permission */ +CREATE INDEX auth_permission_content_type_id ON auth_permission (content_type_id); +CREATE UNIQUE INDEX content_type_id ON auth_permission (content_type_id, codename); + +/******************** Add Table: auth_user ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_user +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(30) NOT NULL, + first_name VARCHAR(30) NOT NULL, + last_name VARCHAR(30) NOT NULL, + email VARCHAR(75) NOT NULL, + password VARCHAR(128) NOT NULL, + is_staff TINYINT NOT NULL, + is_active TINYINT NOT NULL, + is_superuser TINYINT NOT NULL, + last_login DATETIME NOT NULL, + date_joined DATETIME NOT NULL, + gold SMALLINT NOT NULL DEFAULT 0, + silver SMALLINT UNSIGNED NOT NULL DEFAULT 0, + bronze SMALLINT UNSIGNED NOT NULL DEFAULT 0, + reputation INTEGER UNSIGNED NULL DEFAULT 1, + gravatar VARCHAR(128) NULL, + questions_per_page SMALLINT UNSIGNED NULL DEFAULT 10, + last_seen DATETIME NULL, + real_name VARCHAR(100) NULL, + website VARCHAR(200) NULL, + location VARCHAR(100) NULL, + date_of_birth DATETIME NULL, + about TEXT NULL +) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8; + +/* Table Items: auth_user */ + +/* Add Indexes for: auth_user */ +CREATE UNIQUE INDEX username ON auth_user (username); + +/******************** Add Table: auth_user_groups ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_user_groups +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + group_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: auth_user_groups */ + +/* Add Indexes for: auth_user_groups */ +CREATE INDEX group_id_refs_id_f116770 ON auth_user_groups (group_id); +CREATE UNIQUE INDEX user_id ON auth_user_groups (user_id, group_id); + +/******************** Add Table: auth_user_user_permissions ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_user_user_permissions +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + permission_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: auth_user_user_permissions */ + +/* Add Indexes for: auth_user_user_permissions */ +CREATE INDEX permission_id_refs_id_67e79cb ON auth_user_user_permissions (permission_id); +CREATE UNIQUE INDEX user_id ON auth_user_user_permissions (user_id, permission_id); + +/******************** Add Table: award ************************/ + +/* Build Table Structure */ +CREATE TABLE award +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + badge_id INTEGER NOT NULL, + awarded_at DATETIME NOT NULL, + notified TINYINT NOT NULL, + content_type_id INTEGER NULL, + object_id INTEGER NULL +) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; + +/* Table Items: award */ + +/* Add Indexes for: award */ +CREATE INDEX award_badge_id ON award (badge_id); +CREATE INDEX award_user_id ON award (user_id); + +/******************** Add Table: badge ************************/ + +/* Build Table Structure */ +CREATE TABLE badge +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50) NOT NULL, + `type` SMALLINT NOT NULL, + slug VARCHAR(50) NOT NULL, + description TEXT NOT NULL, + multiple TINYINT NOT NULL, + awarded_count INTEGER UNSIGNED NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8; + +/* Table Items: badge */ + +/* Add Indexes for: badge */ +CREATE INDEX badge_slug ON badge (slug); +CREATE UNIQUE INDEX name ON badge (name, `type`); + +/******************** Add Table: book ************************/ + +/* Build Table Structure */ +CREATE TABLE book +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + short_name VARCHAR(255) NOT NULL, + author VARCHAR(255) NOT NULL, + user_id INTEGER NULL, + price DECIMAL(10, 2) NULL, + pages SMALLINT NULL, + published_at DATE NOT NULL, + publication VARCHAR(255) NOT NULL, + cover_img VARCHAR(255) NULL, + tagnames VARCHAR(125) NULL, + added_at DATETIME NOT NULL, + last_edited_at DATETIME NOT NULL +) TYPE=InnoDB; + +/* Table Items: book */ + +/* Add Indexes for: book */ +CREATE UNIQUE INDEX book_short_name_Idx ON book (short_name); +CREATE INDEX fk_books_auth_user ON book (user_id); + +/******************** Add Table: book_author_info ************************/ + +/* Build Table Structure */ +CREATE TABLE book_author_info +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + blog_url VARCHAR(255) NULL, + user_id INTEGER NOT NULL, + added_at DATETIME NOT NULL, + last_edited_at DATETIME NOT NULL +) TYPE=InnoDB; + +/* Table Items: book_author_info */ + +/* Add Indexes for: book_author_info */ +CREATE INDEX fk_book_author_info_auth_user ON book_author_info (user_id); + +/******************** Add Table: book_author_rss ************************/ + +/* Build Table Structure */ +CREATE TABLE book_author_rss +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + url VARCHAR(255) NOT NULL, + rss_created_at DATETIME NOT NULL, + user_id INTEGER NOT NULL, + added_at DATETIME NOT NULL +) TYPE=InnoDB; + +/* Table Items: book_author_rss */ + +/* Add Indexes for: book_author_rss */ +CREATE INDEX fk_book_author_rss_auth_user ON book_author_rss (user_id); + +/******************** Add Table: book_question ************************/ + +/* Build Table Structure */ +CREATE TABLE book_question +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + book_id INTEGER NOT NULL, + question_id INTEGER NOT NULL +) TYPE=InnoDB; + +/* Table Items: book_question */ + +/* Add Indexes for: book_question */ +CREATE INDEX fk_book_question_book ON book_question (book_id); +CREATE INDEX fk_book_question_question ON book_question (question_id); + +/******************** Add Table: `comment` ************************/ + +/* Build Table Structure */ +CREATE TABLE `comment` +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + content_type_id INTEGER NOT NULL, + object_id INTEGER UNSIGNED NOT NULL, + user_id INTEGER NOT NULL, + `comment` TEXT NOT NULL, + added_at DATETIME NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; + +/* Table Items: `comment` */ + +/* Add Indexes for: comment */ +CREATE INDEX comment_content_type_id ON `comment` (content_type_id); +CREATE INDEX comment_user_id ON `comment` (user_id); +CREATE INDEX content_type_id ON `comment` (content_type_id, object_id, user_id); + +/******************** Add Table: django_admin_log ************************/ + +/* Build Table Structure */ +CREATE TABLE django_admin_log +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + action_time DATETIME NOT NULL, + user_id INTEGER NOT NULL, + content_type_id INTEGER NULL, + object_id LONGTEXT NULL, + object_repr VARCHAR(200) NOT NULL, + action_flag SMALLINT UNSIGNED NOT NULL, + change_message LONGTEXT NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +/* Table Items: django_admin_log */ + +/* Add Indexes for: django_admin_log */ +CREATE INDEX django_admin_log_content_type_id ON django_admin_log (content_type_id); +CREATE INDEX django_admin_log_user_id ON django_admin_log (user_id); + +/******************** Add Table: django_authopenid_association ************************/ + +/* Build Table Structure */ +CREATE TABLE django_authopenid_association +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + server_url LONGTEXT NOT NULL, + handle VARCHAR(255) NOT NULL, + secret LONGTEXT NOT NULL, + issued INTEGER NOT NULL, + lifetime INTEGER NOT NULL, + assoc_type LONGTEXT NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + +/******************** Add Table: django_authopenid_nonce ************************/ + +/* Build Table Structure */ +CREATE TABLE django_authopenid_nonce +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + server_url VARCHAR(255) NOT NULL, + `timestamp` INTEGER NOT NULL, + salt VARCHAR(40) NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8; + +/******************** Add Table: django_authopenid_userassociation ************************/ + +/* Build Table Structure */ +CREATE TABLE django_authopenid_userassociation +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + openid_url VARCHAR(255) NOT NULL, + user_id INTEGER NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +/* Table Items: django_authopenid_userassociation */ + +/* Add Indexes for: django_authopenid_userassociation */ +CREATE UNIQUE INDEX user_id ON django_authopenid_userassociation (user_id); + +/******************** Add Table: django_authopenid_userpasswordqueue ************************/ + +/* Build Table Structure */ +CREATE TABLE django_authopenid_userpasswordqueue +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + new_password VARCHAR(30) NOT NULL, + confirm_key VARCHAR(40) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: django_authopenid_userpasswordqueue */ + +/* Add Indexes for: django_authopenid_userpasswordqueue */ +CREATE UNIQUE INDEX user_id ON django_authopenid_userpasswordqueue (user_id); + +/******************** Add Table: django_content_type ************************/ + +/* Build Table Structure */ +CREATE TABLE django_content_type +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(100) NOT NULL, + app_label VARCHAR(100) NOT NULL, + model VARCHAR(100) NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8; + +/* Table Items: django_content_type */ + +/* Add Indexes for: django_content_type */ +CREATE UNIQUE INDEX app_label ON django_content_type (app_label, model); + +/******************** Add Table: django_session ************************/ + +/* Build Table Structure */ +CREATE TABLE django_session +( + session_key VARCHAR(40) NOT NULL, + session_data LONGTEXT NOT NULL, + expire_date DATETIME NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: django_session */ +ALTER TABLE django_session ADD CONSTRAINT pkdjango_session + PRIMARY KEY (session_key); + +/******************** Add Table: django_site ************************/ + +/* Build Table Structure */ +CREATE TABLE django_site +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + domain VARCHAR(100) NOT NULL, + name VARCHAR(50) NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +/******************** Add Table: favorite_question ************************/ + +/* Build Table Structure */ +CREATE TABLE favorite_question +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + question_id INTEGER NOT NULL, + user_id INTEGER NOT NULL, + added_at DATETIME NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +/* Table Items: favorite_question */ + +/* Add Indexes for: favorite_question */ +CREATE INDEX favorite_question_question_id ON favorite_question (question_id); +CREATE INDEX favorite_question_user_id ON favorite_question (user_id); + +/******************** Add Table: flagged_item ************************/ + +/* Build Table Structure */ +CREATE TABLE flagged_item +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + content_type_id INTEGER NOT NULL, + object_id INTEGER UNSIGNED NOT NULL, + user_id INTEGER NOT NULL, + flagged_at DATETIME NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + +/* Table Items: flagged_item */ + +/* Add Indexes for: flagged_item */ +CREATE UNIQUE INDEX content_type_id ON flagged_item (content_type_id, object_id, user_id); +CREATE INDEX flagged_item_content_type_id ON flagged_item (content_type_id); +CREATE INDEX flagged_item_user_id ON flagged_item (user_id); + +/******************** Add Table: question ************************/ + +/* Build Table Structure */ +CREATE TABLE question +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + title TEXT NOT NULL, + author_id INTEGER NOT NULL, + added_at DATETIME NOT NULL, + wiki TINYINT NOT NULL, + wikified_at DATETIME NULL, + answer_accepted TINYINT NOT NULL, + closed TINYINT NOT NULL, + closed_by_id INTEGER NULL, + closed_at DATETIME NULL, + close_reason SMALLINT NULL, + deleted TINYINT NOT NULL, + deleted_at DATETIME NULL, + deleted_by_id INTEGER NULL, + locked TINYINT NOT NULL, + locked_by_id INTEGER NULL, + locked_at DATETIME NULL, + score INTEGER NOT NULL, + answer_count INTEGER UNSIGNED NOT NULL, + comment_count INTEGER UNSIGNED NOT NULL, + view_count INTEGER UNSIGNED NOT NULL, + offensive_flag_count SMALLINT NOT NULL, + favourite_count INTEGER UNSIGNED NOT NULL, + last_edited_at DATETIME NULL, + last_edited_by_id INTEGER NULL, + last_activity_at DATETIME NOT NULL, + last_activity_by_id INTEGER NOT NULL, + tagnames VARCHAR(125) NOT NULL, + summary VARCHAR(180) NOT NULL, + html LONGTEXT NOT NULL, + vote_up_count INTEGER NOT NULL, + vote_down_count INTEGER NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; + +/* Table Items: question */ + +/* Add Indexes for: question */ +CREATE INDEX question_author_id ON question (author_id); +CREATE INDEX question_closed_by_id ON question (closed_by_id); +CREATE INDEX question_deleted_by_id ON question (deleted_by_id); +CREATE INDEX question_last_activity_by_id ON question (last_activity_by_id); +CREATE INDEX question_last_edited_by_id ON question (last_edited_by_id); +CREATE INDEX question_locked_by_id ON question (locked_by_id); + +/******************** Add Table: question_revision ************************/ + +/* Build Table Structure */ +CREATE TABLE question_revision +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + question_id INTEGER NOT NULL, + revision INTEGER UNSIGNED NOT NULL, + title TEXT NOT NULL, + author_id INTEGER NOT NULL, + revised_at DATETIME NOT NULL, + tagnames VARCHAR(125) NOT NULL, + summary TEXT NOT NULL, + `text` LONGTEXT NOT NULL +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; + +/* Table Items: question_revision */ + +/* Add Indexes for: question_revision */ +CREATE INDEX question_revision_author_id ON question_revision (author_id); +CREATE INDEX question_revision_question_id ON question_revision (question_id); + +/******************** Add Table: question_tags ************************/ + +/* Build Table Structure */ +CREATE TABLE question_tags +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + question_id INTEGER NOT NULL, + tag_id INTEGER NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; + +/* Table Items: question_tags */ + +/* Add Indexes for: question_tags */ +CREATE UNIQUE INDEX question_id ON question_tags (question_id, tag_id); +CREATE INDEX tag_id_refs_id_43fcb953 ON question_tags (tag_id); + +/******************** Add Table: repute ************************/ + +/* Build Table Structure */ +CREATE TABLE repute +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + positive SMALLINT NOT NULL, + negative SMALLINT NOT NULL, + question_id INTEGER NOT NULL, + reputed_at DATETIME NOT NULL, + reputation_type SMALLINT NOT NULL, + reputation INTEGER NOT NULL +) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1; + +/* Table Items: repute */ + +/* Add Indexes for: repute */ +CREATE INDEX repute_question_id ON repute (question_id); +CREATE INDEX repute_user_id ON repute (user_id); + +/******************** Add Table: tag ************************/ + +/* Build Table Structure */ +CREATE TABLE tag +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + created_by_id INTEGER NOT NULL, + used_count INTEGER UNSIGNED NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; + +/* Table Items: tag */ + +/* Add Indexes for: tag */ +CREATE UNIQUE INDEX name ON tag (name); +CREATE INDEX tag_created_by_id ON tag (created_by_id); + +/******************** Add Table: user_badge ************************/ + +/* Build Table Structure */ +CREATE TABLE user_badge +( + id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + badge_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: user_badge */ + +/* Add Indexes for: user_badge */ +CREATE INDEX fk_user_badge_auth_user ON user_badge (user_id); +CREATE INDEX fk_user_badge_badge ON user_badge (badge_id); + +/******************** Add Table: user_favorite_questions ************************/ + +/* Build Table Structure */ +CREATE TABLE user_favorite_questions +( + id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + question_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: user_favorite_questions */ + +/* Add Indexes for: user_favorite_questions */ +CREATE INDEX fk_user_favorite_questions_auth_user ON user_favorite_questions (user_id); +CREATE INDEX fk_user_favorite_questions_question ON user_favorite_questions (question_id); + +/******************** Add Table: vote ************************/ + +/* Build Table Structure */ +CREATE TABLE vote +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + content_type_id INTEGER NOT NULL, + object_id INTEGER UNSIGNED NOT NULL, + user_id INTEGER NOT NULL, + vote SMALLINT NOT NULL, + voted_at DATETIME NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; + +/* Table Items: vote */ + +/* Add Indexes for: vote */ +CREATE UNIQUE INDEX content_type_id ON vote (content_type_id, object_id, user_id); +CREATE INDEX vote_content_type_id ON vote (content_type_id); +CREATE INDEX vote_user_id ON vote (user_id); + + +/************ Add Foreign Keys to Database ***************/ +/*----------------------------------------------------------- +Warning: Versions of MySQL prior to 4.1.2 require indexes on all columns involved in a foreign key. The following indexes may be required: +fk_auth_group_permissions_auth_group may require an index on table: auth_group_permissions, column: group_id +fk_auth_user_groups_auth_user may require an index on table: auth_user_groups, column: user_id +fk_auth_user_user_permissions_auth_user may require an index on table: auth_user_user_permissions, column: user_id +fk_question_tags_question may require an index on table: question_tags, column: question_id +----------------------------------------------------------- +*/ + +/************ Foreign Key: fk_activity_auth_user ***************/ +ALTER TABLE activity ADD CONSTRAINT fk_activity_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: deleted_by_id_refs_id_192b0170 ***************/ +ALTER TABLE answer ADD CONSTRAINT deleted_by_id_refs_id_192b0170 + FOREIGN KEY (deleted_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_answer_auth_user ***************/ +ALTER TABLE answer ADD CONSTRAINT fk_answer_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_answer_question ***************/ +ALTER TABLE answer ADD CONSTRAINT fk_answer_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: last_edited_by_id_refs_id_192b0170 ***************/ +ALTER TABLE answer ADD CONSTRAINT last_edited_by_id_refs_id_192b0170 + FOREIGN KEY (last_edited_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: locked_by_id_refs_id_192b0170 ***************/ +ALTER TABLE answer ADD CONSTRAINT locked_by_id_refs_id_192b0170 + FOREIGN KEY (locked_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_answer_revision_auth_user ***************/ +ALTER TABLE answer_revision ADD CONSTRAINT fk_answer_revision_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_group_permissions_auth_group ***************/ +ALTER TABLE auth_group_permissions ADD CONSTRAINT fk_auth_group_permissions_auth_group + FOREIGN KEY (group_id) REFERENCES auth_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_group_permissions_auth_permission ***************/ +ALTER TABLE auth_group_permissions ADD CONSTRAINT fk_auth_group_permissions_auth_permission + FOREIGN KEY (permission_id) REFERENCES auth_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_message_auth_user ***************/ +ALTER TABLE auth_message ADD CONSTRAINT fk_auth_message_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_permission_django_content_type ***************/ +ALTER TABLE auth_permission ADD CONSTRAINT fk_auth_permission_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_user_groups_auth_group ***************/ +ALTER TABLE auth_user_groups ADD CONSTRAINT fk_auth_user_groups_auth_group + FOREIGN KEY (group_id) REFERENCES auth_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_user_groups_auth_user ***************/ +ALTER TABLE auth_user_groups ADD CONSTRAINT fk_auth_user_groups_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_user_user_permissions_auth_permission ***************/ +ALTER TABLE auth_user_user_permissions ADD CONSTRAINT fk_auth_user_user_permissions_auth_permission + FOREIGN KEY (permission_id) REFERENCES auth_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_user_user_permissions_auth_user ***************/ +ALTER TABLE auth_user_user_permissions ADD CONSTRAINT fk_auth_user_user_permissions_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_award_auth_user ***************/ +ALTER TABLE award ADD CONSTRAINT fk_award_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_award_badge ***************/ +ALTER TABLE award ADD CONSTRAINT fk_award_badge + FOREIGN KEY (badge_id) REFERENCES badge (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_books_auth_user ***************/ +ALTER TABLE book ADD CONSTRAINT fk_books_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_author_info_auth_user ***************/ +ALTER TABLE book_author_info ADD CONSTRAINT fk_book_author_info_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_author_rss_auth_user ***************/ +ALTER TABLE book_author_rss ADD CONSTRAINT fk_book_author_rss_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_question_book ***************/ +ALTER TABLE book_question ADD CONSTRAINT fk_book_question_book + FOREIGN KEY (book_id) REFERENCES book (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_question_question ***************/ +ALTER TABLE book_question ADD CONSTRAINT fk_book_question_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_comment_auth_user ***************/ +ALTER TABLE `comment` ADD CONSTRAINT fk_comment_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_comment_django_content_type ***************/ +ALTER TABLE `comment` ADD CONSTRAINT fk_comment_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_django_admin_log_auth_user ***************/ +ALTER TABLE django_admin_log ADD CONSTRAINT fk_django_admin_log_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_django_admin_log_django_content_type ***************/ +ALTER TABLE django_admin_log ADD CONSTRAINT fk_django_admin_log_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_django_authopenid_userassociation_auth_user ***************/ +ALTER TABLE django_authopenid_userassociation ADD CONSTRAINT fk_django_authopenid_userassociation_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_django_authopenid_userpasswordqueue_auth_user ***************/ +ALTER TABLE django_authopenid_userpasswordqueue ADD CONSTRAINT fk_django_authopenid_userpasswordqueue_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_favorite_question_auth_user ***************/ +ALTER TABLE favorite_question ADD CONSTRAINT fk_favorite_question_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_favorite_question_question ***************/ +ALTER TABLE favorite_question ADD CONSTRAINT fk_favorite_question_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_flagged_item_auth_user ***************/ +ALTER TABLE flagged_item ADD CONSTRAINT fk_flagged_item_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_flagged_item_django_content_type ***************/ +ALTER TABLE flagged_item ADD CONSTRAINT fk_flagged_item_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: closed_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT closed_by_id_refs_id_56e9d00c + FOREIGN KEY (closed_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: deleted_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT deleted_by_id_refs_id_56e9d00c + FOREIGN KEY (deleted_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_auth_user ***************/ +ALTER TABLE question ADD CONSTRAINT fk_question_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: last_activity_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT last_activity_by_id_refs_id_56e9d00c + FOREIGN KEY (last_activity_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: last_edited_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT last_edited_by_id_refs_id_56e9d00c + FOREIGN KEY (last_edited_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: locked_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT locked_by_id_refs_id_56e9d00c + FOREIGN KEY (locked_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_revision_auth_user ***************/ +ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_revision_question ***************/ +ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_tags_question ***************/ +ALTER TABLE question_tags ADD CONSTRAINT fk_question_tags_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_tags_tag ***************/ +ALTER TABLE question_tags ADD CONSTRAINT fk_question_tags_tag + FOREIGN KEY (tag_id) REFERENCES tag (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_repute_auth_user ***************/ +ALTER TABLE repute ADD CONSTRAINT fk_repute_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_repute_question ***************/ +ALTER TABLE repute ADD CONSTRAINT fk_repute_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_tag_auth_user ***************/ +ALTER TABLE tag ADD CONSTRAINT fk_tag_auth_user + FOREIGN KEY (created_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_user_badge_auth_user ***************/ +ALTER TABLE user_badge ADD CONSTRAINT fk_user_badge_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_user_badge_badge ***************/ +ALTER TABLE user_badge ADD CONSTRAINT fk_user_badge_badge + FOREIGN KEY (badge_id) REFERENCES badge (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_user_favorite_questions_auth_user ***************/ +ALTER TABLE user_favorite_questions ADD CONSTRAINT fk_user_favorite_questions_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_user_favorite_questions_question ***************/ +ALTER TABLE user_favorite_questions ADD CONSTRAINT fk_user_favorite_questions_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_vote_auth_user ***************/ +ALTER TABLE vote ADD CONSTRAINT fk_vote_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_vote_django_content_type ***************/ +ALTER TABLE vote ADD CONSTRAINT fk_vote_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; \ No newline at end of file diff --git a/sql_scripts/cnprog_new_install_2009_04_07.sql b/sql_scripts/cnprog_new_install_2009_04_07.sql new file mode 100644 index 0000000000..ff9016fa18 --- /dev/null +++ b/sql_scripts/cnprog_new_install_2009_04_07.sql @@ -0,0 +1,24 @@ +USE cnprog; + + +/************ Add Foreign Keys to Database ***************/ + +/************ Foreign Key: fk_activity_auth_user ***************/ +ALTER TABLE activity ADD CONSTRAINT fk_activity_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_revision_auth_user ***************/ +ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_revision_question ***************/ +ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_repute_auth_user ***************/ +ALTER TABLE repute ADD CONSTRAINT fk_repute_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_repute_question ***************/ +ALTER TABLE repute ADD CONSTRAINT fk_repute_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; \ No newline at end of file diff --git a/sql_scripts/cnprog_new_install_2009_04_09.sql b/sql_scripts/cnprog_new_install_2009_04_09.sql new file mode 100644 index 0000000000..f4424852c7 --- /dev/null +++ b/sql_scripts/cnprog_new_install_2009_04_09.sql @@ -0,0 +1,904 @@ +USE cnprog; + + +/************ Update: Tables ***************/ + +/******************** Add Table: activity ************************/ + +/* Build Table Structure */ +CREATE TABLE activity +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + activity_type SMALLINT NOT NULL, + active_at DATETIME NOT NULL, + content_type_id INTEGER NOT NULL, + object_id INTEGER UNSIGNED NOT NULL, + is_auditted TINYINT NULL DEFAULT 0 +) ENGINE=MyISAM AUTO_INCREMENT=103 DEFAULT CHARSET=latin1; + +/* Table Items: activity */ + +/* Add Indexes for: activity */ +CREATE INDEX activity_content_type_id ON activity (content_type_id); +CREATE INDEX activity_user_id ON activity (user_id); + +/******************** Add Table: answer ************************/ + +/* Build Table Structure */ +CREATE TABLE answer +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + question_id INTEGER NOT NULL, + author_id INTEGER NOT NULL, + added_at DATETIME NOT NULL, + wiki TINYINT NOT NULL, + wikified_at DATETIME NULL, + accepted TINYINT NOT NULL, + deleted TINYINT NOT NULL, + deleted_by_id INTEGER NULL, + locked TINYINT NOT NULL, + locked_by_id INTEGER NULL, + locked_at DATETIME NULL, + score INTEGER NOT NULL, + comment_count INTEGER UNSIGNED NOT NULL, + offensive_flag_count SMALLINT NOT NULL, + last_edited_at DATETIME NULL, + last_edited_by_id INTEGER NULL, + html LONGTEXT NOT NULL, + vote_up_count INTEGER NOT NULL, + vote_down_count INTEGER NOT NULL, + accepted_at DATETIME NULL +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8; + +/* Table Items: answer */ + +/* Add Indexes for: answer */ +CREATE INDEX answer_author_id ON answer (author_id); +CREATE INDEX answer_deleted_by_id ON answer (deleted_by_id); +CREATE INDEX answer_last_edited_by_id ON answer (last_edited_by_id); +CREATE INDEX answer_locked_by_id ON answer (locked_by_id); +CREATE INDEX answer_question_id ON answer (question_id); + +/******************** Add Table: answer_revision ************************/ + +/* Build Table Structure */ +CREATE TABLE answer_revision +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + answer_id INTEGER NOT NULL, + revision INTEGER UNSIGNED NOT NULL, + author_id INTEGER NOT NULL, + revised_at DATETIME NOT NULL, + summary TEXT NOT NULL, + `text` LONGTEXT NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +/* Table Items: answer_revision */ + +/* Add Indexes for: answer_revision */ +CREATE INDEX answer_revision_answer_id ON answer_revision (answer_id); +CREATE INDEX answer_revision_author_id ON answer_revision (author_id); + +/******************** Add Table: auth_group ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_group +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(80) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: auth_group */ + +/* Add Indexes for: auth_group */ +CREATE UNIQUE INDEX name ON auth_group (name); + +/******************** Add Table: auth_group_permissions ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_group_permissions +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + group_id INTEGER NOT NULL, + permission_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: auth_group_permissions */ + +/* Add Indexes for: auth_group_permissions */ +CREATE UNIQUE INDEX group_id ON auth_group_permissions (group_id, permission_id); +CREATE INDEX permission_id_refs_id_5886d21f ON auth_group_permissions (permission_id); + +/******************** Add Table: auth_message ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_message +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + message LONGTEXT NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8; + +/* Table Items: auth_message */ + +/* Add Indexes for: auth_message */ +CREATE INDEX auth_message_user_id ON auth_message (user_id); + +/******************** Add Table: auth_permission ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_permission +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50) NOT NULL, + content_type_id INTEGER NOT NULL, + codename VARCHAR(100) NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8; + +/* Table Items: auth_permission */ + +/* Add Indexes for: auth_permission */ +CREATE INDEX auth_permission_content_type_id ON auth_permission (content_type_id); +CREATE UNIQUE INDEX content_type_id ON auth_permission (content_type_id, codename); + +/******************** Add Table: auth_user ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_user +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(30) NOT NULL, + first_name VARCHAR(30) NOT NULL, + last_name VARCHAR(30) NOT NULL, + email VARCHAR(75) NOT NULL, + password VARCHAR(128) NOT NULL, + is_staff TINYINT NOT NULL, + is_active TINYINT NOT NULL, + is_superuser TINYINT NOT NULL, + last_login DATETIME NOT NULL, + date_joined DATETIME NOT NULL, + gold SMALLINT NOT NULL DEFAULT 0, + silver SMALLINT UNSIGNED NOT NULL DEFAULT 0, + bronze SMALLINT UNSIGNED NOT NULL DEFAULT 0, + reputation INTEGER UNSIGNED NULL DEFAULT 1, + gravatar VARCHAR(128) NULL, + questions_per_page SMALLINT UNSIGNED NULL DEFAULT 10, + last_seen DATETIME NULL, + real_name VARCHAR(100) NULL, + website VARCHAR(200) NULL, + location VARCHAR(100) NULL, + date_of_birth DATETIME NULL, + about TEXT NULL +) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8; + +/* Table Items: auth_user */ + +/* Add Indexes for: auth_user */ +CREATE UNIQUE INDEX username ON auth_user (username); + +/******************** Add Table: auth_user_groups ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_user_groups +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + group_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: auth_user_groups */ + +/* Add Indexes for: auth_user_groups */ +CREATE INDEX group_id_refs_id_f116770 ON auth_user_groups (group_id); +CREATE UNIQUE INDEX user_id ON auth_user_groups (user_id, group_id); + +/******************** Add Table: auth_user_user_permissions ************************/ + +/* Build Table Structure */ +CREATE TABLE auth_user_user_permissions +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + permission_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: auth_user_user_permissions */ + +/* Add Indexes for: auth_user_user_permissions */ +CREATE INDEX permission_id_refs_id_67e79cb ON auth_user_user_permissions (permission_id); +CREATE UNIQUE INDEX user_id ON auth_user_user_permissions (user_id, permission_id); + +/******************** Add Table: award ************************/ + +/* Build Table Structure */ +CREATE TABLE award +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + badge_id INTEGER NOT NULL, + awarded_at DATETIME NOT NULL, + notified TINYINT NOT NULL, + content_type_id INTEGER NULL, + object_id INTEGER NULL +) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; + +/* Table Items: award */ + +/* Add Indexes for: award */ +CREATE INDEX award_badge_id ON award (badge_id); +CREATE INDEX award_user_id ON award (user_id); + +/******************** Add Table: badge ************************/ + +/* Build Table Structure */ +CREATE TABLE badge +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50) NOT NULL, + `type` SMALLINT NOT NULL, + slug VARCHAR(50) NOT NULL, + description TEXT NOT NULL, + multiple TINYINT NOT NULL, + awarded_count INTEGER UNSIGNED NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8; + +/* Table Items: badge */ + +/* Add Indexes for: badge */ +CREATE INDEX badge_slug ON badge (slug); +CREATE UNIQUE INDEX name ON badge (name, `type`); + +/******************** Add Table: book ************************/ + +/* Build Table Structure */ +CREATE TABLE book +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + short_name VARCHAR(255) NOT NULL, + author VARCHAR(255) NOT NULL, + user_id INTEGER NULL, + price DECIMAL(10, 2) NULL, + pages SMALLINT NULL, + published_at DATE NOT NULL, + publication VARCHAR(255) NOT NULL, + cover_img VARCHAR(255) NULL, + tagnames VARCHAR(125) NULL, + added_at DATETIME NOT NULL, + last_edited_at DATETIME NOT NULL +) TYPE=InnoDB; + +/* Table Items: book */ + +/* Add Indexes for: book */ +CREATE UNIQUE INDEX book_short_name_Idx ON book (short_name); +CREATE INDEX fk_books_auth_user ON book (user_id); + +/******************** Add Table: book_author_info ************************/ + +/* Build Table Structure */ +CREATE TABLE book_author_info +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + blog_url VARCHAR(255) NULL, + user_id INTEGER NOT NULL, + added_at DATETIME NOT NULL, + last_edited_at DATETIME NOT NULL, + book_id INTEGER NOT NULL +) TYPE=InnoDB; + +/* Table Items: book_author_info */ + +/* Add Indexes for: book_author_info */ +CREATE INDEX fk_book_author_info_auth_user ON book_author_info (user_id); +CREATE INDEX fk_book_author_info_book ON book_author_info (book_id); + +/******************** Add Table: book_author_rss ************************/ + +/* Build Table Structure */ +CREATE TABLE book_author_rss +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + url VARCHAR(255) NOT NULL, + rss_created_at DATETIME NOT NULL, + user_id INTEGER NOT NULL, + added_at DATETIME NOT NULL, + book_id INTEGER NOT NULL +) TYPE=InnoDB; + +/* Table Items: book_author_rss */ + +/* Add Indexes for: book_author_rss */ +CREATE INDEX fk_book_author_rss_auth_user ON book_author_rss (user_id); +CREATE INDEX fk_book_author_rss_book ON book_author_rss (book_id); + +/******************** Add Table: book_question ************************/ + +/* Build Table Structure */ +CREATE TABLE book_question +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + book_id INTEGER NOT NULL, + question_id INTEGER NOT NULL +) TYPE=InnoDB; + +/* Table Items: book_question */ + +/* Add Indexes for: book_question */ +CREATE INDEX fk_book_question_book ON book_question (book_id); +CREATE INDEX fk_book_question_question ON book_question (question_id); + +/******************** Add Table: `comment` ************************/ + +/* Build Table Structure */ +CREATE TABLE `comment` +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + content_type_id INTEGER NOT NULL, + object_id INTEGER UNSIGNED NOT NULL, + user_id INTEGER NOT NULL, + `comment` TEXT NOT NULL, + added_at DATETIME NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; + +/* Table Items: `comment` */ + +/* Add Indexes for: comment */ +CREATE INDEX comment_content_type_id ON `comment` (content_type_id); +CREATE INDEX comment_user_id ON `comment` (user_id); +CREATE INDEX content_type_id ON `comment` (content_type_id, object_id, user_id); + +/******************** Add Table: django_admin_log ************************/ + +/* Build Table Structure */ +CREATE TABLE django_admin_log +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + action_time DATETIME NOT NULL, + user_id INTEGER NOT NULL, + content_type_id INTEGER NULL, + object_id LONGTEXT NULL, + object_repr VARCHAR(200) NOT NULL, + action_flag SMALLINT UNSIGNED NOT NULL, + change_message LONGTEXT NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +/* Table Items: django_admin_log */ + +/* Add Indexes for: django_admin_log */ +CREATE INDEX django_admin_log_content_type_id ON django_admin_log (content_type_id); +CREATE INDEX django_admin_log_user_id ON django_admin_log (user_id); + +/******************** Add Table: django_authopenid_association ************************/ + +/* Build Table Structure */ +CREATE TABLE django_authopenid_association +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + server_url LONGTEXT NOT NULL, + handle VARCHAR(255) NOT NULL, + secret LONGTEXT NOT NULL, + issued INTEGER NOT NULL, + lifetime INTEGER NOT NULL, + assoc_type LONGTEXT NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + +/******************** Add Table: django_authopenid_nonce ************************/ + +/* Build Table Structure */ +CREATE TABLE django_authopenid_nonce +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + server_url VARCHAR(255) NOT NULL, + `timestamp` INTEGER NOT NULL, + salt VARCHAR(40) NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8; + +/******************** Add Table: django_authopenid_userassociation ************************/ + +/* Build Table Structure */ +CREATE TABLE django_authopenid_userassociation +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + openid_url VARCHAR(255) NOT NULL, + user_id INTEGER NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +/* Table Items: django_authopenid_userassociation */ + +/* Add Indexes for: django_authopenid_userassociation */ +CREATE UNIQUE INDEX user_id ON django_authopenid_userassociation (user_id); + +/******************** Add Table: django_authopenid_userpasswordqueue ************************/ + +/* Build Table Structure */ +CREATE TABLE django_authopenid_userpasswordqueue +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + new_password VARCHAR(30) NOT NULL, + confirm_key VARCHAR(40) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: django_authopenid_userpasswordqueue */ + +/* Add Indexes for: django_authopenid_userpasswordqueue */ +CREATE UNIQUE INDEX user_id ON django_authopenid_userpasswordqueue (user_id); + +/******************** Add Table: django_content_type ************************/ + +/* Build Table Structure */ +CREATE TABLE django_content_type +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(100) NOT NULL, + app_label VARCHAR(100) NOT NULL, + model VARCHAR(100) NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8; + +/* Table Items: django_content_type */ + +/* Add Indexes for: django_content_type */ +CREATE UNIQUE INDEX app_label ON django_content_type (app_label, model); + +/******************** Add Table: django_session ************************/ + +/* Build Table Structure */ +CREATE TABLE django_session +( + session_key VARCHAR(40) NOT NULL, + session_data LONGTEXT NOT NULL, + expire_date DATETIME NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: django_session */ +ALTER TABLE django_session ADD CONSTRAINT pkdjango_session + PRIMARY KEY (session_key); + +/******************** Add Table: django_site ************************/ + +/* Build Table Structure */ +CREATE TABLE django_site +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + domain VARCHAR(100) NOT NULL, + name VARCHAR(50) NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +/******************** Add Table: favorite_question ************************/ + +/* Build Table Structure */ +CREATE TABLE favorite_question +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + question_id INTEGER NOT NULL, + user_id INTEGER NOT NULL, + added_at DATETIME NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +/* Table Items: favorite_question */ + +/* Add Indexes for: favorite_question */ +CREATE INDEX favorite_question_question_id ON favorite_question (question_id); +CREATE INDEX favorite_question_user_id ON favorite_question (user_id); + +/******************** Add Table: flagged_item ************************/ + +/* Build Table Structure */ +CREATE TABLE flagged_item +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + content_type_id INTEGER NOT NULL, + object_id INTEGER UNSIGNED NOT NULL, + user_id INTEGER NOT NULL, + flagged_at DATETIME NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + +/* Table Items: flagged_item */ + +/* Add Indexes for: flagged_item */ +CREATE UNIQUE INDEX content_type_id ON flagged_item (content_type_id, object_id, user_id); +CREATE INDEX flagged_item_content_type_id ON flagged_item (content_type_id); +CREATE INDEX flagged_item_user_id ON flagged_item (user_id); + +/******************** Add Table: question ************************/ + +/* Build Table Structure */ +CREATE TABLE question +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + title TEXT NOT NULL, + author_id INTEGER NOT NULL, + added_at DATETIME NOT NULL, + wiki TINYINT NOT NULL, + wikified_at DATETIME NULL, + answer_accepted TINYINT NOT NULL, + closed TINYINT NOT NULL, + closed_by_id INTEGER NULL, + closed_at DATETIME NULL, + close_reason SMALLINT NULL, + deleted TINYINT NOT NULL, + deleted_at DATETIME NULL, + deleted_by_id INTEGER NULL, + locked TINYINT NOT NULL, + locked_by_id INTEGER NULL, + locked_at DATETIME NULL, + score INTEGER NOT NULL, + answer_count INTEGER UNSIGNED NOT NULL, + comment_count INTEGER UNSIGNED NOT NULL, + view_count INTEGER UNSIGNED NOT NULL, + offensive_flag_count SMALLINT NOT NULL, + favourite_count INTEGER UNSIGNED NOT NULL, + last_edited_at DATETIME NULL, + last_edited_by_id INTEGER NULL, + last_activity_at DATETIME NOT NULL, + last_activity_by_id INTEGER NOT NULL, + tagnames VARCHAR(125) NOT NULL, + summary VARCHAR(180) NOT NULL, + html LONGTEXT NOT NULL, + vote_up_count INTEGER NOT NULL, + vote_down_count INTEGER NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; + +/* Table Items: question */ + +/* Add Indexes for: question */ +CREATE INDEX question_author_id ON question (author_id); +CREATE INDEX question_closed_by_id ON question (closed_by_id); +CREATE INDEX question_deleted_by_id ON question (deleted_by_id); +CREATE INDEX question_last_activity_by_id ON question (last_activity_by_id); +CREATE INDEX question_last_edited_by_id ON question (last_edited_by_id); +CREATE INDEX question_locked_by_id ON question (locked_by_id); + +/******************** Add Table: question_revision ************************/ + +/* Build Table Structure */ +CREATE TABLE question_revision +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + question_id INTEGER NOT NULL, + revision INTEGER UNSIGNED NOT NULL, + title TEXT NOT NULL, + author_id INTEGER NOT NULL, + revised_at DATETIME NOT NULL, + tagnames VARCHAR(125) NOT NULL, + summary TEXT NOT NULL, + `text` LONGTEXT NOT NULL +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; + +/* Table Items: question_revision */ + +/* Add Indexes for: question_revision */ +CREATE INDEX question_revision_author_id ON question_revision (author_id); +CREATE INDEX question_revision_question_id ON question_revision (question_id); + +/******************** Add Table: question_tags ************************/ + +/* Build Table Structure */ +CREATE TABLE question_tags +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + question_id INTEGER NOT NULL, + tag_id INTEGER NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; + +/* Table Items: question_tags */ + +/* Add Indexes for: question_tags */ +CREATE UNIQUE INDEX question_id ON question_tags (question_id, tag_id); +CREATE INDEX tag_id_refs_id_43fcb953 ON question_tags (tag_id); + +/******************** Add Table: repute ************************/ + +/* Build Table Structure */ +CREATE TABLE repute +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + positive SMALLINT NOT NULL, + negative SMALLINT NOT NULL, + question_id INTEGER NOT NULL, + reputed_at DATETIME NOT NULL, + reputation_type SMALLINT NOT NULL, + reputation INTEGER NOT NULL +) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1; + +/* Table Items: repute */ + +/* Add Indexes for: repute */ +CREATE INDEX repute_question_id ON repute (question_id); +CREATE INDEX repute_user_id ON repute (user_id); + +/******************** Add Table: tag ************************/ + +/* Build Table Structure */ +CREATE TABLE tag +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + created_by_id INTEGER NOT NULL, + used_count INTEGER UNSIGNED NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; + +/* Table Items: tag */ + +/* Add Indexes for: tag */ +CREATE UNIQUE INDEX name ON tag (name); +CREATE INDEX tag_created_by_id ON tag (created_by_id); + +/******************** Add Table: user_badge ************************/ + +/* Build Table Structure */ +CREATE TABLE user_badge +( + id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + badge_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: user_badge */ + +/* Add Indexes for: user_badge */ +CREATE INDEX fk_user_badge_auth_user ON user_badge (user_id); +CREATE INDEX fk_user_badge_badge ON user_badge (badge_id); + +/******************** Add Table: user_favorite_questions ************************/ + +/* Build Table Structure */ +CREATE TABLE user_favorite_questions +( + id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INTEGER NOT NULL, + question_id INTEGER NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/* Table Items: user_favorite_questions */ + +/* Add Indexes for: user_favorite_questions */ +CREATE INDEX fk_user_favorite_questions_auth_user ON user_favorite_questions (user_id); +CREATE INDEX fk_user_favorite_questions_question ON user_favorite_questions (question_id); + +/******************** Add Table: vote ************************/ + +/* Build Table Structure */ +CREATE TABLE vote +( + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + content_type_id INTEGER NOT NULL, + object_id INTEGER UNSIGNED NOT NULL, + user_id INTEGER NOT NULL, + vote SMALLINT NOT NULL, + voted_at DATETIME NOT NULL +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; + +/* Table Items: vote */ + +/* Add Indexes for: vote */ +CREATE UNIQUE INDEX content_type_id ON vote (content_type_id, object_id, user_id); +CREATE INDEX vote_content_type_id ON vote (content_type_id); +CREATE INDEX vote_user_id ON vote (user_id); + + +/************ Add Foreign Keys to Database ***************/ +/*----------------------------------------------------------- +Warning: Versions of MySQL prior to 4.1.2 require indexes on all columns involved in a foreign key. The following indexes may be required: +fk_auth_group_permissions_auth_group may require an index on table: auth_group_permissions, column: group_id +fk_auth_user_groups_auth_user may require an index on table: auth_user_groups, column: user_id +fk_auth_user_user_permissions_auth_user may require an index on table: auth_user_user_permissions, column: user_id +fk_question_tags_question may require an index on table: question_tags, column: question_id +----------------------------------------------------------- +*/ + +/************ Foreign Key: fk_activity_auth_user ***************/ +ALTER TABLE activity ADD CONSTRAINT fk_activity_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: deleted_by_id_refs_id_192b0170 ***************/ +ALTER TABLE answer ADD CONSTRAINT deleted_by_id_refs_id_192b0170 + FOREIGN KEY (deleted_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_answer_auth_user ***************/ +ALTER TABLE answer ADD CONSTRAINT fk_answer_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_answer_question ***************/ +ALTER TABLE answer ADD CONSTRAINT fk_answer_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: last_edited_by_id_refs_id_192b0170 ***************/ +ALTER TABLE answer ADD CONSTRAINT last_edited_by_id_refs_id_192b0170 + FOREIGN KEY (last_edited_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: locked_by_id_refs_id_192b0170 ***************/ +ALTER TABLE answer ADD CONSTRAINT locked_by_id_refs_id_192b0170 + FOREIGN KEY (locked_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_answer_revision_auth_user ***************/ +ALTER TABLE answer_revision ADD CONSTRAINT fk_answer_revision_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_group_permissions_auth_group ***************/ +ALTER TABLE auth_group_permissions ADD CONSTRAINT fk_auth_group_permissions_auth_group + FOREIGN KEY (group_id) REFERENCES auth_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_group_permissions_auth_permission ***************/ +ALTER TABLE auth_group_permissions ADD CONSTRAINT fk_auth_group_permissions_auth_permission + FOREIGN KEY (permission_id) REFERENCES auth_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_message_auth_user ***************/ +ALTER TABLE auth_message ADD CONSTRAINT fk_auth_message_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_permission_django_content_type ***************/ +ALTER TABLE auth_permission ADD CONSTRAINT fk_auth_permission_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_user_groups_auth_group ***************/ +ALTER TABLE auth_user_groups ADD CONSTRAINT fk_auth_user_groups_auth_group + FOREIGN KEY (group_id) REFERENCES auth_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_user_groups_auth_user ***************/ +ALTER TABLE auth_user_groups ADD CONSTRAINT fk_auth_user_groups_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_user_user_permissions_auth_permission ***************/ +ALTER TABLE auth_user_user_permissions ADD CONSTRAINT fk_auth_user_user_permissions_auth_permission + FOREIGN KEY (permission_id) REFERENCES auth_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_auth_user_user_permissions_auth_user ***************/ +ALTER TABLE auth_user_user_permissions ADD CONSTRAINT fk_auth_user_user_permissions_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_award_auth_user ***************/ +ALTER TABLE award ADD CONSTRAINT fk_award_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_award_badge ***************/ +ALTER TABLE award ADD CONSTRAINT fk_award_badge + FOREIGN KEY (badge_id) REFERENCES badge (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_books_auth_user ***************/ +ALTER TABLE book ADD CONSTRAINT fk_books_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_author_info_auth_user ***************/ +ALTER TABLE book_author_info ADD CONSTRAINT fk_book_author_info_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_author_info_book ***************/ +ALTER TABLE book_author_info ADD CONSTRAINT fk_book_author_info_book + FOREIGN KEY (book_id) REFERENCES book (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_author_rss_auth_user ***************/ +ALTER TABLE book_author_rss ADD CONSTRAINT fk_book_author_rss_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_author_rss_book ***************/ +ALTER TABLE book_author_rss ADD CONSTRAINT fk_book_author_rss_book + FOREIGN KEY (book_id) REFERENCES book (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_question_book ***************/ +ALTER TABLE book_question ADD CONSTRAINT fk_book_question_book + FOREIGN KEY (book_id) REFERENCES book (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_book_question_question ***************/ +ALTER TABLE book_question ADD CONSTRAINT fk_book_question_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_comment_auth_user ***************/ +ALTER TABLE `comment` ADD CONSTRAINT fk_comment_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_comment_django_content_type ***************/ +ALTER TABLE `comment` ADD CONSTRAINT fk_comment_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_django_admin_log_auth_user ***************/ +ALTER TABLE django_admin_log ADD CONSTRAINT fk_django_admin_log_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_django_admin_log_django_content_type ***************/ +ALTER TABLE django_admin_log ADD CONSTRAINT fk_django_admin_log_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_django_authopenid_userassociation_auth_user ***************/ +ALTER TABLE django_authopenid_userassociation ADD CONSTRAINT fk_django_authopenid_userassociation_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_django_authopenid_userpasswordqueue_auth_user ***************/ +ALTER TABLE django_authopenid_userpasswordqueue ADD CONSTRAINT fk_django_authopenid_userpasswordqueue_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_favorite_question_auth_user ***************/ +ALTER TABLE favorite_question ADD CONSTRAINT fk_favorite_question_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_favorite_question_question ***************/ +ALTER TABLE favorite_question ADD CONSTRAINT fk_favorite_question_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_flagged_item_auth_user ***************/ +ALTER TABLE flagged_item ADD CONSTRAINT fk_flagged_item_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_flagged_item_django_content_type ***************/ +ALTER TABLE flagged_item ADD CONSTRAINT fk_flagged_item_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: closed_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT closed_by_id_refs_id_56e9d00c + FOREIGN KEY (closed_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: deleted_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT deleted_by_id_refs_id_56e9d00c + FOREIGN KEY (deleted_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_auth_user ***************/ +ALTER TABLE question ADD CONSTRAINT fk_question_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: last_activity_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT last_activity_by_id_refs_id_56e9d00c + FOREIGN KEY (last_activity_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: last_edited_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT last_edited_by_id_refs_id_56e9d00c + FOREIGN KEY (last_edited_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: locked_by_id_refs_id_56e9d00c ***************/ +ALTER TABLE question ADD CONSTRAINT locked_by_id_refs_id_56e9d00c + FOREIGN KEY (locked_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_revision_auth_user ***************/ +ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_auth_user + FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_revision_question ***************/ +ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_tags_question ***************/ +ALTER TABLE question_tags ADD CONSTRAINT fk_question_tags_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_question_tags_tag ***************/ +ALTER TABLE question_tags ADD CONSTRAINT fk_question_tags_tag + FOREIGN KEY (tag_id) REFERENCES tag (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_repute_auth_user ***************/ +ALTER TABLE repute ADD CONSTRAINT fk_repute_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_repute_question ***************/ +ALTER TABLE repute ADD CONSTRAINT fk_repute_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_tag_auth_user ***************/ +ALTER TABLE tag ADD CONSTRAINT fk_tag_auth_user + FOREIGN KEY (created_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_user_badge_auth_user ***************/ +ALTER TABLE user_badge ADD CONSTRAINT fk_user_badge_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_user_badge_badge ***************/ +ALTER TABLE user_badge ADD CONSTRAINT fk_user_badge_badge + FOREIGN KEY (badge_id) REFERENCES badge (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_user_favorite_questions_auth_user ***************/ +ALTER TABLE user_favorite_questions ADD CONSTRAINT fk_user_favorite_questions_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_user_favorite_questions_question ***************/ +ALTER TABLE user_favorite_questions ADD CONSTRAINT fk_user_favorite_questions_question + FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_vote_auth_user ***************/ +ALTER TABLE vote ADD CONSTRAINT fk_vote_auth_user + FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION; + +/************ Foreign Key: fk_vote_django_content_type ***************/ +ALTER TABLE vote ADD CONSTRAINT fk_vote_django_content_type + FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION; \ No newline at end of file diff --git a/sql_scripts/update_2009_01_13_001.sql b/sql_scripts/update_2009_01_13_001.sql new file mode 100644 index 0000000000..165d112527 --- /dev/null +++ b/sql_scripts/update_2009_01_13_001.sql @@ -0,0 +1,62 @@ +-- phpMyAdmin SQL Dump +-- version 3.0.0-beta +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: Jan 12, 2009 at 08:55 PM +-- Server version: 5.0.67 +-- PHP Version: 5.2.6 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Database: `twogeekt_lanai` +-- + +-- +-- Dumping data for table `badge` +-- + +INSERT INTO `badge` (`id`, `name`, `type`, `slug`, `description`, `multiple`, `awarded_count`) VALUES +(1, '鐐肩嫳娉曞笀', 3, '鐐肩嫳娉曞笀', '鍒犻櫎鑷繁鏈3涓互涓婅禐鎴愮エ鐨勫笘瀛', 1, 0), +(2, '鍘嬪姏鐧介', 3, '鍘嬪姏鐧介', '鍒犻櫎鑷繁鏈3涓互涓婂弽瀵圭エ鐨勫笘瀛', 1, 0), +(3, '浼樼鍥炵瓟', 3, '浼樼鍥炵瓟', '鍥炵瓟濂借瘎10娆′互涓', 1, 0), +(4, '浼樼闂', 3, '浼樼闂', '闂濂借瘎10娆′互涓', 1, 0), +(5, '璇勮瀹', 3, '璇勮瀹', '璇勮10娆′互涓', 1, 0), +(6, '娴佽闂', 3, '娴佽闂', '闂鐨勬祻瑙堥噺瓒呰繃1000浜烘', 1, 0), +(7, '宸¢诲叺', 3, '宸¢诲叺', '绗竴娆℃爣璁板瀮鍦惧笘瀛', 1, 0), +(8, '娓呮磥宸', 3, '娓呮磥宸', '绗竴娆℃挙閿鎶曠エ', 1, 0), +(9, '鎵硅瘎瀹', 3, '鎵硅瘎瀹', '绗竴娆″弽瀵圭エ', 1, 0), +(10, '灏忕紪', 3, '灏忕紪', '绗竴娆$紪杈戞洿鏂', 1, 0), +(11, '鏉戦暱', 3, '鏉戦暱', '绗竴娆¢噸鏂版爣绛', 1, 0), +(12, '瀛﹁', 3, '瀛﹁', '绗竴娆℃爣璁扮瓟妗', 1, 0), +(13, '瀛︾敓', 3, '瀛︾敓', '绗竴娆℃彁闂苟涓旀湁涓娆′互涓婅禐鎴愮エ', 1, 0), +(14, '鏀寔鑰', 3, '鏀寔鑰', '绗竴娆¤禐鎴愮エ', 1, 0), +(15, '鏁欏笀', 3, '鏁欏笀', '绗竴娆″洖绛旈棶棰樺苟涓斿緱鍒颁竴涓互涓婅禐鎴愮エ', 1, 0), +(16, '鑷紶浣滆', 3, '鑷紶浣滆', '瀹屾暣濉啓鐢ㄦ埛璧勬枡鎵鏈夐夐」', 1, 0), +(17, '鑷鎴愭墠', 3, '鑷鎴愭墠', '鍥炵瓟鑷繁鐨勯棶棰樺苟涓旀湁3涓互涓婅禐鎴愮エ', 1, 0), +(18, '鏈鏈変环鍊煎洖绛', 1, '鏈鏈変环鍊煎洖绛', '鍥炵瓟瓒呰繃100娆¤禐鎴愮エ', 1, 0), +(19, '鏈鏈変环鍊奸棶棰', 1, '鏈鏈変环鍊奸棶棰', '闂瓒呰繃100娆¤禐鎴愮エ', 1, 0), +(20, '涓囦汉杩', 1, '涓囦汉杩', '闂琚100浜轰互涓婃敹钘', 1, 0), +(21, '钁楀悕闂', 1, '钁楀悕闂', '闂鐨勬祻瑙堥噺瓒呰繃10000浜烘', 1, 0), +(22, 'alpha鐢ㄦ埛', 2, 'alpha鐢ㄦ埛', '鍐呮祴鏈熼棿鐨勬椿璺冪敤鎴', 1, 0), +(23, '鏋佸ソ鍥炵瓟', 2, '鏋佸ソ鍥炵瓟', '鍥炵瓟瓒呰繃25娆¤禐鎴愮エ', 1, 0), +(24, '鏋佸ソ闂', 2, '鏋佸ソ闂', '闂瓒呰繃25娆¤禐鎴愮エ', 1, 0), +(25, '鍙楁杩庨棶棰', 2, '鍙楁杩庨棶棰', '闂琚25浜轰互涓婃敹钘', 1, 0), +(26, '浼樼甯傛皯', 2, '浼樼甯傛皯', '鎶曠エ300娆′互涓', 1, 0), +(27, '缂栬緫涓讳换', 2, '缂栬緫涓讳换', '缂栬緫浜100涓笘瀛', 1, 0), +(28, '閫氭墠', 2, '閫氭墠', '鍦ㄥ涓爣绛鹃鍩熸椿璺', 1, 0), +(29, '涓撳', 2, '涓撳', '鍦ㄤ竴涓爣绛鹃鍩熸椿璺冨嚭浼', 1, 0), +(30, '鑰侀笩', 2, '鑰侀笩', '娲昏穬瓒呰繃涓骞寸殑鐢ㄦ埛', 1, 0), +(31, '鏈鍙楀叧娉ㄩ棶棰', 2, '鏈鍙楀叧娉ㄩ棶棰', '闂鐨勬祻瑙堥噺瓒呰繃2500浜烘', 1, 0), +(32, '瀛﹂棶瀹', 2, '瀛﹂棶瀹', '绗竴娆″洖绛旇鎶曡禐鎴愮エ10娆′互涓', 1, 0), +(33, 'beta鐢ㄦ埛', 2, 'beta鐢ㄦ埛', 'beta鏈熼棿娲昏穬鍙備笌', 1, 0), +(34, '瀵煎笀', 2, '瀵煎笀', '琚寚瀹氫负鏈浣崇瓟妗堝苟涓旇禐鎴愮エ40浠ヤ笂', 1, 0), +(35, '宸笀', 2, '宸笀', '鍦ㄦ彁闂60澶╀箣鍚庡洖绛斿苟涓旇禐鎴愮エ5娆′互涓', 1, 0), +(36, '鍒嗙被涓撳', 2, '鍒嗙被涓撳', '鍒涘缓鐨勬爣绛捐50涓互涓婇棶棰樹娇鐢', 1, 0); diff --git a/sql_scripts/update_2009_01_13_002.sql b/sql_scripts/update_2009_01_13_002.sql new file mode 100644 index 0000000000..c223cb8c06 --- /dev/null +++ b/sql_scripts/update_2009_01_13_002.sql @@ -0,0 +1 @@ +ALTER TABLE activity ADD COLUMN is_auditted tinyint(1) DEFAULT 0 \ No newline at end of file diff --git a/sql_scripts/update_2009_01_18_001.sql b/sql_scripts/update_2009_01_18_001.sql new file mode 100644 index 0000000000..6f29fa3254 --- /dev/null +++ b/sql_scripts/update_2009_01_18_001.sql @@ -0,0 +1,62 @@ +-- phpMyAdmin SQL Dump +-- version 3.0.0-beta +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: Jan 12, 2009 at 08:55 PM +-- Server version: 5.0.67 +-- PHP Version: 5.2.6 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Database: `twogeekt_lanai` +-- + +-- +-- Dumping data for table `badge` +-- + +INSERT INTO `badge` (`id`, `name`, `type`, `slug`, `description`, `multiple`, `awarded_count`) VALUES +(1, '鐐肩嫳娉曞笀', 3, '鐐肩嫳娉曞笀', '鍒犻櫎鑷繁鏈3涓互涓婅禐鎴愮エ鐨勫笘瀛', 1, 0), +(2, '鍘嬪姏鐧介', 3, '鍘嬪姏鐧介', '鍒犻櫎鑷繁鏈3涓互涓婂弽瀵圭エ鐨勫笘瀛', 1, 0), +(3, '浼樼鍥炵瓟', 3, '浼樼鍥炵瓟', '鍥炵瓟濂借瘎10娆′互涓', 1, 0), +(4, '浼樼闂', 3, '浼樼闂', '闂濂借瘎10娆′互涓', 1, 0), +(5, '璇勮瀹', 3, '璇勮瀹', '璇勮10娆′互涓', 0, 0), +(6, '娴佽闂', 3, '娴佽闂', '闂鐨勬祻瑙堥噺瓒呰繃1000浜烘', 1, 0), +(7, '宸¢诲叺', 3, '宸¢诲叺', '绗竴娆℃爣璁板瀮鍦惧笘瀛', 0, 0), +(8, '娓呮磥宸', 3, '娓呮磥宸', '绗竴娆℃挙閿鎶曠エ', 0, 0), +(9, '鎵硅瘎瀹', 3, '鎵硅瘎瀹', '绗竴娆″弽瀵圭エ', 0, 0), +(10, '灏忕紪', 3, '灏忕紪', '绗竴娆$紪杈戞洿鏂', 0, 0), +(11, '鏉戦暱', 3, '鏉戦暱', '绗竴娆¢噸鏂版爣绛', 0, 0), +(12, '瀛﹁', 3, '瀛﹁', '绗竴娆℃爣璁扮瓟妗', 0, 0), +(13, '瀛︾敓', 3, '瀛︾敓', '绗竴娆℃彁闂苟涓旀湁涓娆′互涓婅禐鎴愮エ', 0, 0), +(14, '鏀寔鑰', 3, '鏀寔鑰', '绗竴娆¤禐鎴愮エ', 0, 0), +(15, '鏁欏笀', 3, '鏁欏笀', '绗竴娆″洖绛旈棶棰樺苟涓斿緱鍒颁竴涓互涓婅禐鎴愮エ', 0, 0), +(16, '鑷紶浣滆', 3, '鑷紶浣滆', '瀹屾暣濉啓鐢ㄦ埛璧勬枡鎵鏈夐夐」', 0, 0), +(17, '鑷鎴愭墠', 3, '鑷鎴愭墠', '鍥炵瓟鑷繁鐨勯棶棰樺苟涓旀湁3涓互涓婅禐鎴愮エ', 1, 0), +(18, '鏈鏈変环鍊煎洖绛', 1, '鏈鏈変环鍊煎洖绛', '鍥炵瓟瓒呰繃100娆¤禐鎴愮エ', 1, 0), +(19, '鏈鏈変环鍊奸棶棰', 1, '鏈鏈変环鍊奸棶棰', '闂瓒呰繃100娆¤禐鎴愮エ', 1, 0), +(20, '涓囦汉杩', 1, '涓囦汉杩', '闂琚100浜轰互涓婃敹钘', 1, 0), +(21, '钁楀悕闂', 1, '钁楀悕闂', '闂鐨勬祻瑙堥噺瓒呰繃10000浜烘', 1, 0), +(22, 'alpha鐢ㄦ埛', 2, 'alpha鐢ㄦ埛', '鍐呮祴鏈熼棿鐨勬椿璺冪敤鎴', 0, 0), +(23, '鏋佸ソ鍥炵瓟', 2, '鏋佸ソ鍥炵瓟', '鍥炵瓟瓒呰繃25娆¤禐鎴愮エ', 1, 0), +(24, '鏋佸ソ闂', 2, '鏋佸ソ闂', '闂瓒呰繃25娆¤禐鎴愮エ', 1, 0), +(25, '鍙楁杩庨棶棰', 2, '鍙楁杩庨棶棰', '闂琚25浜轰互涓婃敹钘', 1, 0), +(26, '浼樼甯傛皯', 2, '浼樼甯傛皯', '鎶曠エ300娆′互涓', 0, 0), +(27, '缂栬緫涓讳换', 2, '缂栬緫涓讳换', '缂栬緫浜100涓笘瀛', 0, 0), +(28, '閫氭墠', 2, '閫氭墠', '鍦ㄥ涓爣绛鹃鍩熸椿璺', 0, 0), +(29, '涓撳', 2, '涓撳', '鍦ㄤ竴涓爣绛鹃鍩熸椿璺冨嚭浼', 0, 0), +(30, '鑰侀笩', 2, '鑰侀笩', '娲昏穬瓒呰繃涓骞寸殑鐢ㄦ埛', 0, 0), +(31, '鏈鍙楀叧娉ㄩ棶棰', 2, '鏈鍙楀叧娉ㄩ棶棰', '闂鐨勬祻瑙堥噺瓒呰繃2500浜烘', 1, 0), +(32, '瀛﹂棶瀹', 2, '瀛﹂棶瀹', '绗竴娆″洖绛旇鎶曡禐鎴愮エ10娆′互涓', 0, 0), +(33, 'beta鐢ㄦ埛', 2, 'beta鐢ㄦ埛', 'beta鏈熼棿娲昏穬鍙備笌', 0, 0), +(34, '瀵煎笀', 2, '瀵煎笀', '琚寚瀹氫负鏈浣崇瓟妗堝苟涓旇禐鎴愮エ40浠ヤ笂', 1, 0), +(35, '宸笀', 2, '宸笀', '鍦ㄦ彁闂60澶╀箣鍚庡洖绛斿苟涓旇禐鎴愮エ5娆′互涓', 1, 0), +(36, '鍒嗙被涓撳', 2, '鍒嗙被涓撳', '鍒涘缓鐨勬爣绛捐50涓互涓婇棶棰樹娇鐢', 1, 0); diff --git a/sql_scripts/update_2009_01_24.sql b/sql_scripts/update_2009_01_24.sql new file mode 100644 index 0000000000..45b83935fc --- /dev/null +++ b/sql_scripts/update_2009_01_24.sql @@ -0,0 +1,2 @@ +ALTER TABLE award ADD COLUMN `content_type_id` int(11); +ALTER TABLE award ADD COLUMN `object_id` int(10); \ No newline at end of file diff --git a/sql_scripts/update_2009_01_25_001.sql b/sql_scripts/update_2009_01_25_001.sql new file mode 100644 index 0000000000..1f1942e380 --- /dev/null +++ b/sql_scripts/update_2009_01_25_001.sql @@ -0,0 +1,2 @@ +锘緼LTER TABLE `award` ADD `content_type_id` INT NULL +ALTER TABLE `award` ADD `object_id` INT NULL \ No newline at end of file diff --git a/sql_scripts/update_2009_02_26_001.sql b/sql_scripts/update_2009_02_26_001.sql new file mode 100644 index 0000000000..9cc8097488 --- /dev/null +++ b/sql_scripts/update_2009_02_26_001.sql @@ -0,0 +1,19 @@ +锘緼LTER TABLE answer ADD COLUMN `accepted_at` datetime default null; + +/* Update accepted_at column with answer added datetime for existing data */ +UPDATE answer +SET accepted_at = added_at +WHERE accepted = 1 AND accepted_at IS NULL; + +/* workround for c# url problem on bluehost server */ +UPDATE tag +SET name = 'csharp' +WHERE name = 'c#' + +UPDATE question +SET tagnames = replace(tagnames, 'c#', 'csharp') +WHERE tagnames like '%c#%' + +UPDATE question_revision +SET tagnames = replace(tagnames, 'c#', 'csharp') +WHERE tagnames like '%c#%' \ No newline at end of file diff --git a/sql_scripts/update_2009_04_10_001.sql b/sql_scripts/update_2009_04_10_001.sql new file mode 100644 index 0000000000..b0d05ac710 --- /dev/null +++ b/sql_scripts/update_2009_04_10_001.sql @@ -0,0 +1,3 @@ +锘緼LTER TABLE Tag ADD COLUMN deleted_at datetime default null; +ALTER TABLE Tag ADD COLUMN deleted_by_id INTEGER NULL; +ALTER TABLE Tag ADD COLUMN deleted TINYINT NOT NULL; \ No newline at end of file diff --git a/sql_scripts/update_2009_12_24_001.sql b/sql_scripts/update_2009_12_24_001.sql new file mode 100644 index 0000000000..3d082c2f84 --- /dev/null +++ b/sql_scripts/update_2009_12_24_001.sql @@ -0,0 +1,5 @@ +alter table question add column `vote_up_count` int(11) NOT NULL; +alter table question add column `vote_down_count` int(11) NOT NULL; + +alter table answer add column `vote_up_count` int(11) NOT NULL; +alter table answer add column `vote_down_count` int(11) NOT NULL; \ No newline at end of file diff --git a/sql_scripts/update_2009_12_27_001.sql b/sql_scripts/update_2009_12_27_001.sql new file mode 100644 index 0000000000..e2da7d4d48 --- /dev/null +++ b/sql_scripts/update_2009_12_27_001.sql @@ -0,0 +1,3 @@ +ALTER TABLE comment DROP INDEX content_type_id; + +ALTER TABLE comment ADD INDEX `content_type_id` (`content_type_id`,`object_id`,`user_id`); \ No newline at end of file diff --git a/sql_scripts/update_2009_12_27_002.sql b/sql_scripts/update_2009_12_27_002.sql new file mode 100644 index 0000000000..a36470bfd1 --- /dev/null +++ b/sql_scripts/update_2009_12_27_002.sql @@ -0,0 +1 @@ +ALTER TABLE `vote` ADD `voted_at` DATETIME NOT NULL \ No newline at end of file diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000000..02725854a9 --- /dev/null +++ b/templates/404.html @@ -0,0 +1,48 @@ +{% extends "base_content.html" %} +{% block title %}{% spaceless %}404 Error{% endspaceless %}{% endblock %} +{% block forestyle%} + +{% endblock %} +{% block forejs %} + +{% endblock %} +{% block content %} +
+ 404 Not Found +
+
+
+

瀵逛笉璧凤紝娌℃湁鎵惧埌鎮ㄨ姹傜殑椤甸潰锛

+
+ 鏈夊彲鑳芥槸浠ヤ笅鍘熷洜瀵艰嚧锛
+
    +
  • 浣犳鍦ㄦ煡鐪嬬殑闂鎴栬呭洖绛斿凡缁忚鍒犻櫎锛
  • +
  • 璇锋眰鐨勫湴鍧鏈夎 - 璇锋牳瀹炲師濮婾RL鍦板潃锛
  • +
  • 璁块棶鐨勯〉闈㈣淇濇姢鎴栦綘鐨勭Н鍒嗕笉澶燂紝鍙傝 faq
  • +
  • 濡傛灉浣犵‘淇′笉璇ュ嚭鐜404閿欒锛岃鎶ュ憡杩欎釜闂
  • + +
+ + +
+ +
+{% endblock %} + + + diff --git a/templates/500.html b/templates/500.html new file mode 100644 index 0000000000..2e89783a1d --- /dev/null +++ b/templates/500.html @@ -0,0 +1,33 @@ +{% extends "base_content.html" %} +{% block title %}{% spaceless %}500 Error{% endspaceless %}{% endblock %} +{% block forejs %} + +{% endblock %} +{% block content %} +
+ 500 Server Error +
+
+
+

瀵逛笉璧凤紝绯荤粺鍙戠敓浜嗛敊璇紝涓嶈兘鍝嶅簲鎮ㄧ殑璇锋眰锛

+
+ 绯荤粺宸茬粡璁板綍閿欒鏃ュ織锛屾垜浠細灏藉揩瑙e喅姝ら棶棰樸
+ 濡傛灉杩欎釜闂闀挎椂闂存病鏈夎淇锛岃鎼滅储鏌ョ湅褰撳墠闂鐨勭姸鎬侊紝鎴栬呮姤鍛婃柊鐨刡ug銆傛劅璋㈡偍鐨勬敮鎸侊紒 + +
+ +
+{% endblock %} + + + diff --git a/templates/about.html b/templates/about.html new file mode 100644 index 0000000000..6638060e95 --- /dev/null +++ b/templates/about.html @@ -0,0 +1,71 @@ +{% extends "base_content.html" %} +{% load extra_tags %} +{% load humanize %} +{% block title %}{% spaceless %}鍏充簬鏈珯{% endspaceless %}{% endblock %} +{% block forejs %} +{% endblock %} +{% block content %} +
+鍏充簬鏈珯 +
+ +
+

+ CNProg 鏄涓涓潰鍚戜腑鍥界▼搴忓憳鐨勫厤璐规妧鏈棶绛旂ぞ鍖銆傚畠鏄竴涓粙浜庤鍧涖佸崥瀹€佺淮鍩哄拰Digg涔嬮棿鐨勭ぞ鍖虹郴缁燂紝鍩轰簬Python鍜孌jango寮鍙戙
+ 鍒涘姙CNProg鐨勭伒鎰熸潵鑷簬鍥藉鐭ュ悕QA绀惧尯StackOverflow锛屼絾鏄疌NProg涓嶄粎浠呮槸涓涓眽鍖栫増鐨凷O銆
+ 鎴戜滑閫氳繃寮婧愮ぞ鍖烘潵缁存姢鍜屾洿鏂版簮浠g爜锛屼綘鍙互璁块棶杩欓噷鑾峰彇鏈珯鐨勬墍鏈夋簮浠g爜锛堣娉ㄦ剰婧愪唬鐮佷娇鐢ㄧ殑鎺堟潈璁稿彲锛夈
+

+
+

+ 鎴戜滑涓嶈繍浣滅ぞ鍖猴紝鐢变綘鏉ヨ繍浣溿CNProg 鏄涓涓敱鐢ㄦ埛鏉ラ┍鍔ㄧ殑绀惧尯銆傛瘡涓敤鎴蜂笉浠呮槸绠$悊鍛橈紝涔熸槸绀惧尯鍔熻兘闇姹傜殑鎻愬嚭鑰呫
+ 绀惧尯鍐呭鏄崗浣滅殑锛岀郴缁熻秺淇′换浣狅紝浣犲氨鍦ㄧぞ鍖鸿幏寰楁洿澶氱殑绠$悊鏉冮檺锛屽彲浠ュ紑濮嬬紪杈戦棶棰樻垨鍥炵瓟锛 + 甯姪鎴戜滑缁勭粐闂鍜岀瓟妗堬紝甯姪闇瑕佸府鍔╃殑骞垮ぇ绋嬪簭鍛樼敤鎴枫
+ 閫忔槑銆佸紑鏀俱佸叏姘戠鐞嗙殑杩愪綔妯″紡鏄湰缃戠珯鐨勭壒鐐癸紝鎴戜滑甯屾湜閫氳繃CNProg璁╃敤鎴疯兘澶熸洿鍔犲鏄撳湴瀵绘眰甯姪锛屾壘鍒伴棶棰樼瓟妗堬紝瑙e喅瀹為檯鐨勬妧鏈棶棰樸 +

+

+ 鎴戜滑鍏虫敞鍥藉唴绋嬪簭鍛樼殑鎴愰暱! +

+ +
+

浣犱滑鏄皝锛

+

+ 鎴戜滑鏄竴缇ゅ鏂楀湪浜掕仈缃戠殑缂栫▼鐖卞ソ鑰咃紝鍜屼綘涓鏍凤紝涔熸槸甯屾湜鑷繁缂栧啓楂樿川閲忚蒋浠剁殑寮鍙戜汉鍛樸 + 鎴戜滑鐨勫洟闃燂細 +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+ 娆㈣繋璁块棶鎴戜滑鐨鍥㈤槦Blog鎴栨煡鐪嬫洿澶氫粙缁嶇殑CNProg FAQ銆 +

+
+{% endblock %} + + + diff --git a/templates/answer_edit.html b/templates/answer_edit.html new file mode 100644 index 0000000000..f914660aa7 --- /dev/null +++ b/templates/answer_edit.html @@ -0,0 +1,139 @@ +{% extends "base.html" %} +{% block title %}{% spaceless %}淇敼鍥炵瓟{% endspaceless %}{% endblock %} +{% block forejs %} + + + + + + + +{% endblock %} + +{% block content %} +
+ 淇敼鍥炵瓟 [杩斿洖] +
+
+
+
+
+ {% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul }}{% endif %} +
+ {{ revision_form.revision }} +

+
+
+ {{ form.text }} + +
棰勮寮鍏
+
+
+
+ + {{ form.summary.label_tag }}
+ {{ form.summary }} {{ form.summary.errors }} +
+ {{ form.summary.help_text }} +
+
+ + +
+
+
+
+
+{% endblock %} + +{% block sidebar %} +
+

鍙楁杩庣殑鎻愰棶

+
+
    +
  • + 鎮ㄧ殑闂涓庣紪绋嬬浉鍏冲悧锛 +
  • +
  • + 寤鸿鎮ㄦ彁鐨勯棶棰樻槸鍙互琚瓟澶嶇殑锛岃屼笉浠呬粎鏄彲浠ヨ璁恒 +
  • +
  • + 璇疯缁嗘弿杩版偍鐨勯棶棰樸 +
  • +
  • + 鎴戜滑鎺ㄨ崘鎮ㄤ娇鐢ㄤ腑鏂囨弿杩伴棶棰橈紝杩欐牱鍙互寰楀埌鏇村鐨勭瓟澶嶆満浼氥 +
  • +
+ faq 禄 +
+
+
+ +
+

Markdown蹇熷弬鑰

+
    +
  • + *鏂滀綋* 鎴栬 _鏂滀綋_ + +
  • +
  • + **鍔犵矖** 鎴栬 __鍔犵矖__ + +
  • +
  • + 閾炬帴锛氫竴涓猍渚嬪瓙](http://url.com/ "鏍囬") + +
  • + +
  • + 鍥剧墖锛![alt 鏂囨湰](/path/img.jpg "鏍囬") + +
  • +
  • + 鍒楄〃锛 + 1. Foo + 2. Bar +
  • +
  • + 鍩烘湰鐨凥TML鏍囩涔熸槸鏀寔鐨 +
  • +
+ 鏈夊叧Markdown璇︾粏璇存槑 禄 +
+
+ +{% endblock %} + +{% block endjs %} +{% endblock %} + diff --git a/templates/ask.html b/templates/ask.html new file mode 100644 index 0000000000..ecd176bcdb --- /dev/null +++ b/templates/ask.html @@ -0,0 +1,191 @@ +{% extends "base.html" %} +{% block title %}{% spaceless %}鎴戣鎻愰棶{% endspaceless %}{% endblock %} +{% block forejs %} + + + + + + + +{% endblock %} + +{% block content %} +
+ 鎴戣鎻愰棶 +
+
+
+
+

+
+ {{ form.title }} {{ form.title.errors }} +

+ {{ form.title.help_text }} +
+

+ +

+

+ {{ form.text }} + +
+ + + + + + +
+ 棰勮寮鍏 + + {{ form.wiki }} {{ form.wiki.label_tag }} +
+
+
+ +
+

+

+ {{ form.tags.label_tag }}:
+ {{ form.tags }} {{ form.tags.errors }} +

+ {{ form.tags.help_text }} +
+

+
+ {% if not request.user.is_authenticated %} + + + + + + +
+ 浣跨敤 OpenID 鐧诲綍锛
+ {{ form.openid }} +
+ 鑾峰彇鎮ㄨ嚜宸辩殑OpenID銆 +
+
+
+
+
+ 鎮ㄧ殑澶у悕:
+ {{ form.user }} +

+ 鐢靛瓙閭欢:锛堜笉浼氬叕寮鏄剧ず锛
+ {{ form.email }} +

+
+ {% endif %} + +

+
+
+
+{% endblock %} + +{% block sidebar %} +
+

鍙楁杩庣殑鎻愰棶

+
+
    +
  • + 鎮ㄧ殑闂涓庣紪绋嬬浉鍏冲悧锛 +
  • +
  • + 寤鸿鎮ㄦ彁鐨勯棶棰樻槸鍙互琚瓟澶嶇殑锛岃屼笉浠呬粎鏄彲浠ヨ璁恒 +
  • +
  • + 璇疯缁嗘弿杩版偍鐨勯棶棰樸 +
  • +
  • + 鎴戜滑鎺ㄨ崘鎮ㄤ娇鐢ㄤ腑鏂囨弿杩伴棶棰橈紝杩欐牱鍙互寰楀埌鏇村鐨勭瓟澶嶆満浼氥 +
  • +
+ faq 禄 +
+
+
+ +
+

Markdown蹇熷弬鑰

+
    +
  • + *鏂滀綋* 鎴栬 _鏂滀綋_ + +
  • +
  • + **鍔犵矖** 鎴栬 __鍔犵矖__ + +
  • +
  • + 閾炬帴锛氫竴涓猍渚嬪瓙](http://url.com/ "鏍囬") + +
  • + +
  • + 鍥剧墖锛![alt 鏂囨湰](/path/img.jpg "鏍囬") + +
  • +
  • + 鍒楄〃锛 + 1. Foo + 2. Bar +
  • +
  • + 鍩烘湰鐨凥TML鏍囩涔熸槸鏀寔鐨 +
  • +
+ 鏈夊叧Markdown璇︾粏璇存槑 禄 +
+
+ +{% endblock %} + +{% block endjs %} +{% endblock %} + diff --git a/templates/authopenid/changeemail.html b/templates/authopenid/changeemail.html new file mode 100644 index 0000000000..a6c53a648c --- /dev/null +++ b/templates/authopenid/changeemail.html @@ -0,0 +1,39 @@ +{% extends "base_content.html" %} +{% load i18n %} + + + + +{% block content %} +
+

+ {% trans "Account: change email" %} +

+
+

{% blocktrans %}This is where you can change the email address associated with your account. Please keep this email address up to date so we can send you a password-reset email if you request one.{% endblocktrans %}

+{% if form.errors %} +

{% trans "Please correct errors below:" %}
+ {% if form.email.errors %} + {{ form.email.errors|join:", " }} + {% endif %} + {% if form.password.errors %} + {{ form.password.errors|join:", " }} + {% endif %} +

+{% endif %} + +{% if msg %} +

{{ msg }}

+{% endif %} + +
+
+ +
{{ form.email }}
+
{{ form.password }}
+ +

+ +
+
+{% endblock %} diff --git a/templates/authopenid/changeopenid.html b/templates/authopenid/changeopenid.html new file mode 100644 index 0000000000..c1f3d180df --- /dev/null +++ b/templates/authopenid/changeopenid.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +
+

+ {% trans "Account: change OpenID URL" %} +

+
+ +

{% blocktrans %}This is where you can change your OpenID URL. Make sure you remember it!{% endblocktrans %}

+{% if form.errors %} +

{% trans "Please correct errors below:" %}
+ {% if form.openid_url.errors %} + {{ form.openid_url.errors|join:", " }} + {% endif %} + + +

+{% endif %} +{% if msg %} +

{{ msg }}

+{% endif %} + +
+
+ +
{{ form.openid_url }}
+

+ +
+
+{% endblock %} diff --git a/templates/authopenid/changepw.html b/templates/authopenid/changepw.html new file mode 100644 index 0000000000..f3cf4be0d2 --- /dev/null +++ b/templates/authopenid/changepw.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block head %} + +{% endblock %} + + + +{% block content %} +
+

+ {% trans "Account: change password" %} +

+
+

{% blocktrans %}This is where you can change your password. Make sure you remember it!{% endblocktrans %}

+{% if form.errors %} +

{% trans "Please correct errors below:" %}
+{{ form.errors }} +

+{% endif %} + +
+
+ +
{{ form.oldpw }}
+
{{ form.password1 }}
+
{{ form.password2 }}
+

+ +
+
+{% endblock %} diff --git a/templates/authopenid/complete.html b/templates/authopenid/complete.html new file mode 100644 index 0000000000..fd243f2833 --- /dev/null +++ b/templates/authopenid/complete.html @@ -0,0 +1,66 @@ +{% extends "base.html" %} +{% block head %}{% endblock %} +{% block title %}{% spaceless %}缁戝畾OpenID{% endspaceless %}{% endblock %} +{% block content %} +
+ 缁戝畾OpenID甯愬彿 + +
+

+

鎮ㄧ殑OpenID甯愬彿宸茬粡楠岃瘉閫氳繃! 璇峰畬鎴愭渶鍚庝竴姝 - 缁戝畾OpenID鍒版偍鐨勫笎鍙枫

+

杈撳叆鎮ㄧ殑鏂板笎鍙锋垨鑰呮寚瀹氬凡缁忓瓨鍦ㄧ殑甯愬彿銆

+

+ + {% if form1.errors %} +

+ 璇锋敞鎰忎互涓嬮敊璇細
+

    + {% if form1.username.errors %} +
  • {{ form1.username.errors|join:", " }}
  • + {% endif %} + {% if form1.email.errors %} +
  • {{ form1.email.errors|join:", " }}
  • + {% endif %} +
+

+ {% endif %} + {% if form2.errors %} +

+ 璇锋敞鎰忎互涓嬮敊璇細
+

    + {% if form2.username.errors %} +
  • {{ form2.username.errors|join:", " }}
  • + {% endif %} + {% if form2.password.errors %} +
  • {{ form2.password.errors|join:", " }}
  • + {% endif %} +
+

+ {% endif %} + + + +{% endblock %} + + + diff --git a/templates/authopenid/confirm_email.txt b/templates/authopenid/confirm_email.txt new file mode 100644 index 0000000000..9af177ed81 --- /dev/null +++ b/templates/authopenid/confirm_email.txt @@ -0,0 +1,12 @@ +Thank you for registering. + +Your account details are: + +Username: {{ username }} +Password: {{ password }} + + +You may sign in here: +{{ site_url }}signin/ + + diff --git a/templates/authopenid/delete.html b/templates/authopenid/delete.html new file mode 100644 index 0000000000..19e0884ab5 --- /dev/null +++ b/templates/authopenid/delete.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} +{% load i18n %} + + +{% block content %} +
+

+ {% trans "Account: delete account" %} +

+
+ +

{% blocktrans %}Note: After deleting your account, anyone will be able to register this username.{% endblocktrans %}

+{% if form.errors %} +

{% trans "Please correct errors below:" %}
+ {% if form.confirm.errors %} + {% trans "Check confirm box, if you want delete your account." %}
+ {% endif %} + {% if form.password.errors %} + {% trans "Password:" %} {{ form.password.errors|join:", " }} + {% endif %} +

+{% endif %} +{% if msg %} +

{% trans "Please correct errors below:" %}
+ {{ msg }} +

+{% endif %} +
+
+ +
{{ form.confirm }} {% trans "I am sure I want to delete my account." %}
+
{{ form.password }} {% trans "(required for your security)" %}
+ +

+ +
+
+{% endblock %} diff --git a/templates/authopenid/failure.html b/templates/authopenid/failure.html new file mode 100644 index 0000000000..87839ab2c5 --- /dev/null +++ b/templates/authopenid/failure.html @@ -0,0 +1,13 @@ + + + + OpenID failed + + +

OpenID failed

+ +

{{ message|escape }}

+ + + \ No newline at end of file diff --git a/templates/authopenid/sendpw.html b/templates/authopenid/sendpw.html new file mode 100644 index 0000000000..237a5cf675 --- /dev/null +++ b/templates/authopenid/sendpw.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} +{% block title %}{% spaceless %}鍙戦佹柊瀵嗙爜{% endspaceless %}{% endblock %} + +{% block content %} +
+

鍙戦佹柊瀵嗙爜

+ +
+
+涓㈠け浜嗘偍鐨勫瘑鐮侊紵 浣犲彲浠ュ湪杩欓噷閲嶈瀵嗙爜銆
+璇疯緭鍏ョ敤鎴峰悕锛屾柊鐨勫瘑鐮佷細鍙戦佸埌浣犳敞鍐屾椂鍊欏~鍐欑殑鐢靛瓙閭欢銆 +
+{% if form.errors %} +

璇锋敞鎰忎互涓嬮敊璇細
+ {% if form.username.errors %} + {{ form.username.errors|join:", " }} + {% endif %} +

+{% endif %} +{% if msg %} +
{{ msg }}
+{% endif %} + +
+
+
{{ form.username }}
+ +

杩斿洖鐧诲綍

+ +
+ 娉ㄦ剰: 鏂扮殑瀵嗙爜鍙湁鎮ㄥ湪婵娲婚偖浠朵腑鐨勯摼鎺ュ悗鎵嶄細琚縺娲汇 +
+{% endblock %} diff --git a/templates/authopenid/sendpw_email.txt b/templates/authopenid/sendpw_email.txt new file mode 100644 index 0000000000..dec062a806 --- /dev/null +++ b/templates/authopenid/sendpw_email.txt @@ -0,0 +1,14 @@ +Someone has requested to reset your password on {{ site_url }}. +If this is not you, it is safe to ignore this email. + +Your new account details are: + +Username: {{ username }} +New password: {{ password }} + +To confirm reset of your password go to this address: +{{ site_url }}{{ url_confirm }}?key={{ confirm_key }} + +Regards, + + diff --git a/templates/authopenid/settings.html b/templates/authopenid/settings.html new file mode 100644 index 0000000000..c765b989f2 --- /dev/null +++ b/templates/authopenid/settings.html @@ -0,0 +1,41 @@ +{% extends "base_content.html" %} +{% load i18n %} + +{% block head %} + +{% endblock %} + +{% block content %} +
+

{{ request.user.username }}璐︽埛璁剧疆

+
+
+ {% if msg %} +

{{ msg }}

+ {% endif %} + +
+
淇敼瀵嗙爜
+
{% trans "Give your account a new password." %}
+
鏇存崲鐢靛瓙閭欢
+
{% trans "Add or update the email address associated with your account." %}
+ {% if is_openid %} +
鏇存崲OpenID鍦板潃
+
{% trans "Change openid associated to your account" %}
+ {% endif %} + +
鍒犻櫎甯愬彿
+
{% trans "Erase your username and all your data from website" %}
+
+
+{% endblock %} diff --git a/templates/authopenid/signin.html b/templates/authopenid/signin.html new file mode 100644 index 0000000000..9c5511f22b --- /dev/null +++ b/templates/authopenid/signin.html @@ -0,0 +1,96 @@ +{% extends "base.html" %} +{% block title %}{% spaceless %}鐢ㄦ埛鐧诲綍{% endspaceless %}{% endblock %} +{% block forejs %} + + + +{% endblock %} +{% block content %} +
+ 鐢ㄦ埛鐧诲綍 +
+ +{% endblock %} + +{% block sidebar %} +
+

涓轰粈涔堥渶瑕丱penID鐧诲綍锛

+

+

    +
  • + 鏋勫缓鍦∣penID缃戠粶璁よ瘉涓婄殑鏈郴缁燂紝涓嶉渶瑕佷綘娉ㄥ唽鏂扮殑甯愬彿锛屽嵆鍙娇鐢ㄦ垜浠郴缁熺殑鎵鏈夊姛鑳 +
  • +
  • + 鐢ㄥ悓涓涓笎鍙峰彲鐧诲綍浜掕仈缃戞墍鏈夋縺娲籓penID鐨勭綉绔 + +
  • +
  • + 鍏ㄤ笘鐣屾湁1.6浜縊penID甯愬彿锛屽拰10,000涓敮鎸丱penID鐨勭珯鐐 + +
  • +
  • + OpenID鏄湁寮鏀炬爣鍑嗭紝骞朵笖鏈夌浉鍏崇殑鍩洪噾缁勭粐鎻愪緵鏀寔 + +
  • + +
+ 鏌ョ湅鏇村 禄
+ 鑾峰彇OpenID 禄 +

+
+
+{% endblock%} + diff --git a/templates/authopenid/signup.html b/templates/authopenid/signup.html new file mode 100644 index 0000000000..e51544f714 --- /dev/null +++ b/templates/authopenid/signup.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} +{% block title %}{% spaceless %}娉ㄥ唽甯愬彿{% endspaceless %}{% endblock %} + +{% block content %} +
+

娉ㄥ唽甯愬彿

+ +
+
+

鎴戜滑鏀寔涓ょ娉ㄥ唽鏂瑰紡锛屼綘鍙互浣跨敤甯歌鐨勭敤鎴峰悕銆佸瘑鐮佹柟寮忔敞鍐岋紝鎴栬浣跨敤OpenID甯愬彿娉ㄥ唽

+ + {% if form.errors %} + +

+ 璇锋敞鎰忎互涓嬮敊璇細
+

    + {% if form.username.errors %} +
  • {{ form.username.errors|join:", " }}
  • + {% endif %} + {% if form.email.errors %} +
  • {{ form.email.errors|join:", " }}
  • + {% endif %} + {% if form.password2.errors %} +
  • {{ form.password2.errors|join:", " }} +
  • + {% endif %} +
+

+ {% endif %} +
+
+
+ 甯歌娉ㄥ唽 +

{{ form.username }}
+ +

{{ form.email }}
+

{{ form.password1 }}
+

{{ form.password2 }}
+ +
+
+
+
+
+ +
+
{{ form2.openid_url }}
+
+
+
+{% endblock %} diff --git a/templates/authopenid/yadis.xrdf b/templates/authopenid/yadis.xrdf new file mode 100644 index 0000000000..a9ed44fecf --- /dev/null +++ b/templates/authopenid/yadis.xrdf @@ -0,0 +1,14 @@ + + + + + http://specs.openid.net/auth/2.0/return_to + {% for uri in return_to %} + {{ uri }} + {% endfor %} + + + \ No newline at end of file diff --git a/templates/badge.html b/templates/badge.html new file mode 100644 index 0000000000..4ffedfa61e --- /dev/null +++ b/templates/badge.html @@ -0,0 +1,38 @@ +{% extends "base_content.html" %} +{% load extra_tags %} +{% load humanize %} +{% block title %}{% spaceless %}{{ badge.name }}-濂栫墝{% endspaceless %}{% endblock %} +{% block forejs %} + +{% endblock %} +{% block content %} +
+ 濂栫墝 +
+
+

+  {{ badge.name }} {{ badge.description }} +

+
+ {% if badge.awarded_count %} +

{{ awards|length|intcomma }} + 鐢ㄦ埛宸茶鎺堜簣璇ュ鐗岋細

+ {% endif %} +
+
+ {% for award in awards %} +

{{ award.name }} {% get_score_badge_by_details award.rep award.gold award.silver award.bronze %}

+ {% endfor %} +
+ +
+{% endblock %} + + + + diff --git a/templates/badges.html b/templates/badges.html new file mode 100644 index 0000000000..eb5a0233c3 --- /dev/null +++ b/templates/badges.html @@ -0,0 +1,72 @@ +{% extends "base.html" %} +{% load extra_tags %} +{% load humanize %} +{% block title %}{% spaceless %}濂栫墝鍒楄〃{% endspaceless %}{% endblock %} +{% block forejs %} + +{% endblock %} +{% block content %} +
+ 濂栫墝姒 +
+
+

+ 鎻愬嚭闂锛岀粰浜堝洖绛旓紝鎶曞嚭浣犵殑绁 - CNProg 浼氶拡瀵逛綘鍦ㄧぞ鍖虹殑琛ㄧ幇锛屾巿浜堜綘鍚勭被濂栫墝銆
+ 杩欓噷鍒楀嚭绀惧尯鎵鏈夌殑濂栫墝锛屼互鍙婂埌鐩墠涓烘锛屾瘡涓鐗岃鎺堜簣鐨勭敤鎴蜂汉鏁般 +

+
+
+ {% for badge in badges %} +
+
+ {% for a in mybadges %} + {% ifequal a.badge_id badge.id %} + + {% endifequal %} + {% endfor %} +
+
+  {{ badge.name }} 脳 {{ badge.awarded_count|intcomma }} +
+

+ {{ badge.description }} +

+
+ {% endfor %} +
+
+{% endblock %} +{% block sidebar %} + +
+

绀惧尯濂栫墝

+
+

+  閲戠墝 +

+

+ 閲戠墝鏄崄鍒嗙綍瑙佺殑銆備綘涓嶄粎瑕佸弬涓庣ぞ鍖虹殑鎻愰棶銆佸洖绛斻佹姇绁ㄧ瓑娲诲姩锛岃屼笖闇瑕佹湁楂樻繁鐨勭煡璇嗗拰鑳藉姏鎵嶈兘鑾峰緱銆傝幏寰楅噾鐗屾剰鍛崇潃浣犲湪鏌愪釜灞傛涓婂凡缁忚揪鍒颁簡椤跺嘲銆 +

+

+  閾剁墝 +

+

+ 閾剁墝闇瑕佺粡杩囬暱鏃堕棿鐨勫鏂楁墠鑳借幏寰椼傚畠鏄笉鍚屽甯哥殑鑽h獕锛屽彧瑕佷綘浠樺嚭瓒冲鐨勫姫鍔涘氨浼氬緱鍒般 +

+

+  閾滅墝 +

+

+ 閾滅墝浼氬湪浣犳椿璺冧簬绀惧尯鏃朵骇鐢燂紝瀹冪浉瀵瑰鏄撹幏寰楋紝浣嗕篃鏄竴绉嶇壒娈婄殑鑽h獕銆 +

+
+
+{% endblock %} + + + diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000000..3ed3b3f44b --- /dev/null +++ b/templates/base.html @@ -0,0 +1,82 @@ +锘縶% load extra_filters %} + + + + {% block title %}{% endblock %} - CNProg.com 绋嬪簭鍛橀棶绛旂ぞ鍖 + {% spaceless %} + {% block meta %}{% endblock %} + {% endspaceless %} + + + + + + + + + + {% with request.user.get_messages as messages%} + {% if messages %} + + + + {% endif %} + {% endwith %} + + {% block forejs %} + {% endblock %} + + + + {% include "header.html" %} +
+
+
+ {% block content%} + {% endblock%} + +
+ +
+ {% block sidebar%} + {% endblock%} + +
+
+ {% block tail %} + {% endblock %} +
+
+
+
+ {% include "footer.html" %} + {% block endjs %} + {% endblock %} + + diff --git a/templates/base_content.html b/templates/base_content.html new file mode 100644 index 0000000000..7fec09ed3f --- /dev/null +++ b/templates/base_content.html @@ -0,0 +1,75 @@ +锘 + + + {% block title %}{% endblock %} - CNProg.com 绋嬪簭鍛橀棶绛旂ぞ鍖 + + + + + {% spaceless %} + {% block forestyle %}{% endblock %} + {% endspaceless %} + + + + + + + {% with request.user.get_messages as messages%} + {% if messages %} + + + {% endif %} + {% endwith %} + + {% block forejs %} + {% endblock %} + + + + {% include "header.html" %} +
+
+
+ {% block content%} + {% endblock%} + +
+
+ {% block tail %} + {% endblock %} +
+
+
+
+ {% include "footer.html" %} + {% block endjs %} + {% endblock %} + + diff --git a/templates/book.html b/templates/book.html new file mode 100644 index 0000000000..e5d4396b3f --- /dev/null +++ b/templates/book.html @@ -0,0 +1,150 @@ +{% extends "base_content.html" %} +{% load extra_tags %} +{% load extra_filters %} +{% load humanize %} +{% block title %}{% spaceless %}{{ book.title }}-璇讳功棰戦亾{% endspaceless %}{% endblock %} +{% block forejs %} + +{% endblock %} +{% block content %} + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if author_info.blog_url %} + + + + + + {% endif %} + + + + + + + + +
銆愪綔鑰呫{{ book.author }}
銆愬嚭鐗堢ぞ銆{{ book.publication }}
銆愬嚭鐗堟棩鏈熴{{ book.published_at|date:"Y-m" }}
銆愪环鏍笺{{ book.price }} 鍏
銆愰〉鏁般{{ book.pages }} 椤
銆愭爣绛俱{{ book.tagnames }}
 
浣滆呭崥瀹 禄
涔︾睄鐩綍 禄
缃戜笂璐拱 禄
+
+
+ +
+
+ + +{% endblock %} +{% block tail %} + +
+ {% cnprog_paginator context %} + +
+ + +{% endblock %} \ No newline at end of file diff --git a/templates/close.html b/templates/close.html new file mode 100644 index 0000000000..04a22f184d --- /dev/null +++ b/templates/close.html @@ -0,0 +1,36 @@ +{% extends "base_content.html" %} +{% load extra_tags %} +{% load humanize %} +{% block title %}{% spaceless %}鍏抽棴闂{% endspaceless %}{% endblock %} +{% block forejs %} + +{% endblock %} +{% block content %} +
+ 鍏抽棴闂 +
+
+

鐢变簬浠ヤ笅鍘熷洜锛屼綘瑕佸叧闂繖涓棶棰橈細 + {{ question.get_question_title }} +

+ +
+

+ 鍘熷洜锛 {{ form.reason }} +

+
+ + + +
+ +
+
+{% endblock %} + + + diff --git a/templates/content/images/box-arrow.gif b/templates/content/images/box-arrow.gif new file mode 100644 index 0000000000000000000000000000000000000000..89dcf5b3dd40fac0e6afb0b1a7ff899a059f923f GIT binary patch literal 69 zcmZ?wbhEHbWM@!dXkcJ?_wL=lfBzJJvM@6+Ff!;c00Bsbfk~#Pf92`7{EJz*0#eqW WoE7iinDij`X5pe+YFj-S8LR>Nkr%B1 literal 0 HcmV?d00001 diff --git a/templates/content/images/bullet_green.gif b/templates/content/images/bullet_green.gif new file mode 100644 index 0000000000000000000000000000000000000000..fa530910f9dc11fadaa2314f72bd98f29df39daf GIT binary patch literal 64 zcmZ?wbhEHbKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=00004XF*Lt006O$eEU(80000WV@Og>004R=004l4008;_004mL004C` z008P>0026e000+nl3&F}000VaNklJyRN8J52lge3Dk<@*>AXrMmGP=H z$s9P2&*V2vPMX-1L}oIXPMP_nlH^n>#fZ%$`c@)Y4M0h*N)5H*Dy5UhPr>W;VqjnZ zld(w!&=SoOtX;bn<{y|*_V7bUrc~hhgft*Y9vryzSY}M06iG7y={dwn-rQt#5xb>+`RC^f6v^z4(Q|d8B-!MDTk(XP{Q8r-@ZB!XmXA&5bSa9P_XS zTCEm>AV9CzqqMXX0MOIZgGeL-kH>?Fi3wI$un4HD--X4uEk+`dKs=E^A`wR-kx-fp zO5tksDt`IIQ;5Z45Cj2ErxSX;UeVb|B!b%7T6jDjXfztMI$CGF)V0_(RPU_$!r;hu zn9lZ|rQW`C)aUP`!JwZmydNaNB2aqrl2)swmX;QZMx!*Bbai!+R;y+0iVQ_`zOR=C zgM;K7?4#bkbL8zkOJ~GxdiQVd(CO||bmE=kWH1;A09mb81)hvE^BFSsTgU&bNJWOC ztT-;GleTW!d{a21qod^O>my%ZAB~QV=7j@*cmPnPZLnIUf?B22T%*y5Kp=qT=4NQM z+BwaG)oMjJ9A;B#Bs79{#}S1s=b1+$c_V(GAE8hPf*_!N_wIR3kkx91AP5)f1LhU0p{MZ^CXrv4!x zo%i*U_q?RV@4WXHG89YN8xDu_#t(4No=U&Jo}T#mV+4R& zT3YDP!9xUqj=uF)UN~}pe0_Zq-ks~{XWMO5zpIW`EYs79WqNWsojGx`Xt1Qkj%OUq z-gb3$&8xN9M61=p>-Dm>jzf;LFP+w4F6~qEJVKX3FqurVY@E$zV_I&r*%W1Zy&fi$ zNwKnrLK03{Ss5PLxDjJxV>r{@jTOuE`0wO3Y}U!qMyXh{a+E1ug;r z%7vfc5AII1wI9abrbYmOyR$1Njx4Ng@pzP#D|w7a2#pJ(xpq`?(9P7 z(xtp`WNCd?Qn=s$@fCLONB7?k0Eoq6`1s0|oH&eNS)06GFC(YAx|&rIMG+Q@1!l7u zX0sV~yFF)FM@NUkUdmeRJ?qWTUJe{TP4H(Sciwdu+S(6ebaWK;yXsK#z1#8j(W5AP za099~Z(%lcF41T-aJgK#O|t|qzx;C6I-h)UeNGH%qrq|DISvB@1Com+2#gp}6k#@- z6^%qugeZ!ruC9i~VwqKT;lc%Ub#*Z;x7&?@fdOd;m?l;tmt%fqw#7`=T&vYOt2|qq znfGF`7|wKeqpkfgte0#kdvF5)px@_1zt4xl!a{J1)N|r2Qmav4SBKjcFJ|}peLj|7 zreBt`KN%V&|pt!ggq9`H~i6}ZI575lK?1PG;2!p|(*jdfQ`Nd<8qjleYth#+Asy1)I zhnFL$sH{X=`(adV+m;v3*w`3anwqh7(`K~p+mF_L`_a_U007v%XHU-lCm%bWIiI-6)J@3jZHeAiPP48 z7`7cdaOL0s!au`dxSUSxZE8eCWhLwf_M>FY>UnW&J9fafV}~@*ot^0F?8Nm?u46;l zL)cQaHD`YmCgSsyb?eu`P;7w5^H-xjdsS!VZ-~n8|ENOLdaWM?V#dG2)HJFr9tW0|%YqQ(!#>B(~ zg25n`FJBJ3-OkG7ZE|K==5(HpkFp;{CmLHCq0wmIcDrG*SXi6PC|e{FfyH7$M@I)V z8Vz<<@0|5AdwyG=6=&D(I=ueo8#jfsdd+H7R92#*vJ!^k;=FKJu*W|x zk_klrGl7HlgUpvS8jUa-jnHbf5Jiy<`g}o}Yq4u+JLq6Rn$Hu51$+93`cY6&0DF@i zo?{+pwOT}@QH5vVa=BPA$7C|0xw)AQfXn4#bu-HVVEOXph(sc|?}zu{h_fBnr=}2} zL9iS*P9;<$H0nVR0kLsr+|JUhsq9(&;-H5o|Zng_MaPR;g z-0%RV;!~K4$B~G~5l_q@I7^9PX4ba;*Y)WDdvcoO zj3Xnq$kMHKWW*MC0MyXjK>pzY3SJD*qd$FA5m5^S0t2x}BJ@2C6#Q+Tk{q)lBUdp@e%wwXN`OJIs z;mp@QAFOP37K$-TgJr3Cx*Ap6s@PGF=0 zojBKXZow~eGp1oalQ0+lLI*8hj5!IG<=)bJv7u}O?pS>XzM;{iKb@L3Fhqo_u^5I1 zhj9Aj=>-$}S!wXi+Ti)tginp&ujD2+8btKz>$5D*Z6fPgSCFq)s4ARr)MU|_7VtMKsfouZtnuBfQ3r*Lp^p{JlwP*A0- zq@1Cfpr)U+x3i3qjFXs>m70`}la833m$0y~v9++Cqn)6jpqHGMz`(%8$i=R+t&Nh5 zq^hHon3I;9m5!5*kCcwBvaFPulefCIqo|^rpqjY6xQ2>_tFEfP!M(q~zmb-Z!NkF^ zwXdY8ql%A-qNbsRiG-}Lte>Bs;NakWfqamakWo`mhl_^E%*n~k$!@r-RpNfu(v9z$Sv#yYkkeQyCudlC)kBZUM(1?tO zq^G09#>2L{waw7X)7H|dtf|k^&Z@1dwYap%%g3Rnpm}|HoS>VDj);<%k)^1lkd%*< znUoe67OAhPkB^U=pqrYWnXa;~tgx)LxwV*_my3^z@9*!Vs-!|hLJJEE8XFqAy}820 z!LYNi*4fs!xwVOnh@YgMczkyP0|LLozM`n1$;-&Gx3G12b)27@&e6@Ks-%;clc1!Z zl9iELU0PIERKmr=g^Gl;xU$R6%ErmX(9_Soz`eA&vvhZJw79gjyR?6Tex|CWKte!! ze|o5^sL;^RDk~`}EGmwYjcRUc3=9mnytX_&Jifucp{1cyRZ^m+qKAxzv9+<2my*1| zySTi!USM6Wv8@CI1gx&B#K*);PD|9+)XdM!frWsAg@J;Ef}NwCwYjvIo0pN4k*ct% zkd=>?nw0?o0Y*qh4h{~2hk=ffjhdaB($&(6jfskliU$Y>VrF8;%Ewe!Q_RoHvbC|Y zx3QF$lY@wYo1U6AHZ_uzl9rj3L`6i<)6kimm}F>Vnw^=Ko0g)bp~T3;Y;J7I%*u?A zi_X!`p`)OSkc!gP(Qa{V)Yj9fuBnickDZ{LGc+@`xV4UvjvpW&CnzUB|c9N&VVzJZykO{A@7ep{vsL1vFKYgqeXubk1PL(42z&9igG8PKEBsFPIbL zzuPQqj4CqrEMY-TigvwMdElbc@~G}?X^61YtXXhr(%*jbi-!-Jue-W#b9KF5yD6eD zG(SjF64G7tA(Ghdlk_}`JVPm!JQBK@x7?q+>*R5;X>8YkBG!65q%bTk1~iJr2WW=JJ~jRjbon3xmwrNDO*a zj8qu;_Rc+*E`y`Yo;3ev)#}vR9aBP(_;`r}kZjp=;#qK<=jP3C*uK?uX;3q;pvPI9 zfqm`VvjJda^Fw`W#GE*aSdf@^{sBhL;jbH-(rWWdmQch)^7j?@j>9PVXg+opnq?<$ zEB*U?*A_OWtovol6lT zk{gZzmk$IR0h<8$b?RJydzC)N#DxPSfrKCd?xt?Cku|+AVihEG6-7Upu?vBKBf$Cu zhrwm5!fP=j1=+9M2bUr7S=dntD*$k zBIB_rQk#DTXz~UC*U81i#hzSTXaQUffIxw70&o!(96pZ0_PpRzc?`yu*-L}+fPRpx z$4E|w)*YmXYFXy2v5~I|H2aWvTgm>B09zIx#^D0y#h~+1G?8bn96<=Clh#zQq3_~? z(ikgw8p*gm$AYvao&D-r&E%LRNc1YXa-738Jk2 zgDjl@emcqSE0v0AqEYKv-zpnfBN4j2HasE2AdIx$F&GZy z)l8%aPwjyua;BpyiV6i6DrDnH0Z9Ke)lQ^BUk4_hlmRHx`M?e%`LmSk^hmTio+U&2 z$k)xyZ8$@a{i%TcQR1~oD)CpW%|rS~C=~i08|KF0*u``t>8lCP!SCZjqWlHYe#aCHq+7okbzZ<)Gb1){Qx_Tj|xVU(lHGjqzmFVb&=VEhn z65E0GTai~TiOk;xxGNv*6zP;~$ zL=pRI=o}0zK|=?`(YY`y#vshVBMqwZlP@K6uJqQv$DA@VwuNcj!QOze1Hx?ViXp=^ zM(qw5GE49{VI~IDqX;;t;^6i>%F@`WJ_EYme@8^MqmJhE400000NkvXXu0mjf D3>(Ui literal 0 HcmV?d00001 diff --git a/templates/content/images/close-small-hover.png b/templates/content/images/close-small-hover.png new file mode 100644 index 0000000000000000000000000000000000000000..7899aec7213b837143a2e975faa90a2abd456521 GIT binary patch literal 337 zcmeAS@N?(olHy`uVBq!ia0vp^d?3ui3?$#C89V|~+9j?LCC){ui6xo&c?uz!xv2~x z8Knv)3c;xb3PuJ7779kjR>r1QCT0q{1{MYeDE)e-c@Ne1ia=5ZCX&{{Hy&_tW!N_ZKfc zpObUM#pTWAs~3xk4w#ty`t$F>lBGXhy}DLgdpr1Q#zqRd1{MYe;g^zIfZEtgJbhi+Z*Z~+S_nO6;N1-r z;wE)e-c@Ne1ia=5Z4(qXDwR1Wb5`Fd-okU zaq{%lYd1c8`uyw9U!Xizkhgxu4WI-^NswRge+Xc>*St3pD5mS_;uunKD_NtRfsJRE z&YnFcvL4forc1XpAK{H{IrvG{>z#&4h|Ds+W&FE$GCZx(SSr0JY6i#_Pgg&ebxsLQ E08gA+X#fBK literal 0 HcmV?d00001 diff --git a/templates/content/images/cnprog_logo_200_56.gif b/templates/content/images/cnprog_logo_200_56.gif new file mode 100644 index 0000000000000000000000000000000000000000..ab690de2a1c9679f225d80560cf5e06f3ed3cab0 GIT binary patch literal 2114 zcmb7<`#;kQ1INFc?}kmzHeo{yGuL*6N$J$gW^>CWm!Vv8cjzehrOw<6kC^+A;}XMS z9hWqvT#jUODI~OxD7lnMhwgPeub%(l`TX$y?frVaKMZ?2s{=tJfE6$U{MhR1YFJoU z4je8LiFS5&h(zLFDJkW6ypodA(yd#)QBgD+O_H5mT3RZVNZ!4BCvQ8_ z_=gUO#bT*c8W$IbL?S&rJmy@t@grT|{Qq zh0K_oTq=kM3b=(hHB}l|Sa{x!2he3@YU}FjC zB2wPg7;jqo?5x@bucWDJKv=WFQdv1#(Jmiiu3QehM=d1M%>Y4%J=mrPWvvHdlx41Y zW{_!hs0(#@wV*PUiDa7^E4ZQ3{n41+MvK%~K&xm6t$i^2870Ve4Dr-LN8G>8!a$)k z#3;u#TMRXp#cJ*{wMpP_nt9h$(PgvvlCQ>%z1`Gcc+knd#Ox>?ik#ISUP7 z#GoF#j`(()T+*;pki7QOd2ZU0?Y^JHaexWK{?0W{_Z}wUF4j{TvesPlwUA3#aZB+{ z7)YI}-H*93NW2`4MCuAPrZFhsV^1KID+PK(qmxx9HT5C{j_CnlC~n(<81SRAjmOZ zuX!fW#(kJC!;9E#B$#R1gk4Z3$`g2l&BG|F95wx6RDusfYIzZrf6-9!GW!ob- z5RpcTnp9Vz>-kOzC5~=XgNdh_RbUiRA=>DONAs;-F0M!f=HIj;uSn5mhkNdLM+7b5 zttN!evt6#TvEIC`GlR*a77ZMsw_@D)ox!xX7K_MBKlj;Xn&yVn*X$4(SGL98H(cy5 zf&^ht)zxu~uYy^YePFgdeCt_N^KETM`kCuam-B|;BBo=y&wza0g25i{{z1s9;c@Wp ze&a9Xi9#Ln)oD&b(J~Q9+94y}IMmm!fo9$8Q7O&LW-g-snULrAq*>Yf|&p0Y!q^tJn8k z?tt)jCuQEOXsK&=#eAh|voSsiUN2D@OH%{qg&)3si-LPzC+cf{8u&i1dX~zyBg*eu z-bm{Ad)$|uB+vu0aLRKWOl$|hrg5OXRto?t> zPs;`j#YI+Ta_ntCcl=0Gh^xqT($7(jnEs-ezc#2&^Ib?Ke5DdG))S zm~`)wK)`^@k;ex?RTinBr$R8jl4C5Hx|F5vo~7Fvlqbk2V~kOpuBSdP8*NKXa5^7XcD8 z4QWsdI1r7C`5UFWdm`=0ARYoS9W+*=jQTz@E6d4j+#8f)PaQ1c(kmPH2B$~@riysB z$$I-rbHGrePNSaPD|@pR$87%nr|^CQ@#pJ3qd^@(#WO=IiuPXGuTau6W^wK!GvRWYySSZdh?2JAdxm} z4@L^i%LZu%cDL5Y!_|r^6v_Ot5!AE>=`9+=W)GB#c ztC+B+x0S*yDC=ru#=O9JeRGiAsbOSn}iGDZgXt#=z(6UXyd@4U( z9p+K1+}PylDVYqeCpV~jZunedKO8Wcsk6P?$beXTjnyac40o+ME*)eE_+<1U&jvr7 z+Dy~YW2K+-em&vy#b^9N_x0_KjWC80YkmdO^^qoUe<5Hc8J!dr=&hPb4JX4f7B{LM z>bdE^oQoKI)chgd_$2z3TiqSyiUj&8t0wh@7R^~vNn3ykwMuQi;n{m$UugJo7o*wY z%44O6^@w_RU$I_(C>NM#?PUynb#!n{pa@KQ2Ee)H7 io>#?{QxAKS722~IPR}q^pN0&Mw&!{uAI1ZK^?v~_GK-J^ literal 0 HcmV?d00001 diff --git a/templates/content/images/dash.gif b/templates/content/images/dash.gif new file mode 100644 index 0000000000000000000000000000000000000000..d1ddc507fe00bd654fce38ac8552793aa18c9966 GIT binary patch literal 44 wcmZ?wbhEHbWMN=rXkcLY|NsBAY10&cvM{hS{AbW%00NK<0~50k11p0y023w&(*OVf literal 0 HcmV?d00001 diff --git a/templates/content/images/djangomade124x25_grey.gif b/templates/content/images/djangomade124x25_grey.gif new file mode 100644 index 0000000000000000000000000000000000000000..d34bb311615b1378a672a828c7a7916490cd882b GIT binary patch literal 2035 zcmcJOSyz(>0zk8Y5oHk(5d(s_FbFhAqNt4L16&YNCyID%iyA#v9i~-V)T#$7C{?Rq zJuXmNkX;Zk3t36XzAs-E$W8(YK|~TDELE}gFw-9~_w_#9r@MFGo{ViLN+D5@_t6k? zub_>}Y9`ZKyBS?Q+zuw^CB28p=9m6l=^h>P&(87W>M^fRs?m>(j#(W;9ErkUvGq!o zR>z=aV9@3qVhSZRzIguQM;cEA4PH>{`)!UPyVLdOr%&oW6O}KX^iRvR21>7B_K!bg zpuy#NEl_HdeI}XK;2M6dGg;OB7NH7sx`ycjiOOJXqcVp_-!Mh8P9}%M;d7*l9dn^o^Yc8JiXo6#2L{zfi^DzK#p>;|ITX6Se!BxS zS=nOw+`D&V4qvF$^jqyzo~TDG>y;|lVi{d1<;qn?yF=A))|stRQ2&y_<|)*2U7tjw zV~V8YUSW?!VYCi#Byx?(%9SZ)x_-xyo5JBc-5#D?H9GEn-bvP4>_a1?Mw^2xQ-LN+ zBe7ec(5U;2FS?oT(KkAyXb zH`<+SiGsov4vvg6M6xClb-?9rrO;i&BX+lk$mV$`rZ`gN>v8YfiAm6G<101ow4OKP zUbVqQ?BTjSuXPq%Yd5pISJ261cQQEjo#Yk@y{?1ASAq*s-`cubDGW-lki_O|%{D4etT9^j7JEC5N#je{GL^~hpbMnVVNY!b z@p%VHZ?SpC-cHTTm>h#mB$`;Qbq9D5VJ`EU_H44c4@Fu%*g{g$2m} zjre&46atBcB>!Fb`w0kg0fIg2-$QN?-a;-U9a~C|Sx_l#$$ zbyds`pGKe0LOZIh;hTXQH~7?2Jo0 zAKTtHp2*){xDdLxDX)5Bq$d9S)rRYTt~R1BZu8%arq9oL7S0X{cVZ83Md|CWuc5Ww zgHJrm4n{311;Egli>`(nMilUQIqb4)5Q?cl#}=HzL03S&F5J5ZvF3I&1iAmphxib7 z=~(%y)r?(&s;zbaOiB%VcyqB)a3LW*6`!N2T5$*vtPDAu4Lr&i{1t{hUIbJv$v&)4 zc!CfB!4I<5zFha<24-Hg2z@rDMTRf&8K%(xp|Jl;8yyb7(z29dO~7 z0?>d2d_u(#9&?g)BczhRg5UXUk{R}HU+hrKk846$t{)2uvfo5}`X_+FT_r3*q@K(Q zIFy3^Nem&SdwmdC?f@$3a69--AQ=DME>cj0|A&0oy86<nZyuyLVuwr{IGXQux+DRXY@2U6(<)cxduLt8LR@#Wa`O=WAre>^=26DJK^^h~Zenh_Qpc_eE|a>K3SC}>hGS%%baA>Rzm6~eB6s0c`oTN0US zfK?FULsI-Xr|IOSn-WhZ6RhFiUYWj6SlS#V&y{WdZMyPn->wo=`JS}ytYDdcZ9-8+ z#g^jc^%g~Q?0bcL=f~+^%9ggo{bjwMjFH13QK!~qEei?la)%F0L$*X*t*SoddGxEM zWy4mba{slN#|^%bl*nZdHaOy*)Xwd`S5&UbXN;^SSGFdf*{A-}K2y!otWP}=A9U0{ sv!XO(598i6?6_>^sSNjGbB$7Sdi(Nfq+XETwht`+l3E>&L_&7_7sn(m+5i9m literal 0 HcmV?d00001 diff --git a/templates/content/images/dot-g.gif b/templates/content/images/dot-g.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d6bb28e56377b0eeb80899222aa3290ec2a3a95 GIT binary patch literal 61 zcmZ?wbhEHb1;oomohA-cw8MruKF$f7>W?=Zo!hivofRLHNli}wd9fr@0yBS{oImf`r!T=CJ zObo<=KYvmfSa>QJq}1IQ{xNkh{QGMS5(Wq$!Uiw`?fv_wh=H9yhCxi_BLl18R|YAy zzYGlQ%?$tlTLT0TVFP~usbb(1@&ju6$nf>=e}=c;7#aR?|7H-C1iI?46+i&7;IWyL z;n$xU20l?+1~CPo=06M!Uw{_>X8zCc{xt`~yO&=Xm{>Lg1Q0F*xPh8m83e@j8ARki zGJO8U!0_!K1H&(%gWtd9WO)AQ6T^RoY6eEe8vp@>#en~UKxelz2uZ60@n?olzZn_6 z{|9LXI{!5n!^+`mIW?f>FASf4GBSJvI{OzR z1H&<(HAFtjse0v3qvG*Lj!k<6yW@2D$#+OV00*L7y zBZtO!W_$i{sO4^#Rs-O?>`EBV-VT&i$$;vm@)9CGk^eM*?-}6i0Jdne+|V2 zxHvw3_{Z?+(@RDM_T7w3%nJ!=1_6KoVp+N8l7OGV`-jpW1oz1C@m=Tm^ZxZW7V#J0 oz$F3z1Q6r@|Nj{%0RRC80Nya-9-e3d82|tP07*qoM6N<$g1t^w0{{R3 literal 0 HcmV?d00001 diff --git a/templates/content/images/expander-arrow-hide.gif b/templates/content/images/expander-arrow-hide.gif new file mode 100644 index 0000000000000000000000000000000000000000..feb6a6187c2742ea8e516244f139e7946ed757fb GIT binary patch literal 126 zcmZ?wbhEHb6k!l$Xl7tYOG_&#C^&ZP*n$NM9zTBE+}u2E+O#ug&iw!Xp8*?C{K>-1 zz`((v1Cj)p!N8&|aME-2UW?afcmGe&$YV~Jr(qS6`f6R+>scREmz$PdzB_la&4mZ% LT2lR!I2fz}g2F4- literal 0 HcmV?d00001 diff --git a/templates/content/images/expander-arrow-show.gif b/templates/content/images/expander-arrow-show.gif new file mode 100644 index 0000000000000000000000000000000000000000..6825c56ee42f0184d66c0fe954d7fc4b6f05e850 GIT binary patch literal 135 zcmZ?wbhEHb6k!l$Xl7tYOG|5RZr;3k^RZ*c9zTA(V8Mcdf`WVZ?*0G&p8*?C{K>-1 zz`((v1Cj)p!N6i7aME-2(x+KmpRPH4k6ma{w6t6)bw%IW-N%f4X5Wr&{_cHgU%a-) Votr)GNqpOrH0{qn(_mt-1^|9hF$Dks literal 0 HcmV?d00001 diff --git a/templates/content/images/favicon.gif b/templates/content/images/favicon.gif new file mode 100644 index 0000000000000000000000000000000000000000..910c26660ca2088729309bd9286403237c68f020 GIT binary patch literal 3918 zcmbW4c~Fyg9>#yUNJtP)x!weWgv&qzDu*Ooazu*Ax**6A?m#F| z#FlF#9t(;HE^Pr(qXI z-2eFF`O(pZt5?67np&Qp|52}h`SRuD^+4uZpoiarROc-Y=tt|i%;*;JiL9^h)J(kR8={VcqXm=O|2+G557evqSo zC4;<`@96Hl*};|V5xz6wP*t|`sZ7kDo#_C6CNPGd^ZHHY|5cc7fBzl`f@||hZ0x0^ zq^k!G+{nutFD#rWD!L5UW^iy}bX0%k%3ojA=GR|;U9&DQvs}c4(mRc#qV7Cv4Z&c* zLCQBL-U$F7X`)1K0JpokLg4DdXA@68)phSMQSGddBvPcJ^xm9crN!xkZh;NgNGu+#nbC<&x=VP|rFS9;3_ zj;-zMGTYnt`1ze%VIGQ$8&N1${Qxsx(r7;I=$JcyUOzgzxWc@&VurPW;jggHAA#ib zCc+Bs*L0XxV|qFSrF{v*3L0%}C{@#+YGGJx1(c|3FHuSDswLr9-VxEcK|N*I>z)cO z5sazQn%M)V$Jw8Jw}{xraNg?5Wo;)L%N>l#{$v8j5kaU=WDDbRNXPv>B`HTb8k!uM zTPQWPObul{<}N3v9&hhe=D$QnUS0{njl#mQ`ub^Dc!$B?EZCu z4a_BaGPn@|mQL6PEVF?7-Fsk?-(_`+^0r3&6ezVv}k(MJ!MWwCeo=RvKZjqEsSHTfUyPN0&ic1z}Lo+w~7;T zoB1tKO0!nYdohjglPjuY)b8Bwn6mYtJLvQtAD>m|H_bg!SU6c@If1BD?&y`=} z1C!d_y}R#tz10A2mAj!(4eIJ_E97@~MKw*?|3Vm3*c1Yy7(q};s3d2x{2;8Sw=}J( zyt1fTO)V@AFJ&^c`|B!m4+Cs37L~mobr*-TDs}%#qz(3d73sV6^>dw_4_>ML?ez2y z4tB-p#c{o5kUiZq3pxKm`BGLR!LqyxX)KqC5S{hR$emBeWXR2 zelv>Y40<@AJmB``mU&i9E3HARXVvPq_h&!JYN$X|KA%6BU*Ih*re^14g3_Z|XK@o!bKSBX#B-fQSk*>~vBytZx*{waAbaK}QWzpA z1z~4{KXWdOv6f?szK0bR) zJHu`k$&GQG_Fc4O1qo-;uRQ$Vm&);b&t}yX4n3j0W_=zLMK``s6k9znbmw^{;^OR? zL>8NA;uP`dTHMb)Z$uQg2#^BM*;%qtM|1_TTxCA}8- zltyy~9#q4_k48ton40=w!>|V4JpG_yKzG+5?|6uBu`kp-y%NGjT}xc(yLsJ?WMye) zCkgUk9OFOg{kdTL@ZbW@DbqLiwDeoZ7F`Y|Ox*y>JYXE1lNL(L8acl70ZBq|B%1+D znMmv%j1N3oj3VN)%ngt`b8?U7mBlAyxG1yAS^L+7ZL_v+v$5%3X<9@3_KmEroca0V z1qIzO>Ch0oZ_dNJ*UZc+?7I8r>aKz*)NiK4TW7V$`6i3@6m56r_pAy#idy>e{n)H8 zQR+BuNu2|O8P;>`v9T1LfDX8pyhJl9wU$SenE)Ni#kJJRifnX0tmr9?EKDEh@Bx^j z?Pg>#WbB=H1Z9d%gF%f-@XD;boFYeGM6y$ATCuC2bZ;y(#vyubU>dF6*0#sr|F=f{ z#+uz-TRS%}@a4seaKBo-eEHc*b~ozgqwr}F0-qNBp@|{BwRGIXk3%k;&$jusbkCjT ziP7(spldHejJLLu7bVc!eN_TrBp+m;0MT43VN@BNrUwSl-LMteF|sWr2;pBQY2f2M za&lo!6IYDOOHIpB<_WeT_A%s%`Hr!nKpN#JV@d1-!ySXyUN~DfZGs1K_xA0upWi$z zt`!u(cNaXGZnm|}oICfs-D?98#uUhz(WE4t>Kc?3(%OA{ghB>+w%oZO=CIu5-Z^f0 z5Gc#Fx4{pW{lvvJ15INx$fk#?)lc=^{E;UjX3h~AZU~cW%Ib}1#Lu1%8eW9^Q9RjT zV74MDYk#hn6JjqTHr{+YXJ@#CzpH`aFAfkhsT=>6uXA*I$0q9APGs15AnsE45@AR#B=Sy~Sf!dr{@s%Rq3LRWB z5#$C2*|_(+7+&yMm3cg(rrnmRs%zw+@F}uW7NhLQw7=_1`@^l^&dZLCPg7*MJ0T(& ivS@P;4zyG37NllSyo7GPE?fc6&zb4C#R)zfz5fG3#T7&V literal 0 HcmV?d00001 diff --git a/templates/content/images/favicon.ico b/templates/content/images/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..b5c6f57805a25d425da12528990530afea643e96 GIT binary patch literal 3638 zcmeHJX;c(R68?$;Y%Z}u4)1ex#9LUEQAAwDRlHC{Wfd0}XGH`>&~aGZMYnNu6}lU_ zW_2L%t?XUS^zL!;%nURqZUwn~K z00R{a7yxD4rUs0ouaP5r#|Z+!pXR=#AuqyDGoVRo^BLvqH;-pYO4-lnSuKHTCC7Oli@Y7 zEbU?#T>}Gtoz++4<<%HX10lb^KfhmHOP|pc3fMmVy!-%xpX5-bXwu&4i+rP#PH#vm@y*-PEMuRz5532?XSSmF$=Y|uc4IKf$Eh44h|Q{uOG}}GY1hM!5VcURFqoQ!&Kt9Qr5XM1dV+7e2OR-A8 z!i6%zr(9VRJv^=;Dykau<|Wa&!Gv!!nwwvuy1EU621V2Pa-29(PIi}I*|Hq0T9t!C zhYBf<1*AI%0zn{(iyxEk4{+|>eN31TgVU#PQSD8lm?+TQ-HooUcj)MNgZB1LJbChp zFgZpsc}^IMp`&vW0|!P>tqsSB5s?&^r^JUC@-bRj!>3L?OEHZ@NXSiP9k;bjC$3b$ z)3ciFzd<;b6W;l#sCcTZ``OuTNK30nV&WYvU#`H~wHXkJipbwQFpLDMssY4-00@QQ z7&0URlP1L|{}U`NWmNx@;qTvs4I9prevb5BBizoA9d#rlBYml`wM``qaw$$3#McX? zw}9eMfX>c$c>VevUcP*TXU{s(*4BwfkA7DEN2sVs$=3i>RkfjCzY~O60P!P`>irinHjYMCRwMB~lJGi-^XKnl z*svJl>3xhIeF|g7L_wjrN3p1*96F7&XYXRllsKF@(}<~4V-XiuLwQh59FIqM_-)Ld zoem3&v&1K!%gG21uAsQdU~PR4M~@bh&zIrrTSV_%%DJ3R+y$M3wO(PEIMHXzuAhcXF@5oX|sm3!27poI;UO86RIM5|yWL(*)*udUKQl z;j1E8*3B+$ih^a!MQ(S~+=FXGa<;-e^NDiZOSs5x#zTGe)TKWMwc%J4P7ac-ko&R-n6U6nUhazHly{kYj&Miw=OD_6j?}Wv%|g$ zKKSjh8IDt=rJTaqX^A~LW9HAcW|)9lUolhAxOsetl^>%u$!!^1%1Q;XQOMqXCQ)o- zt-jeSyf{DLRAh^(n7K35?nLFSayIp!UdURq&eEpLG$Z85W>w4Y-?p{5N*G_)F13|A z?YNs?=E7sipDirD-s{GdA6cz^z|k(mREIHsY-MWd6@8>`@J2jebMJVeRg;uutI|EX z!j`5TEMoE{B>~=AUktcB*Z|u{EoQ`T?Uu0$?i&Y(N~xW!knt1GE0$Oky8M;yhqMLz z7_pT*?Uy@*8QhkpsTVROk59dCw`3$!eS)!FNuzuVz!)n5BtF?sjJ3RD(`+Gm8!29t1vSEzn%O4!! z^@l|pmH6w33IC^G)w>$|TNFtoMdEM2{>zSR{Bc51e215IxXVL|U!+J{leH&Y^-<%< z#G~p-3pJx)zvQH|TgZz|M#*p5g5xRvZ8=8C$=4jCJHl#aQTzb22D!A{AuX*&$)Bpb zb|Fn^O(FH1eEGkX{Kystv2tRbD1|F0{wZ6fNTG}#FYsjB{tA{Y%Y;9(T|Y#bze6a0 tFa5fgYClzfrl%X|X$M9$0J^zAzYjYJGyiY@P!IpzK>GP}`1AO4{{wV#b|wG- literal 0 HcmV?d00001 diff --git a/templates/content/images/feed-icon-small.png b/templates/content/images/feed-icon-small.png new file mode 100644 index 0000000000000000000000000000000000000000..b3c949d2244f2c0c81d65e74719af2a1b56d06a3 GIT binary patch literal 689 zcmV;i0#5yjP)(tky!*UETcH-TCU7SrqEjJM#?B`_A)!p7(kFf9-P@=@15kkTkGK zgFusyy#KECqZzRdBLb=P?$(kUP;>kYTDeG&{|a+iOiRbI6nbQ)j#7bOf>iF=C+|_py<&Fo1F5cC*iEM?zZGC{ejNg4LWYp=S$L6Qaby6y zp$+F`250{%tU{Lg$5*ROH}y!1UKJS4*xqd7P(Y3JQF?lrnf?yerr%&6yGXLG1ur*B z{$&R1@Oj)yl@%rY5rh?j(j10Yz_DBs`AKFU_QnB;)(aqQmGi&ieOS|21^NP9UMpa< zU&p!f6RZ6Owp^X!EXA=0SbN&h?CrQK%Q3(=YBqqHD^9ZUM0Hxt-6-KT;>lf@j?Z+v zHm(}`>85I&E<7e}oz?6UwjAogowzGO8kSN7+2`b^$Az9L{K5*ko87EV45LT-`_##3 z>d3AGh@>=mbg34|6}+-gT9N+6Dr@44VEl44O&{&|w=qpbzC#iWMKa?5)>tI+KLQK@ Xq0QFqn(9Yl00000NkvXXu0mjfZ8t40!3-puuch|@DVB6cUq=Rp^(V|(yIunMk|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5X*aCb)TzBu@{r~^}iVZzqfg(&L zL4Lvi8J=!8@B;EgJY5_^DsCku9AK6xWM-3k!OUU6z#qV1KKathOF(%BPgg&ebxsLQ E0Ke)mAOHXW literal 0 HcmV?d00001 diff --git a/templates/content/images/indicator.gif b/templates/content/images/indicator.gif new file mode 100644 index 0000000000000000000000000000000000000000..1c72ebb554be018511ae972c3f2361dff02dce02 GIT binary patch literal 2545 zcma*pX;2es8VB%~zPr=ibVMCx-JQ^BhLDAsK)^**h(ZDp9YGuzZ%~j!}+w%FI;|aC7){7CdVvG)P{bng1y9Te*f}~*`1kQl$jwb z$tlW~rRS!X?#xfm_&6tTdp_`cjgYwbRFLNdoJCN$S-yhg`ZnC-yvedRSmOh%;Y`Gl6bY$Z-}#C=#F4%9!I1b zWQ~f+9P?;vhCxWwlwl=lrWG|7IYo;{jjmzJ5R9?f>n%-d@>kLINUc z4wM5dAO;kq<$}Dk{2-u0$I6@2N}&cUx9nmV1dYc8jfC}%=F9WCg^OQK9C6poh#2!A z3^EU*UFZvS^)?bu3T?J;@Ahb~%I?+@4!l5!*TjC}GIslNan-RCrrd~PdHYnNLJk+m&`$Y+NV(e>CCu%R#_8GqY4cv#j`#uRWdsg9DxWy(?oOvgCU}&@jy%c!H&-Q zqXJxajAtmQRoRa9V-RFXXh-bK*;Fum{BjpkYQGX~i@OZ^Dx0n&H}kvGKqQ?w(6iGXu_g08T|_hp#ZvFzIwKF*a=oMJ~3UGAjZ?g}GOxm44td zXoyYrU*I=y*vHv89hkYH(v5R#wc)BC3dZJKb3K)f>zaM3%JP(mpecViP0eKKYf3zy z->jx_mc?mCtPEvCQ?uppk?eLJt}_IR7giW%Jr)RyI!+E-voIs*lXI*z`GQc_&D#X( z{6G};HPYj6O|$lXxBJeDaweqa{4L=tOZCjTI^&UOxXg})LRG_cr^B9Rqt(i5ORbQX zq`_xCRsH>xEYY%&*Nyi#{S_JZNlTm#K56`RI%7^amom;*h90Si&g1CfaFV3D|a!`3Y-GKKbL*KSbl z>I96`TR@CqPJl(>QqB~RvK~-U)`e`l4LIqj+IU^~yyIe*|BRVB>4Bup%j{tLdKz4j zY^<8P8m~GRGz*yv0&-RJE+-keJ+%m3wNeopzsltWd->eWmBVwUr)pX` zK~CD<;~Z*Uy3W`3+MrEYxm5qYQ!z%YI;y7DTG`UVH0;@{M{!B&id_}3DBQ?zsotuR zEGLdRx25nLm%-wjlnEi;-aN_1S7???rO~WgA67jjr&(vRa3y$u#kqJbeKnw z{!T!1li9>M+sJ6AUe+*9d}2uGjhzd z|L1Rtp8uTGYyZoQ*`DS^m2dw-X{a)l+3m?ncvn^+O>)hdd3(hMtlhkRGns{<8c0I! zDDjpmwtj?@!6kA|iu3q+Ai;@JR+ zfk+ln&YFC{4bhK6IxVgLs4W%^8Lk`qzWU*L>yq0A3;l}{!wKZ!ue)C)SKI)9dl1hl zhIRLV@8E}rwvE{gX(}$f6x*k)_`*Ijt1=EU-Ls6-(phomeQBgtUs z5Xz~Cd*nE)Ac!0i4ep}Z1AugMB(&F?)#CU{Qc{Sp^vKsdL}vRB30H+Bbzrn`M##H3 z{W8dc_mDroEE+p8_}mnJtzZ4!RNe)zhB)Ds;S57nYSJxtek>^~&(7B+N5MPf2+2xx z5Dl&4X|c@f{Kd|z1r+N|$DmsoVp*3yOdxT^J^-VAk)Z@$4^XrPrFP-Co+MXZ+KJ(W z{JNYvraLLWA;&tRhIKOvhW|HC|L-dLvAUF(MG0(Nl?4tB{RzN7I(}Cb%hwN{crFC8 zji#aJElKvDFV+&VI1V?oUMA>*kto0^;3W8FQBSZ|{ z$v~TqE=(8DZa^i$^oht&h};P1N&wMXorKh*Z68gPV&ouy>%f36Oqkwemyeas$Qbz# zV?7Jy%o7KY6^I=P@eCji%W`o5sf(5hySYo9$l4e2`(hIV_?=H-#R6}0$WVA|*(K@3 z=5?@RlcLh(meW%A4)hGzcvEpm(_w?>zhL*i&s9$2>r zAtk{8Cia|+Y+V!uX9BtpXoF%lswuRKsM!pSs!?yhlCy!269K0|b M?FSZn2B>%I-}ej|s{jB1 literal 0 HcmV?d00001 diff --git a/templates/content/images/logo.png b/templates/content/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..640eb1da4c1022a6b108951c4ad33abe7c55163b GIT binary patch literal 3631 zcmbVPdpOhW|Nne8o7v3fuwjKcB!`VTRWvo{$@BqUdf(Ukdfl(r`<)Z8-3N;% zp#cEE`Z7HOp{Rfs9R-8-I%jS-6jb)Q`MUu?gJL5hcM>}5AM#=!3fdoc=#Qw>Simi2 zKR1@_n;f+_HZV3S=IFr(v2+ORzOScSaN00;`PZ+l9Ts|sek1^PZYq;{gH(V4$o&ksss`{NLlxJKz^bc%TUs)Z z13{0naYi-~Ej&vbG8yO>4iL);@h0)+=_kLZYEvMfS!VXl8HDy-QDfo zYvJQ(4T9jp!U7tNR*(z~3>vR(O<$o8%DNN^p}FA0wV?X?D=&wIbGU}KwzCZlCqsyZ zcBDIS6aW*dC5no~Viarbw;+P&djSHYLm;dnk%WzPQfcAf3Rse?dxaHRReiXsZTVwQ z!DUT)06^x6X-YKB7c9c~O31s4)8rtnyr75oATcAmCw`b@0aa{54I{oLZ7!@qOa#Q= zzkk8+ys(bp0}g-;pppDL&xv$B7?I?+^y7!ea3I4;ZnCfA6gK9CYCndep{=E5@rO&> zRSilBF9Egdw$tz%5*~u2C=3{!M1vrN^tNmI%Ae!j8>Npz0s??wTvD!R$4xL9G!No* z{Ox{4b@~Ok7p@%4@5XCzC+*zMW8n4=Ai&29o_S;0B^7$lcvX8j>WpcD* zV+jRp{@HhyVm9#RZJWLYCOBhAZ9sTt@N~}oNDElL>%bt=QRVhyRaW@-p`oPZ<@1v5 zULlmqhW*MR=YDM>12EPi4qn5uLq=`GcwV|v+RK)MroPSFFK*JT5zV_}uz->n*Dk0c zFu%)L`gp`~rLu9Go7UO@VhT#Kr#xR?92K@Rt2RPK!Yo%~``OmL>wrVN&~CejoW^lO z1ng`^9}wW5p1$=YBEDl69t_9Shi1zV9m>_F zjGI|GiO5sxyu&NmpR$P3pJyyB>T3NiC5W;1%w$XwAJmlUXNEFhH_7XR>M{)EgL(nB zukakdM7BAF2XOftYZ@g;t6>$2OdX3Ac@ZgWfTD9X79(}(Ac?l!y*s|JLYwmWSnA-! z<&NxjPuRR!X2)iJ)Oq#-7E&%hMtrQov4=_4r{$`U1bgdZm~aTR;)1_?-qzR{OlBFe z<3)c-x8H1b*Sojn#Ia)&_`wOVd+mw|Si|V+Q5AcRJS0y}c0a2YC%`UU!<#fVLcDjg zbUJU7Wk#v{yrF?$eQMDHz7{Gl#+6#z(BR|8E@sW+9j>J)2fUU!dh-+g7xHxbI{A~h zpv?hzYSew@#y`byXX9tw8lrvl@!1hK=HjC_Zw$qJ(Rqa2dL5_7=uP_K;vx=(;#tEV zwqKT1RDcS^zprc~T7c=>@SW~R8UF)3yt{C6b2;_fj|Bkqe4dH;ilil1IMr)uYbV4Q zNI#g|L1cu!;W(jd$+Tp!%dW^=8d241#6LJQF(G_)Ih*2Fx;1^v{8#U&C}Wy`d2B*C zndU-<=PEkJxax*hkrOfVdu{2g(=ghJ|kKv zBalFAnt6NgUiz<-WVQV_+_#ZA^MWf@oF$cANFxCDu<{&PAu-<7A`hIU>j6^%0xuk- zDI=DRJ*|wv-7r5i^CB#R z^rpw>k~h2?CjAe>S6?ple)3uFsA`7|OmXXHeBXmdFuDqll6u_^Zvs$cVoNihyx2=B06)o53CU#r|@gSYSALbF&gsG)28%;GF$M5|&V!Ns^) zhGoO{1n84UXIlq#G`?nvw61uFp zlA5fy0s6`8*#d-o&96cc>%@r@$k}C_lvhnF_1KowS|4mq0FOgc zO!@kIYGF3Rzqa=8V`%{s>YN`0=i-qZ;6*UP+<;jI@5a!hl6fHVMQbFp9p-JFy2i-9 zZrh$8IeM#Jl=z143cFUf#=Pli<%QkjgfKIzD`LZ=r!LpzT91x?Uga8QGtKpb+M7wTUH;#W8}GI9p#;PdOF z`kksoKY7(y&haDq;t$-0NLAu)`8-Z$-abgQfQ_$ajn+tMEYf<+_5(SEFjIsLs&|QD zQw4bBZHWjMT0#o%`E44>d3F~-Dz1V@L$mI!+g@e=5VG)mL$rH1z;c`wQCSD}e~FW=fOr72b$+lAYXuct zm^skbw<9#vxlE@9Ge0!6v$WLq=g;G7geyOf&(9cnuC=J?>77;x?zWD9{`G6&?LFLv z$l%~$*{xeeRR}WA+mA9Vz#1BwUo-PTXx#pGpw@=GN!cF_cf2m>nY2+}hshX{H4cpfp znSx!_h3RAphnxMJr$~yp3Oei>&2^@~$A|TseB=oH(e!+^7QQ%nAD62UNRz+xj_-o6 zJkwR)#4Dd#CHBVf2W#3{i);^^bEyVr9SUmOGhL&Mub9!VqMau>NR#WW$n-#7ZDuCf z%yMM^%P9Y3alW2oe&w#$d5rl=9O+-WJFDub*WaRb34?)~P6SnkUS zsj65?~FuS!`bU$D)^-!7c=TtkEzP&&{czB=nw8$PFg zvho~SLA9dqJ~kdm%L~=Il8QK3KK=3%4=RaQtkYWzA9Qr;Wsstx)p<@AQx!rYBl^n ca~KjxC_UX>+E!}@~ literal 0 HcmV?d00001 diff --git a/templates/content/images/logo1.png b/templates/content/images/logo1.png new file mode 100644 index 0000000000000000000000000000000000000000..d79a627174b08ee90776540abad2e76f28909652 GIT binary patch literal 2752 zcmcguX* z1E?4wgA2<ibF5B?oZ9u^18n1*~xFBuz3-<%yx3)#_ftUE+Qo`d)qPK67?2S(r z0zbj_1R*mtDSopsN*FIl+1W1i27nS38t4}z)g^qLp7y;lhYt7a0jSl3L8?S)fQbgp z9GIgd0|RA`d?7_d00faod_JKJpnwt1uSD7Z2a|-B1yhe(GKu=epgmLHL<<`k8h-xr z#Rdb>9oZ&!^VeQMo#r!{pg-pxO=%%wiP-5se;)6v3??meND?n)RA!O@$<(3FLWQ+$ zOH6FdOV()2Oid#y4ULJnFZpl4eYEx}KeR}+M$Gk5S zqnm}0W#xsXD4uMIn&y?8n~Sx|d}IA$=JVCuRjV$XJ}sknP^i=`V|K{Uo}IS~d2w;U zw>#2*{<@gaLWBV!hwNSpj+t{B4+|*Cyj*>2K%9^omNa`xrFm7gG6I0)*hvDZW~2n9%+MzzWk{Tzj9=GEY?tX{kpHp1&$#)S9m54a>eAI8%Q-XV);&;*9apqP&PXYp>>%+b;E;=0xznd$s;o zNiW9QI{j^mKNAYvs+E&f1KTijaz9V7?^FoLb3{g=Tb7$1e){vBP^z+Zns=jU$thc( zw2kd%$grJDyMNT!)Sct9dhWuKlacvPp`- z8Y8&LnwaoBc`{&GJVY{O#mCp`P@%=Q3Yaf}s2B6C79AD5YR#P~V>m6)bOTOOJli=W zPNp*HEQD667cH}?Hg{}+gdgp}93YjUmp*9c`gj8_aBZ0sW8avY zX6NiSFgF7CK79K0^heY)4c1V_P-sdc?>r6RHTL$J{dk^GMMm!9(tmz0dWka-lQA#W zXdf`;=ExOJv+V3vx`;W^wrWq(KyLp>!+{ofPxJF9|Ku2~4KPy`&%r!MfevTFv?hRH zP^Pv`=qS9h326iT7wKo$i=g2*B^lbLre~#DL(I(n28>2Gg^v4`z>bmBWVf432BE}! z=%dyMYS3f}wFCnuO`6FNZ&g-=WBwi8-KIYYS~6hF|43W|sCKWJaqiix73<%aT>M#5 z?iKC8)_XL&u;F5WRi;7`VW01Uz?7QJJz;?DfTU)e2~pZhZ!ORA0JzhpA(Hd7nVDJl ztq(E=8|M-c?lGfz@4u1lb$BMrC2Om_dxO4-tz2^b_1KuqlAiJtXpSQ6`8qPSH$8nC zMZpy}rL*@|27`gFMY^W63My8YCbaRwy~}3>~>!x8!nLwhyfOZXVGBycPfMA^MtwF)p}uJ zB~ORB*G&5!yTZ<$OqwMMHLF_PJ&jGd-SXLoYICY?CVF(&Vw#m#{b%s+m#mJxx&FG3 z8EpzW20O+=4wK)eCMQ3=(LXxwIZs6*uopv5ROAkrE?rPBaxA;pgO}{nULCe zHva>TDb#W^s+&*5L4WaxR#7-B1|!KkpC9{0e>FF=@ssguLF9d|wA!E~;qk9j!Nb{V z724{=IXkjH?b#LE~)Ia~*I(j^ z&q7!0`jgh#H!;;L(ylgBpXh9_2S(;HM+P(Zgj)SipDbK@^n^bC=|1xLztn?+(cTs; zL9LTzC`o)-7zuSAeKT~#fv@{a-vaYz1u)j9(QBzS8#fk8^g^SuEFbTf!OCZm@e1Hz zk~G1k6;|w?^B68VecJwAmXgBAYOPakiL>pz(w!`at=gC8Z#gHN?r?plOG7Gru6NLxkY;S=fF2z|YbO3%qJzr|R*`t+_ElUU&&^^{glpQP5mHpLzxP@1#e01HOQOj08Vo z)cfHL0^U{i&=SYTLGdn3&Ju3SY#4p@t=L7hVjDBl94p&Pms&GXe$dl$W59QduVdfz zK_DwVt5H0(psqg{TB3EPB_MT+v zLYBDN^U+I)`GZ+Th^mq2lakVw_C)=`4cD`4R&i(Ib*)VL&w?yA@5bAw@19`~{B3xY kse_>K@2>xA`@bf7AU)z?-rE%2I=lr1p}dH|I)5bN->?*N_5c6? literal 0 HcmV?d00001 diff --git a/templates/content/images/logo2.png b/templates/content/images/logo2.png new file mode 100644 index 0000000000000000000000000000000000000000..bd3cccd9f47793f86864cd068621ab07198b5ff0 GIT binary patch literal 2124 zcmcIm`&Uy}7Cw1j9(f?ogb*T6 zR7xF)f`B{(Do|8Luizj$s9*~MRt2>X1!+Z~1*!Hr|H7>K;heqp+UuPCt?ygs+owPh z9z-=}83O>QA;AHWSUia>UkH!w{6lRrED-njZSe!3sdpXe0oyJ}doah{1$l3>n$0jEa145Xm{l=`0 z1LOGW4g>)b$0!*Rr7zHbv%EOo9Z|$Fo71*7zJWCy1avV4C^u25yk)w+l|hG~+NP%M z5{YQYU@)jZ|6}ppWJ?dj(b2ICDyt7~YcEeqbnFp!&dzSWetl`j4p9%R#_ovkDqA); zH&^*-g-KjDYY(ZuwsyF`U!+y!<>j?5(BX=hvuhN^Uk??}&Q{n9Y4Zjg#C7RoPy$Wi z{*X1KD~4_Y4Z$7tC2Omw9FAC!5Acv66G_Q!o6uY7#pImab!WWHb~w?Z0Yl``%a$|q z+>?+r?Ts74s#CZ+-0m|}TfQ#NUh)?>(Z$J0GLxDv2Bn)2Z1H?F;I?WNsG~%EmS7Pjk|D)ZWt7A)huHmXOer^gBJH%1K9jp$`#$4x zb~w%Q?@pblQ{_46k=OZ}+xH(tNCYC#!ac#N_JOZWKf7U{DDkgy2`d$SnL*NS*Lyk0 z%meWH?Wzzz0i!T%m4v~F`SGnry4R#TIUJ1vJ3A0IipV;YRq&)YZGt}EW(eud{ zE;wK6z~y^1FP?Bu(p|Q0-uZ9VP{;H9U`&*-j-@vuhP{16BhsxE$`{EVKiAp{q~8uq zr@u2SsG*&O$?=ivqQiihvx^*$fSkYwVxu7!GvA=hX{$Q^|2i*Q5IBWivcFZ#_XbQb<4Md2}~BtK?7vNsOe@; z8A7rc8k5Y~=#YTZ36{>eteYjoWt1`AYnuXw~+sOqb zwxMU@^F4f%7!EBh=q1a|wAiZ_D+JOhUX!JJa2*$iS7#3pi1YLFdk4gKV7j*>o*xr) z>u|a52rtb9z` zL5qYJFB}IWKha&}+a4CAY57e4)62=pAG~t$p>#RjdtqsQ+_oJzW`~!f=cC-qY`D zk$bnEefjm5qa|4Mzj(KDJvR>pqy+7to)KGbH~EW!4A`pNaZ zoo-AVwbdl!!x09)Z|CpRy=ESskd{ID`jXDLfL?hW9X-=U$GpHyAgw3%zFZB{#O zNiG-P)g6G3eOSK97L?xGE4MfIYy#f`>zXaygC;%Ei~H&H6ZB;yzeOe+$gdv&7;t@C zrZ*)T@!lqtLa&6cr>4Y#2wypjY&gET2c|!nXb&Nw67mG0^=3cjK+>=HMrGJ-oxxOB?TeD9oE*q;kn@I-k&}bV{vSuh^`1%k6r<;IMd1E+ZG{w0g~MyWjA*d`_?1 z@A$la&+q&HfPsR8goTEOh-(y!jE#0PICFAzz_X{% zpFo2O9ZIyQ(W6L{DqYI7sne%Wqe>k@wW`&tShH%~%C)Q4uV7~+8cVjU*|TU7DOk(4 zt=qS7(BTJr4xw7TUm@^~T z%(=7Y&!9t#9!C>oFt6t5zwd>cgV;`7JySDAyxO3~?&AYen-@tu`Sa-0t6$H)z5Dm@NG7S| zk}d||0+o_zM{=bwNED(Iku7HVjkApih7e}UBq literal 0 HcmV?d00001 diff --git a/templates/content/images/medala_on.gif b/templates/content/images/medala_on.gif new file mode 100644 index 0000000000000000000000000000000000000000..a18f9e8562941254941a446efad3e6edcb651d9c GIT binary patch literal 957 zcmV;u148^qNk%w1VJrb40K@E)v5}!; z41e42_PDkdcy;l$Dm3n3(BTJqC>oFt6n{%wd>cgW6KueptkMXxO3~?&AYen-@t5f($n3;DZoGDB*+&RA}La7-p#9h8%Y2;fElG zDB_4DmT2OMD5j|5iU_pm;)^iGDC3MY)@b96IOeG1jy(400+o_zM{=bwNED(Iku7Ha6Bh$gD&q69SR=%bKED(R$@R%+>`m}aW!rkr-_ z>8GHED(a{Mlxpg!sHUpws;su^>Z`EED(kGY)@tjmxaO+st^xGw>#x8DE9|hu7HjOW z$R?}ovdlK??6c5DEA6xbRBP=zwb*8>?Y7)@>+QGThAZy4+ZYo f#w+i<^ww+dz4+#<@4o!@>+in+2Q2WwApih7u&Gpl literal 0 HcmV?d00001 diff --git a/templates/content/images/new.gif b/templates/content/images/new.gif new file mode 100644 index 0000000000000000000000000000000000000000..8a220b531225397b6a304918e4d96f6196ef40a8 GIT binary patch literal 635 zcmZ?wbhEHblwuHIc*el+@5|9!VKPrU6JO0wzv{&J_sfTWzkfci3%c&b^ZDfVC#}&> zyOaNZ`}}-T?z6u1zh6H-?MZpollt+%s=r@9J?->=+L`dQ-S^kCd)M4KzTZCopv3i7 zg#7c#dEf6|d^NB3$Neksx6gmOcH+A&vz~S(UH9g@mudETVb^R-1c%-`NuBSmGx$*^t}v|N3{XpZ=QLxvghB=@852m{z+->`t|DZla{DoFCJX;;C#~TaW_r#|NsA29T^4|DE?#tJ3t3Sg5rdM{YC?W zNN`JQTYE>a2m^CyU;l)Olls+yCQqLcG;PM53A6e*r27K<7?(+e+V$BkQ0bc=>K)=6 z>S?AMvXf0cM9U_`CsbZ({cMkrfKVO*0bx^n7M2ip!4S?%Tu1x7I766NnV3TOd0ax> zT^02BokLcHZqTpCs*6-yL$WVW?v z$*r&`a5&o0$QRlWP#C1jBFZZwJ5}J(3P%A63#oz=VNXx?YB3g7+`6(-c+I>yOH7zf SWil{ucTQ5<#GoL+U=08@?DshU literal 0 HcmV?d00001 diff --git a/templates/content/images/nophoto.png b/templates/content/images/nophoto.png new file mode 100644 index 0000000000000000000000000000000000000000..2daf0ffd4333c90aafd71479510144bcdcb16c79 GIT binary patch literal 696 zcmV;p0!RIcP)FMR=<>BGs+}zyR+1b_A)zQ(>&CSip$;tWo`Nqb^+obycyPRT{LUB1#`*2@<8tPF=iD3b$&izilao_AJ$Uu| z?T7EI;9G2Ni9S*S|C71nPeS~@YXtLGZ#Xme_@@>8G%0p2sX6212og-Y1w$?e z!WtwvbPJl0Aa)A^G6(_^hxshQF(4>p2|9paHcPMx2&P29rJ}2$!H> zp6f%wU$+bD9?CDf;J*mCI1D_PzD=;|;mna;B%E*;B%w%FK=_dsy!3SVseTRsf;O0PA5l@7S3xZ$It;!i#Ky zUwupv47dxD@P=FMLIa$I+=l%s0_x#ZiV;DS09Qn^j9pByOm?A=ICBWn)?Lr=Eg7SN z03L<9;aJ866<{Oli{Qt&ARUsBlRXUURcV2;m^$aahm^dfY4!Hqk3O{)q1D z1TF3(2qBkcAppN3{)S!D3NGw#J)8~}C44zdYXvndi+CRUT0sljYWS7$P%CI+|Ayli em8wo4&)6FRqy5_K=O4cS0000${>eZ`v@813YY~Q2faPbmo5s9gt%|d4ho>o57Mp#$&^RgUuZ5eg+dZJYZnp<>ZnO zn8@79#>ir^py2~!6AQbMoJWI#lOrpaM#=_*i%myaxx_eX7A$CT;APg}>iKX$rJbGI pjAPFPVa3)-5*81xR0c3Hu?omAG~5VaYGz`Q2)lD?YqkS}H2_zIYl#2= literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/aol.gif b/templates/content/images/openid/aol.gif new file mode 100644 index 0000000000000000000000000000000000000000..decc4f12362124c74e1e0b78ad4e5d132621ab23 GIT binary patch literal 2205 zcmV;O2x9j~Nk%w1VNn1b0QUd@0a~U0{{97Cr-7}~`~3at@%IK^rUhN5{r>*;`TQ|@ zxAXV<(c$m-`uz9${QUj?tjXaAU#9_Cqyt>0`uzP6Wve@Yx&8hA@b&ra^Y|liumW18 z16!pEV5rI5>-6~hXr0Mflf!YN%x>+Qkd8p6#`TXYZ_T}#Ooxt1~X|1!)YIhOpD5#NM*a<0W#j0a&CWZm>^{ zzyn;Rz}D!)*y=NTw$$VApTXTqiN5vt`#gcU#o6jVg1UmP(x}JZzt!kmmBs1t_qNaF zEOxXxf4M<~yV&LMwa?_c(&n4K+mpH2M25T;XRHups^01ID|NGbsn3_Y+VS@KWSYp* z;_ryE)EsK9fUMC>i@&bQ;tOD?Mu)vGc(qZE!4hSw$lL2DbFy2M#IVcb=I-{7w%6?P z_}%F8#@g%I=JCVW>A~0O1zM$Emc;;Aq|e~)=kN9^bhB5I!`tZcY@o~4Dwe zHhs4lW~<`t^hk)l_4)e+UZ(8x_}b_3h_Ter;O(~1GFN6(4WBES(L=`_W7sA;8&5u>hkx|;qKw=^yu*R z4rHnaUZ-7_#k9}l^!NJ*UZyBu2wvd-h_@b-M1#8yVW@Sa&Gh*C zz}DxCwAK`8te?W&k+|6D@b~`z|2%=Z24AP1z}wd3@G*F`*5vQL)#tg==7q1*{{H`_ z#^61Iy8r+GA^8LV00000EC2ui08s!P000R80RIUbNU)&6g9sBUT*$DY!-o+6Jy`H% zQ^boHGYUk|VhNoVyflg&nXrK{5cMRHfHRGxOOgqmlo8oERHm?$HPJbz#x1Z zpeoL(7W@hZxJ5+J9eE5BP*LH>O&${ zj5jX`S&`8IL!Cx*Fz7_k)nS8ApeE%1x(B4-jBvRPK#9X9Oc*K+HhF5Leg{%TGv{D8K;`L_xwpaHxaF z0b^+Mfl?X7amfU05OYC(Eiz<;2RbaUiytGQ0x5J^bziwedW^uQh}2wH>_T<*uvM9pjgf(kHL(TyFV3}K8NEHsip6(+=y z&mT8*M^FIdM4?9wB6I;j1ZWKZ^G^UCv;lw?B2a+P3?fKiKopBK>LNoIcyNRiBZxr* z3skJY1QoA5aVRDuT=9ep_zX!<2JM_N0V+YPFa`jiSn&@6Y-j*L7D^;UixL1NBE%5F zIz+$0D>L=cJ;YWUy}E(fIl&_o8nn81SpJFsxj2TRoOLkeItpmjn7WRMLXFdR_93ql-= z1sX|!ae@q8)L_8?$rNzmK!~tV!vO{eV8H9GyWWQlALOvc;zfv35CtA!F~I>nUE0WC6>_LJDwEf?Ad!6)ETg5hf{+1h8Trx)^{dte^urh{6Tzy$WAVijduPI(q;0nNaEbGS@D4BQ7Jci(whr)Rj z2q%0XEZ+#_Ct;QoHXnrD7mcRRG|JxzlR06vA#8Vq`IeoTkwqW`2*{qEdy|l0s_pcpGac^C{l1+0Klhw_ z&&T`@fCw(|_68p%Za@V6lF2M~`8?nwT2qqAT-dS*v`8aE#9vMiv)K%5uiT>`Cu)M8Smh5Zv%QKMzFEtB5sZL;q!re*wb?jBb3)yUxCP$DlBcT zL~7f2Xc#phq4g__Pfa4yRFB|+YGk+9pkrbfljbS-=}#g^UkO?BX(*bj5Y=)P6(&8R zO&8EjIa=wQK6IBb$~`nSj@zR~h?^=9$j(D&k8U|fv8T{Z@q#Iibl^PYK8+B{A42a? zn&ISkg6Y&SAlPq3IwwFtymf2cujzUWIlJo?t9T&*_MRU`vwqzc+-Li7Ie}Z~G zw--mnb2~J18Ml|a^Y~h=%%9s4;%rO&*gS5p3SVHc(|ZoU<~DkwMeO*)pdrB+_7<^=v$j_Y602 z`C%7w+v^bCUxP0O8_{GQ#m)y;vDe(lIiw=?CYvtf$V4M<5;OZIN3pf@5@38@&kv2aagW&h{ct;C2I}#);Rf;YA$}%~j}S*U5O+@yBM+JNXeK_&iEC2g zVcl>ivG!|}cK^irokINm*mxIr#*BEg_ZQ@KT);bqU!m-;Md5=V(Ka!J&7D8s_+S%f zwxX{Zm2{3EVkhehN@9O3O&g~f%MTkGaEszaP>gr!-qHPa(2tuSAtncKmY?DrX8gCX zw~BMRcDRG{ov~M8tU)~Wgk$}8ag_SW2Q;^IUBX+vH&E1l6;o7K6S3YvHIh(0Buyvb zPq7*ES+A(4dj?Z{#(CB^!dlL7#>=UHD5w@T&X-e-SU-uNe5_A=N#7-g&KplPQnh`H zPpS5~)B`tB4GvL#c2V7C$7}`uQ3W`%9{-rZU1zsNPt=!gocjbl$bG*$0T$*uM_#og zqCg|Oj)j|ToOkqD9r=oShaixip)P)7lk0PiqG(xWk-CUfrb~sQT(xGwfh@bnZt)8{ zOS#N-`c;zh{GQn97)jX{(Yl`-r8``9*&;k6ch&`=V2(|Hv9Q?Y!17y%ns+Deleo>c zXxB?L3fq2>yTn;9_Ox^x=H#ziXLYde*Z6o(?-#8oR9PIR^3 z@paatZ5n(3g?_+M-|dv&)6MY$9@Z~3eSe{3dw@NFY^CLT4(AuNdxNbG`TGi;zmHH_ zSiDu1l`l%qOH$kZ{2ccSrA6|bw77#IFRiuQojuoJeX89Ogm8^qV@=JLQbqwetb-Qw+Rg0ZKx z&@oVwYk{zTlDlPmt@`@>gqOWSUYhOj^{u(ngOha>|?_PGQs<+b3)a1g<-&k^{S8%1h$J}*`wztCBw7}OfP?3F+ zx}UAgE>4j0^Z00huWN#^P-~*o+2@|D%bKdmk)p&^Z>3FWpl*hPmxpaxO{r>*^{r&3g^y}{QvcA^&`utmTsG+aT<>~RIv(NVT z`dxOZnyJau+UV8W=vs5AIaif$g|m8&xL|mzI9Ha?*XCe(t6FoXft9>`kh$96>;C@# z=j!sh#oF=n_nfQBkD$XkS(mT8)w90W`T6@dRg{;f$iKG0|8^T^QRhnm2|&EM7A>5!qsI$4%mbf-I5mPlls z$SB4TVtT7ycB#|a=rU51xWw9-sL89i z(n)2W=j-y--09cc>DS%rdyu)Cs><{B`Ju4Qjh@49g|hDO^}EK~dXKnYc&bxvqfcs~ zPimqoOpejm=F-~dch+4I98VJ@Ad5N^-O1=?C$GIVlOYcaH&31>#Gvky1T6k8 ziI9>}$}k#&1aaV#k&~HkVjA>Ni}1-ALH^X7g3wDVMhx42p^-3zFGdr>{P}}0nBh() zQ+&Yj_sGEtC{9v4!QeCs7}ZYbLV2PZ!;@{5(yUo^Ep-=xT4<+!GBhd%)x@V1(7dY$ zli|e;x|GU}&KlATNQC)RW{;a~Qea~L*oW%bl|LfzM8I*SAGLi>0OXdiYZ)0oD=NA0;?e(m_y^K!7e(_>)B@sen*VB(K|;J z;Q||($kIn4;0ypl4t>-S3JpnY<3$=NxKl(oq>Qq{7C!8dNgbK+K*j(AkU>Kvb=0s! zARZvXTnJ~JVgmss;IYv`U6h~*6>vQuM?3-$A`TU3R6z&;&1B&ZBQIn@$Qv#gGKMd9 zNHPWw)!<@i^F zkW_BOA%Q=nA4{0yNA2%5#gj6X79!bLy&P%(i8R0KhQ33|Ze zj|Ok}Gsr!L_`}03U?j9t6w0L1E*sk@0ZAVnNaLnII^>|)C;T=d!X^G#Ax8_0R3V8E zl#H>)GOFyNnF1*IGr|%kTu}@aihL;wA`4(5gFkFQBJu~CRj>duDkBsH2JHIN$u@|5 zfkhT}5Tcn5^JsPl5SsM=&8eIT7^H}xB?~M@+bUFBMfc8pJwdwjAuwgf&OR%CSahM z26#XX{?G+}HV}YBB!VF4+r9Wh!XGIp1P)5^3=c%-A5dWe2?B5h9F#y4 zD_{U7W^fAzFdzebFo6j2V1^USVFmb*0z1fH251Z+3}D$dVm%x8e+Ke`=wY_TR8Nr~50fe7M}lw@Sx z)|sz}w0Z6jHaQ_AqDOitt<&SSea)PHxo<4{I(gaj_r1;9XTGktbGBaB{saBT0srj_ z{;~R31Lym74}$(bu>NSIe?gpv&bzYY@H?IKd literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/google.gif b/templates/content/images/openid/google.gif new file mode 100644 index 0000000000000000000000000000000000000000..1b6cd07bd8b9f27175e0a03be3b5849e0f5479c7 GIT binary patch literal 1596 zcmc(e`#aNn0DwQcU}GKMxn#>^B<6OWQKZt-cb3xBiE^HYQf=ZKSu)*APi@FdDnu7l zbE$~JN>R#|+lE{hiz(BRl~d+uOl9Xe=bt$55AUzjP!`6aB*XlLd;L`$MA0-=oh;_@%=DSKzTW5!kkg02oxN<-;QgzZXZ6@(M)5 zb-u1@<^vWqN`U%R3CtOJuojJt|Ec%yo>_yZ%MV%ajx`i>ysy4d0^mKeNIQ#t@2y*KMj}jE8i*m zl#eQZ7!1Pfn72wr)$QwY6gabm(O6$Lylw3Pd(s%KbU5crNh3{eeZxI4(dJKB1MUAN>n;QZCCkQs_tGtJY-^iC3ja3x9v_uTP?vFVW;}s># zx;OS=;!{FWer7!3y~sj6t|9~xWcTkC-QJ+z*` z{$kU`Oy-`7hp(oZDFCEubef~t-M)K#*_S^K7T>g7T^A0(oK7oIN_s0RehD8}s1*i- z0sK!m=+Xa`J^uB-PXLSoRAEU$)j~-M#?mcPT3yt{hn6u4gKCOf&J$L|DbuOJmz+s9 z2lJ2J?sjAok}A_-F35;rl&1P$i@IJDD5Bmxks6yO#s#L4K20(2&;kgjBXbWq$Y}&> zCc!g3Y<~;U$CQlDX2nU|3Dx218gg&b%2GehXilrp4#P1y;weqVUjQptQlB1c;VO7e z@*D^wqyiQ&MP@@Eiijj!C6&AUPa6q7&lm^MToqj2ny^P9>WX^Ttd-e`;&k}6HltTz=X|A>@zzv6@ z)2r$ZZK19Hq1s>pg(Wg*yF5bqcpgSu2*Z=3Y48rhsMseSGm6D#RWnKSz*rI2&e%)U zhJ)uMj-*j*Cq6a|SR^kuis=outMPl7vPf8@-OF`fK(;t_tEV6%zOcxe#-=20Mq7|L zi=0@wEQshFjSRBhL&)v46Z=EWNGr^Y7(cjs9|q}uirjP>UklMq_Cn}BpIZ=OxlIZN zrqgmZ9Daq-5mP(tkggoG%l1Mp5`!YX9P+{9a@vc{UA@ux9w!5<$J7Qsxz)kjp9U>O zdMGwqZ?ce!P4?kRO}wMe2<(jAw{y`J9zkIp$bd;9jpjy5e7h8h$r8hU6K*}g{&bHR zc4&^sGRyCwh1g@leXv&EK^8KfI43fLjtGZ4%_yBJq-Q6Ii74-1r$U?ItVA?Z^o7I@ z6Gx_VGVMkkya7VbaJCw^O!RGWg$&GOOC(&Bu>?}_7>IP{%ivHGBI}%WA6YI2+3M9H z%iJLj*4d~I--NgTJ(9t@qodNU?AaV`YHlKR%UVir5C+OujBse~Mp}pFlaUEl5;MVK zxnv+FK^_1to@fbJn^<{1g0s+?k E17=sO82|tP literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/livejournal.ico b/templates/content/images/openid/livejournal.ico new file mode 100644 index 0000000000000000000000000000000000000000..f3d21ec5e8f629b77c77615982cef929802fbde4 GIT binary patch literal 5222 zcmdT{3s6+o89vBPQIq*$1QbbvAP7Q0Tpmk!l@)pHf>>S> z1vbL6JXf&Eq~nt$W+Y}?NhYbg%X2}TX`y3UlPS(H)68fPIsMMP%d)ZvOQtiO{(Js= z?m7Sef9JdZJ&(JD*bxy~wQ3b%;$cU~E2vFPBC#hV6@5-lg8iE%gba#Un|TxR-jjq} zb3h#KnTHdU;W5$jSK%T=Pj@H?K_Lo-P~nPOqSb0qGXv!dp_JW0@nc==!i$LGD~{u9 zt~8U?B2Fd~qvpC~M^KA`gqqWJF*i|=E@%ujnuad%Of!pb5`P(QC7kR#SP2OTzQ<#W zlv%8aIKD~feX!6nCX`OuQ922|4;{CsbQG#}pj5FEW=E(mRL;B7LWEq0KANYW^3Y=B z_y|vmH;?ldeDaRw*8J(~hC!qOw?4H%Oa?Y1JnqbNZuG{_4-W8zh5g(k>k33gQDw%FD{ne3XB@ z!rC7_g|Gdhw<&R;HMK*r`+|J;KQGI_{V?zIn&?P3mLE&uo!9m>GUrS3pvy(U5A^kP z_$(c0u8#D!b_R{U=43cu$bYTlSjYsNjhYF)s`QQZ*3Ky}xtxmjy4jX?u^{kLVeo`r zO$S;h4E5!2dRRN72QywCwpkgq;m=hECwm&HvGsd>T}g=BENAdX&yl^G;15ZD@oDXe za5~)ny+KtH;%e1SDcr|-+q7@ZKZGT0tS19Bm$;2T93LRj8^{4y675bB zwk%H%+bJ)|KhfTK`uexou|aVjGo#E;Z%!+~BizWLXGzMgwI!$9Yp#x{^ivH+c7UV2 ztG$yM@p8QPk{Hi9qZjA|_iy0IrBz^V2FDGCt7!c=X2YVB&%j+s%GRZq6}$VIQ&2P#@0_gE zNAUFwKQH_3h_#F3ZUXmN_F>UpAnQ~Ky-mq~NZp*1ER$dEt(TrWr;qctLx_#Sm^+j7oj?A#I7DC$ zaD!T6s6Sj3{L6HyM1HcisHVO0oT2v1d(D5PMI|R99BoZLz$4vBrg+7t)3*@)h!oupL+wwg_YH%9vj*4aIjHXba4{8xkuc);A<= z{dZS2HK=KK!_1Gt{0T^;r%|h@D@A zwEWI*^|gxqvzS+eyR}HSKjd>V18&q9+tQP_E(>?D2|U7;$hbAy$_UJGbI$ekhw(yN zQ(t@t+Lp`(@GUljJClQ+q->vynK|C(jk-g{A&xDnJEp9_2N%N}naK~`m>>4s;pgp< z9QJ=jEdleAH`nptjkB2FdOtgL+Y^|;w&WZ>d7<84e)0JS>Jtat2~yqPk^=D3P?xq0 z@f7|6Jern%&D$w>p*GAGyl#LeY+CZk`Lq2)w{GZkg^@2rdyw`F-&0YZ?HMmk^)y+7 zCvI74%WRnjCpgYpE3*5H!##ZipIx~q^<9GpuZi7A2hXs1Zk~!pO}{2J>4l}(OBYOw zFj0B(Bt6hCeb>`pT-SE@^z{x5U2Ln3-?S|8w?F!!Jf|8`_0G@Mi{w$ z=X|SDy7MOoto~1%!)>|A@LPpZ)J;^~NDC9o;+|ify5q^Z+~}r~bWFtv8#b;5N6F%T zh9Q2R{a&r|U)2@;IgyF6UTmI3tzX1!nST@^QP$V_qZVtm#9wTzwZCbi{LlWU{0Anp BEK2|Y literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/myopenid.ico b/templates/content/images/openid/myopenid.ico new file mode 100644 index 0000000000000000000000000000000000000000..ceb06e6a3f0d88fb97cf10475a3062fb0edab33e GIT binary patch literal 2862 zcmeHJJxc>Y5S@6ZrZbS)owhjA&;jnXfl*X745tmMB3MrBW$)n`RP3b417qd6J6bL?UM{+)q(3xlv0Ik%T7j-l59$8$m>#ard~jq(8yIciUu?j(!>?&WKIe?G5c$>` zV+r!H1WS-ha)=*H^!uZEl>O1BP8%xc=fconk~~4DvKCYWn4`b_pUnoZ788}%mc>uh z9HV;s)r}P~NWtqf_p5&HGjTJoZI|S8n)uf0l05g}rdhqaIBpnv^myAWbI*7E=&N3x z95xI+0zR;x-|08c&;6Ul#XdjZARV+no-wSN`};1(+>)AIisPc*P@H*_1Kd%ys#()H z>NUmL)tL6ccj9UxPF`{LG^Rc9JypwV>?^N0yvK~LBc9f{#^OA9dQUv#8Tz7oxfa(K u#=%<%_2}PpAb{bmUKcqz}))c5uC(7v?)v4a2P)ZNa- z@$&T2)z|&~{r~^}A^8LV00000EC2ui01yBW000GQ;3tk`X`bk)Wk@<6#nZYULKH{p zEx|?+kif!I0vIL|#ZMubBmjWH2OtmxIFVa~6JQ7!1CK!f5W#StOTv&C3=E8h2vI1s n+#cd5;2fT3B_0kF0v!+!GARoV78n&7dMN`JIW(4+BOw4gP{MS* literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/openid.gif b/templates/content/images/openid/openid.gif new file mode 100644 index 0000000000000000000000000000000000000000..c718b0e6f37012db6c9c10d9d21c4dea0d0c01bc GIT binary patch literal 740 zcmZ?wbhEHb^k$G`xXQrrKS$vIw-5i{JotZf!T-qt{~ulWe{RG7ST3!;kh({9A)7tlU&$%5*g$f^Ar># z6BXsynVh) zJ?osJf(s)D10z?npvQi179P(djPk7Va&pI%NfVlv<{V@&c*Q1S?C^%corz71;ll+1P9`Sd{~>qE3OQZcJ(5}z4)|O#`p@vJ zr9;Fsp~HjOs*vv^`}=;ISs7Cf1bMkUpV%Pi{6*$qgF{F5!;-XxTBi=%eG5gPtV^!wdin~r1kkVO&vN=8Ce+Xv z$*|MCqlY(ACp$%vPrNeV;U*4lo)c<`?yngdvl5)QWEV6rHbi?!)@MOEE;CkPT#L!!@77y7u K{UjJ!7_0#i2pVPp literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/technorati.ico b/templates/content/images/openid/technorati.ico new file mode 100644 index 0000000000000000000000000000000000000000..fa1083c116527de7cdbf5897976aae8807fce878 GIT binary patch literal 2294 zcmeH}ze^lZ5XZl}d+sirdNzWcsg4x+2g0RLIAWPjuoD!tN}VeB7eq*vB1MXHX)Xi{ zAytZyMi86WScxK7SO|(gE|<@|cRuzut2sy&xMBC*%tj+A zE!c_l2H#`zaX;dYlru_mk^31KdcB@L9&W3#wIFp`YJOeP`OSr1{CK6O-`2Es@?E#T zy1MFK>-Ep~I=Vd7%e_s#J@}-Zvwh`X=4ClX_h=7BXW;)k1Ifb@+v7M5AZI7aYkiNm z$KjX;Qm=X2(~a>=Zn(6-IG8mv>sbkaBEroVrCFBdHr=3XM61uF&u!`5GI1u;Qf<+zMxU!sr1q{f@m!ic#&7x4 zjcDZqv{&NU85cGO2UiL7I^;$4kVpqJ@-E;pjlK(>l3v2Y;e5IS@q=)?(5+CX;*7LwCwnlxopJBahPURBFV+~&J eFF>coTp;}_7zqbJAQuX63TM^f{)_Klzq8-HK65Pq literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/verisign.ico b/templates/content/images/openid/verisign.ico new file mode 100644 index 0000000000000000000000000000000000000000..3953af931987b0e66c122b338dc352502564eafd GIT binary patch literal 4710 zcmeHJc~n&A75@Q)fTGMB7?4e2SOip*O~H*}8$=cdnTIhNBRWh_BW_>?5imwU5pfq4 zQ4m>QjBTZ+CRIeErNk zREwwe2CX!zp{LmSu(HSiXS0Z~ELfW_hmFlL(pSOSItLB|b75<{0z+Ju!Pzbsp04@u z^IM5gez^!5o)68~JR~M1V)|=3XwNQ8?a>Ya%3;dK~By}6c*$o zzc7z#uYNYpl*u)SjcUZ3@pYK4t;Vd>gP50g5b0^P$e34y71<3~mHQrY z^v!hsAEG!C)5bMuezljdfeI&}&sTTWohhE|ksJA(uJTd-&Q zMO2ly;NXEa9IkGqoEFsAT)_K>+aNTx;izy9$B(q(h|rGX$9{>EKmIk&oIQ<;7cbz` z_Vf7oOgqlCbl~T$U*gkC?YPwb87^PGj4!TTMMqaVuHU?hTbV;iCum zZRbOL{qcZs;#f*}wrlz{`0xBe*(I;Sz zyL{rRJv~s#3{DZZtH%`9aNO9+=O$@yE9B}Ppw5xAUn^OeZyC|qoIL(nKmn&nYY>eL zKrf+{E*!VX7~r9ZuM^b@Gr+V$Li3f}Ym!#NDK|=*KfCmKlHM?d^N_SO`K0ZlR@aaD z`$@HgRh&}Pnx=3wq}{WbyQe^@gROXtjgE@>Qu-jEKP!rl1Z1YS(s35^4X=At_Fe%L7)Z2wJ zI=BcM$Zt(2XjtYnSb8HX6)sr~HNO7Fi=k7(q*OSR;1tv-=GQtZrfwBAkrlHYyo$=k zI88HxY21*dylU_ihyn*o`a+siMM#3?z2La9_bI5tty|5m@_$Kv=M-r`DWnsuDXI|SI(OnaFs5Rj zX)H<$bK-%v#3C6u8ZzR^Dh7HHqo*OR6YUU|4ygcb%!+EsW(iDpCu}sLU`Ao=$b{)2 zqYUx~O12syWYaUKC^j&d+|rIZmK*4)3nD=!V^Y|D)97J|C?PnK9W{j|5sikK_<-~j zB9Ma7re4g!anVfBnN3BRq6!uR)Iqc*BNYKUJ~~i(NLEqh;Ss1(xyk6vj3QL-oI(}E ztJRXtBFNMQ1%(&^QRrgWCG@7zAyK_e%IJBC60Uv0=A*yw|Kz_F$NuLuvWqkMvw2)i zo$zJE=5ZUFK~Q{S_xsb>KZ5B3WHsh5CkCG#~pZKK$?_l$V}GW#u_kRkqUX z`UyTd@da8=wc+%sYiMmfjdN#zfeRNd;rz$faN&FhZrr$v&dv^;YrTU@mu}(8l`dTS zyp!h7d$`$gpJq>*C%Yct?%liirkiHU``!4q`ysx0_@`GhR*Wg zL+$LnVne>U0!F8BBDJgQ#SO&zJnpsR{N}Sv)RGX5ladO5OX7h<2Rs-#nHmcwuE~3rz z2>~NUOyad;2ZtE}qZs8M)E9^dp|1)1sQ>G$Z=aRsiI#u(rfHU-9}N`$^h{weM0ms) zh?4E1IgP=fR~iiIb_PS5COyWGoN9OA+h%v^2+Yx zGJaHiGz3ONU|59!7au1(GXnz`A0HnV&|@H)n}q>L0s$9;ARnmIVdDT(f_z;3d|=N* zDLy_ze4rMf1_3@kMlc035Cr)7nOM2`_ymE1g8cmaK$@2aOo2_OfcXEPfdPgOHZw3Z X0PU5rU|_JTL0}LcBo2~?sfE!1%eOAT literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/wordpress.ico b/templates/content/images/openid/wordpress.ico new file mode 100644 index 0000000000000000000000000000000000000000..31b7d2c2b77c039342854190a90a8d8436992b47 GIT binary patch literal 1150 zcmaKqJxT*n6op^J!coBi!TOa}allq&O3PWo1c^ULbO>qe21^@jt1Q7KOpyh+ge)Q1 zK|J4huRH_#zwbc3UEA;R9AO!H&d%roag-+O5 zO!N95T@?S*G}Sgw{mN!=VmhZ5Rzf4>LLtlrZUAWLgGPY+oVrG5xo^yW`xZU-Q@wk~@ zYxS@D)yH#t7kvCm!TtK*mFh-7(+TYB+*i5pa!nc|Jf3SU=XN{`fjrfux$lA7e}n0{ zlfCqFi>Z(M`wVVG>yKK1*9rZ1`iw}=W^iIUOLNU?<8e1$!1FrglCO_u)5YTUvK?eu yI~YIj#-~XLO;hd+o2#A2S^08*UB1qS`QCUE52vFxJ9}scm-~xFcCkL1j=lhFMR`a7 literal 0 HcmV?d00001 diff --git a/templates/content/images/openid/yahoo.gif b/templates/content/images/openid/yahoo.gif new file mode 100644 index 0000000000000000000000000000000000000000..42adbfa57f86b8b2df5aa1b7fe90510a7d1fdfdd GIT binary patch literal 1682 zcmV;D25tFANk%w1VN?JR0QUd@mU^Y$)Z(Fuu9$+OiD{W+I(v?Bo^?%%^Y8SKa-f%f zrJRAP?db1@W|sQ-`{?5AU^RD{eyHu}@MAc6Y)F84S&#er{JEpU(8JfsyU}JneZsZL zSS)eo;OgSr=DVrI-qz#a*5rX-lZrIb?D>k<=p7w-06N?k+!11Z%BingssxX*~`Jx%e>NQL4U@#&si&Ry{X0d`1)-{ zg6ib$l60Y~mAI;tw^}Z8;o0SWTajTmc&LxG+tT3I%-z$;*=0U@n}Df z_WAbn_i93aS}k+@`~3Iy_*yJ-{r&yp+~-;?aeZ2la7u;o?eq2W_P3J0;iQSMZ9#_O-sRiQ;BHNT`1AO8Qj6r> z=!+x&Fkmx*3aAJ-s-85w)XV*n|rAH`~33k^Rb@1vYox} z>+;~*+x%&C>Lw4uMvz|_vc)vS@X=;7?8j0^uVyl!LrHg=Iz3>%W_GG_VoC(sJZv``HXa* zrIxkU(csd>*m+iriD#Si^7g{9%5+bN>E!JE{QaMVtz9y8td_W5GInuEg!AzAjBA~X zY@AsvasU7SA^8LV00000EC2ui08{`F000R80L>t9BSw)JIS9nHVe#jm!-o(fN}Ncs zqD6~fM)VmW02LY`Stc0KkV8WON`_FRxX7}l%ZU3P9D0C2ViSKjMS*eC!QC5NWc*24 z$ACo`hlu15G!rIFqD1JxyfmSQfQkeLyuEbT;aCwDIQ`|T5~at(emLt$WH9QCKO?Fj z!YZJpKo=h-$7uT!(ZdXCA3nU9VnV{d0N()k(Y5u#B%yvAamGe5)veXFd%|B&z}{E8T{37 zh=$XgAq(IDLK-DxqXs0h{KJhuWN1QBJY)EyRU!TiVM;~maN!RZP&~xT1YQjCP&*>v zG{z^SKvar9Z%BlLKM^>@P9t6rA<+h8P*4UH{%m1KMF#8;qhgZOW6=OR_%lH)|M;QC z8ZSfy%{eR3AQ2<}h+xkGOhf{J3Vrwkz(32laK<*D3lQa{dk%K=0FpwEPj!g6c z8PB|?!Vn>}!~`5T1t5_zE=)iG0UUIK4SoL5A(0aP5b%#W8tjnDD-wa@&pQ_U;|wMK zP_awA|9s&=3UeHwj6-G|f<{Y6;N(Ia64h{zIqvjAj2hSc^NKS(WVVJ5CDigyFgPgS zk0p~ZbHfV$&=8I(61-3X6MR?_!$S{5GXw`Ytg(h5N(#^hz#+8og#&*SW6=pXX^~7s zFkB+QLkzgEL@`eIumT%^WMK#(^!)R|8hsQ|gbd{TLyHi#R)~`zC)5;?9Um+JL^Gdc zPzgiQO?9dAYKu|J14=HfQCJs5ExCItCfU89hC~?OkX(YSVLmi;d zz!!K_6YW}g;8BGXI9aiX4Mdod4IRil;>SO66v75h2HbJ^?H7Hao9>T4MsJEFFH&Hw-a literal 0 HcmV?d00001 diff --git a/templates/content/images/quest-bg.gif b/templates/content/images/quest-bg.gif new file mode 100644 index 0000000000000000000000000000000000000000..b754023882679555b5d31862f777e5f8b1877bcf GIT binary patch literal 294 zcmb79KQF^k6n#yEq+=^$FjT|RNGC(FR2r3bG9We##9%NQ3>uLbk@yBARv*JGzJSqW zdH4Uj&-?iX&Pnb)_vW6Q-0jh@w{~0$JK-|~h%skR?y5pa2$0O&vznEh|N+RO!h?sK@|HmRv z{h3y(TKyEJ2mNOMtn<{HAAUcKPwGpL&s#5zxz_#Zs$8wV{*2!`hmD)b^4H{i;qK%8 aqJF!3xj$$f?HydV+s)ZpZKm7Z3>&}3(53|d literal 0 HcmV?d00001 diff --git a/templates/content/images/vote-accepted-on.png b/templates/content/images/vote-accepted-on.png new file mode 100644 index 0000000000000000000000000000000000000000..2026f3bcc50e2738bdb6c21f32ffb2a82d088e11 GIT binary patch literal 1124 zcmV-q1e^PbP)(98f962%urEyvrobTSI2iWDonJaRXmcCZ2&_7W|s$8;q zX78?p{;d3j=Jt6u zRf1NRn45~bKOeQloe<4k4F*a0^w988Pn>Cnf)+6fhvK8hS8!=&g-Tr5fO=!taU4$~ zOcn}~1dq~+P+Mn_{a3^epPXDNqV_QrDaOtjsGVmiri&cVy-8sMq#8b+xcl4la{1KX zd)90%K-Mw{%5_9>cd}5B8H|=?=ws;;*H`e>Y)`)g+x+z483yu`hh? z)vUt~N$7kH$t{g&Q6XMdNY^x24}P89!Jn~piFLVw3}%z-ZxONXwNtVCms$I=Hpt<1 z;>5`C2ui916R`wY2}KWfU9>D9Dg;Y<_4cY;b#?q^Z}exPXQRCee0Tq%=HACy;vCVa z)oQ5K>nMeJcUM{?j$?G%ZU0GpPJBRg?!=6hb@~7WeF-jmZ%z`A5yxGcdRvZYk@$u9 qnpoR$QRL8vDfll$;(wNZ1Q-D2C|}A%ZKM4F00002jDb`!&=tG_0s>$|K>*|`prJ6sL73(3+qcd@u04=FA87F=kXo2eKmZ_sFf2$; zPWA&zCIel<#Ldmk0CYVA$YsbuiEN3WpdiEV-@jQtefpFN6jJ#4^XDXHW@fmf00M{! z+3>`~M022FsXRP9Oq`sYV1r>6fM^&7@nIMgTp$C5g@r+ma0TLs@87?}%>)P_xCIFb z3Bo|lB^(?aU=1+CkRuHnMz)lXj}Igk4Pmg5nWK zgM9!HKul2A3d156+4UepK$wMv1;uh~hS${8fRioA43Jqsb)q0~fB<5G=1>+`+J?D) z%9JT^&HerTa5l0y4Aj-tf${>ww{PE&GbGq-fB*uAJJ7~2AO*0T3i2vCz-BNA)YjHA z05ccZaO6}4^z~N|8z6v~pcXs;rCV4KfV@~$RYfo!V1|GF`V}PzL1I7)9)r{X1Q0AA zT!9r*AO#=|po~*pU5(RlP?-Pt@dK;cg2@4U%(nbkq83~4GrM%MlNq) zt_Q^*$WcIgHIVxmBnA*bjL2RCmZUYn2r>s2cJMME1VFhHRs;jfeUu1=7iz%L6XYu( z0EK-K5dWAvcP;}!05PGJEj>WnAAr0L$}BL~0gGY=V7brm?%g}EuaFBtSO$Xz??)hR z2I3zuIe-8{v0&c3c_1f%lFyZoA3rjH3O+6_F0kui`2-depv(ty1ju)w_yQXE94J)^ z#Ltn<1PCBTY{dew=mzBvKWLT74YCM?K^B1kDEN?45GX8n0Pzwa{)%kQf&~j000M{+ zU%3+(7sm^vtby1Jh*f}C5Gn;S=spmi2jcxe{2E;^$d?NjE@S`*AVy+~WpV*P05LJp c7ytwq03Nl7Z}J%VEdT%j07*qoM6N<$f`!tbz5oCK literal 0 HcmV?d00001 diff --git a/templates/content/images/vote-arrow-down-on.png b/templates/content/images/vote-arrow-down-on.png new file mode 100644 index 0000000000000000000000000000000000000000..048dbb44dcf2aa3669386737e4e34503659cfa70 GIT binary patch literal 905 zcmV;419tq0P)-y5{XDqL?wtw8c7i~ zN0Q6^?9Pnu+qv8Oi^-+Pz_+tI^UZtT@2q2t0Un+PKF$My_TW0l0Sr+3C>}Z+0c92j zQ&9RPZchib4JRZRISTw*?j`s&D(yi!4W!bYK|2l~#3&Yl)q=eKB*_hofA~`;xN^ut zQH^pphu&R)Hdf>y>Qg&-^&xZ21q}p#FHqmiA?Xcc?0sNEuv}tToE&x%yyA;O9n_c& ztgi)$?=eay3oI<;;0F@w=OKY#QG@aB?kYGJj-3UDF8m+(%RAuS)fP`Uv|~x*NmL4j z!2}6hSuY1_FXH@Eno4SYa2fqafZMOBtL=P?a&g3-4|twf6~U}kNf0P6+^mhu1MQ&W zQ|)VwXZi;$cy;)KStHP5wXSdC?sR7rWK_$yj`F9K-3tj+pzGE&CT^qA=z+D=Rv$@J zbvtq)#Yq4@9@OYr{|tt^${b4@Tb$voWYw^jsXJl~1l){yZ6Z~mTapgVXlRrfvI@o5R%kNt_@+gec_sFS>sC)ftV7EML$Cz1 z{=+$y6i-HJNDispz>1H>a&r@96Rxcq37>Q;^OE=LI@u)mx5b(Kd2vsyAI4-kummT= zg6^eUr{s{$(8UZkHS&32F)wd(AU!Q7(Rdg%m8GwFfuZFFfcG!1F;4WvoH_`{s8d}AU+B-V@FC#${&~nKmaj< zELga3A;YgoU<-h@djJ(F zfE2(qfH25qFg7-fEDzJi!NCC%R{)s_G8-U(SfCczf+Ro+KtNAVkHN^u2xqW7e*BnW z&z?PC3($iL1VFy|@#BXrkhujQfWSWZ{rk5XND$^Ce1?O7tgI|UVqzj#J%|QjXJ=fy@M{1qdLp4}jidfk}eE+_`fx3{6f>#t=jHft;KiJOrSj0yY~UfM6D&CG|15)01!ZM3y{4xbLLD8!_w2!F~pGdzzl|Am>fU= z!Gj1S080fK85v~z06FP`06+k-pxX?ygxFk+ZUJ&W0Reyjg8Kl3VH&1PnSx) z)Ie%~{`?8YATeO(f|~^k4S)aw`v6o-fJ#FqCMIw$Jbn5!!8)eg7&Qmi00000xCZ&X`T>s1rrok967{t#$kYGS7Vd|fw?Kji~ z;lV5VHnRYeM`{4BF0c$^a34H4Y$j8XY%{~vP4Ur0f;38Hd%(7f1L*It^x#ox6Y^@F zBDnIA8Ir>UzFOH#7SIa-feR)47XkUfbW{ysEx$_Za+(2mrv@e0$jB+NG1p<%zK%|C zDhyl)$6NrHqq@G{IrJPRPyB_8o%g~qnsOblfcn? zud345g@qRO!2EE%0Z?uLjv-MxAZ&$ojSA9F#F=yV|e*{B8pP@ zPpy`qnVS0ErfIu&a2$lel&veGH2NtLOlegf9(x9-G9&7J^nDl1oLg=Hr16Fr(Oro+ zQbLGVpQ1pj;IRb_B#w0GLze=Va%%)w6bBhuOzm9OdN+s8=o$#_ccLp*OIu$G;h>rLx z;mgpUhOxf69+e^?1Ywq=jh2GNqFYu`xESK?pEsfZhXwuLEj*_r99^_vuKcEHdY&#l z0Wa8SHm?w7E{Z_H{N^6JFTqUk){$jh)SV7SR)<^84Pbk)5p-5xEIhKMBS92|x<@3= zZ)!HBX})$JOk*s=%QA0e+p{3c*vl0e=9sUD))!9#$+3Q`u!ebIIb1s(-e@F=*U1b% z9-vyObQ;pB6zoI_#Ud071$xZ|IC*EJ6cLci_@% literal 0 HcmV?d00001 diff --git a/templates/content/images/vote-arrow-up.png b/templates/content/images/vote-arrow-up.png new file mode 100644 index 0000000000000000000000000000000000000000..6e9a51c7df2da30fd2e56359a93f4712077ee62d GIT binary patch literal 843 zcmV-R1GM~!P)Ze18CM!Al?Dub8&GoOqw)_0U&_j1|%mZ z3j?V-AXWlNa&mGq04*cZdym|9R2`JR?`}glckWT;thzab!KYu)chAIdN z2{HWr`xlHsmVhvfpOlou(AU?;;Ns$fQw<0U3k!q96hLNz%mxS`umwN?TMiBmxCT(X zz%UHx=;(lHFE1~+7_vH;K9D6Kvw*ZMNDV*$!7NY%c@N!iY!;y#j4TgxAjmABm>Nh7 zAb^;l8VIHqU?k#|$KnXEnE(OAf-H%y2t6WU0F?aD!Pc!?8Fud6iD4l?05Re7HZlf< zD?Z@u?ajc%#Do!S00G2;&E;unX$-o$x?py0ZZ5;*$&)b*1c~GFC9-({0mOnW3}J@j z3pQ+)=H=yK1UEncF%grAhy|b^LI(f=#DX0Dq!^ZylS5Px0R#}iRD>&trc9ZFHD1uo z0tg@`LIz>;HohQ2&zJxK#DXjV0<5g8D4IZp7&efdosDoMP(O0;g2Z7C0|+1%sG)yA zIS*DU-nemtK|@0WtN>JWV*^vCPQ{suK*a^n%pV{zfB=G7a0gg^Yk+0$lVq#(#)YQ~)1`j9~!(0t4szGKx0I>lA2$l~H18vm+Dfss78yF*}3LYLF zh6M{2fGtH24p`ms^XE@^(165%^kI-ZKmfrk*aj4E1sbd%ARqvC0Z0=pj6Z+=Ot?w| zS`LaokmG=6fn2{0Bn}Wjj4(qI5)wdFCb(AP=H>>wniTNm%NGV#&7yzfB V!E{DAJ$nEE002ovPDHLkV1i?NM1}wW literal 0 HcmV?d00001 diff --git a/templates/content/images/vote-favorite-off.png b/templates/content/images/vote-favorite-off.png new file mode 100644 index 0000000000000000000000000000000000000000..c1bef0745ea9acd1c405ac11e0d5555e8b12d7e3 GIT binary patch literal 930 zcmV;T16}-yP)Q zl~7{r#<-|Zx+tX^7v1(nLEMz+FA(Vu=&lr@i%_r>io5Ej3qgvws#2;kN-aKOFk(}p z#$w4mvd&mnLCfqGB`LW%tTQXT~$@pwWz4*(Z$7u`~3X;?Ck6f-uOMADC8`%H49ug9F8Y$ zw_8+IRf)E?w)=F~D6T0AgF(40thghvTO@bbp`oEcsi>%U%r*rBP;F6Pqt;fdRTLK& z>)!xC_VxAkhJ(#!6RoYS59m#UO~C*#0w5d#&H*ynH51s~l9G~3PA->Ap>jP%V%H7; z1$bs+Zcu>R9*^fGmE?+(-EJ4{?d|vr-^j>_mM?&1XlTeop!aHPYwM^Sb=B3?ZURv7 zN9E<^df;4gaBv`wkB@cT+uMthZf$OE#_0YhP1;0PS65oCtgL+9(a~Wg;GAGQS@Lv2 zkN}h`N1!eQU0hu3oSU1o(cP$Wa&nTu!eDWr*}!96BogVHo}P|wZ*Lo!n{BzQY=b5*FE0apfWSv{QAJ{HZLNQP zem;yw6#{1^;uGuZ>*=Yfskc2nJ!4n)Ad9ee={G;^@9!H;&ZqE2X`<2Sx8B~~uQ}N? z!#RA{$lSzt+5M1{!p76PmY3|<5RSAL&84NK2CzIy@&xf8fJSJCngW4N5yyPM&Jfr$uh-k@bUF=s0dG-KZhD`{`3D>TQ-Os; z#w#l;;f;+A00-HDHurrf6dIy?@=((>&<&onoKqxC$uC;-AG8mSL?SV4mQhBw zj*gB7W@ctSFDxuPr@!!0KgLYy`Z|>GFQSP5EPn+U0OR;~TRRy%rT_o{07*qoM6N<$ Ef@zSrumAu6 literal 0 HcmV?d00001 diff --git a/templates/content/images/vote-favorite-on.png b/templates/content/images/vote-favorite-on.png new file mode 100644 index 0000000000000000000000000000000000000000..1f9c14ab0813a1aec1f66b12c3eebe7232be3d8d GIT binary patch literal 1023 zcmVZd<5{Le6mt|)_<`GX($dlRu2ZJkuE zjf4$Qewch0=TDhyPWI*W3&@@n;Mrh z;ON^;+o1J6x+lSyC4yAc5*r#_RRe6^%F}2A*z}DOqn}Ca7lL#(u})I%7x#^k&|B0; z`f()bM-h)+;pZ4u$ALJ}P;Wvb3dM-H#z&Yj5-&MXQ!CKC#TXEuPEEBSJ=cPnS)ej| z2r5#+g@;jQ$TU_*6Ij=36b6CwjWTT^%5_m~{H>S28)%4W9OsGaYMC6L=yK8ysOFtZ z$a|Cc`qnVdXsKFY-eyhS#>TZMyvv&Gk-Z`#?>^Zjhh+Uaj*dLD2Glrl0XhE%M&6JK zdqZ9sxMdI+<1Dr0Qu()0dB28}pC5!-B*l|clf(rIB=P3C6)a-E6moW+nx^tEqNfk1 zhaN6W(@j2{T4UmW|9SG(9X_!#|lMVmx<&Y38Ta_F{^dJ0jyZ z^KE3Yfqc<E7fl_u~mXc`B_ShF#sjOqSPbOw6(spucpG!yqP5!xrMP zXa--)`><8~qDbZjaUY(43Ik6LqKX$#+j`!7QB^cQueWs7N thq=s2qJz(mO1EpR@jr*ce;$7X7ywPEpB^Im6SDvS002ovPDHLkV1mKF-a7yQ literal 0 HcmV?d00001 diff --git a/templates/content/js/com.cnprog.editor.js b/templates/content/js/com.cnprog.editor.js new file mode 100644 index 0000000000..289d986624 --- /dev/null +++ b/templates/content/js/com.cnprog.editor.js @@ -0,0 +1,68 @@ +锘/* + jQuery TextAreaResizer plugin + Created on 17th January 2008 by Ryan O'Dell + Version 1.0.4 +*/(function($){var textarea,staticOffset;var iLastMousePos=0;var iMin=32;var grip;$.fn.TextAreaResizer=function(){return this.each(function(){textarea=$(this).addClass('processed'),staticOffset=null;$(this).wrap('
').parent().append($('
').bind("mousedown",{el:this},startDrag));var grippie=$('div.grippie',$(this).parent())[0];grippie.style.marginRight=(grippie.offsetWidth-$(this)[0].offsetWidth)+'px'})};function startDrag(e){textarea=$(e.data.el);textarea.blur();iLastMousePos=mousePosition(e).y;staticOffset=textarea.height()-iLastMousePos;textarea.css('opacity',0.25);$(document).mousemove(performDrag).mouseup(endDrag);return false}function performDrag(e){var iThisMousePos=mousePosition(e).y;var iMousePos=staticOffset+iThisMousePos;if(iLastMousePos>=(iThisMousePos)){iMousePos-=5}iLastMousePos=iThisMousePos;iMousePos=Math.max(iMin,iMousePos);textarea.height(iMousePos+'px');if(iMousePos1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i1){v=words.slice(0,words.length-1).join(options.multipleSeparator)+options.multipleSeparator+v;}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&¤tValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value){return[""];}var words=value.split(options.multipleSeparator);var result=[];$.each(words,function(i,value){if($.trim(value))result[i]=$.trim(value);});return result;}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$.Autocompleter.Selection(input,previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else +$input.val("");}});}if(wasVisible)$.Autocompleter.Selection(input,input.value.length,input.value.length);};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"$1");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else +if(data[q]){return data[q];}else +if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("
").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("
    ").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.Autocompleter.Selection=function(field,start,end){if(field.createTextRange){var selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}else if(field.setSelectionRange){field.setSelectionRange(start,end);}else{if(field.selectionStart){field.selectionStart=start;field.selectionEnd=end;}}field.focus();};})(jQuery); +/* + * TypeWatch 2.0 - Original by Denny Ferrassoli / Refactored by Charles Christolini + * Copyright(c) 2007 Denny Ferrassoli - DennyDotNet.com + * Coprright(c) 2008 Charles Christolini - BinaryPie.com + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html +*/(function(jQuery){jQuery.fn.typeWatch=function(o){var options=jQuery.extend({wait:750,callback:function(){},highlight:true,captureLength:2},o);function checkElement(timer,override){var elTxt=jQuery(timer.el).val();if((elTxt.length>options.captureLength&&elTxt.toUpperCase()!=timer.text)||(override&&elTxt.length>options.captureLength)){timer.text=elTxt.toUpperCase();timer.cb(elTxt)}};function watchElement(elem){if(elem.type.toUpperCase()=="TEXT"||elem.nodeName.toUpperCase()=="TEXTAREA"){var timer={timer:null,text:jQuery(elem).val().toUpperCase(),cb:options.callback,el:elem,wait:options.wait};if(options.highlight){jQuery(elem).focus(function(){this.select()})}var startWatch=function(evt){var timerWait=timer.wait;var overrideBool=false;if(evt.keyCode==13&&this.type.toUpperCase()=="TEXT"){timerWait=1;overrideBool=true}var timerCallbackFx=function(){checkElement(timer,overrideBool)};clearTimeout(timer.timer);timer.timer=setTimeout(timerCallbackFx,timerWait)};jQuery(elem).keydown(startWatch)}};return this.each(function(index){watchElement(this)})}})(jQuery); +/* +Ajax upload +*/jQuery.extend({createUploadIframe:function(d,b){var a="jUploadFrame"+d;if(window.ActiveXObject){var c=document.createElement('