diff --git a/umonya/requirements.txt b/umonya/requirements.txt index 010d8be..b3561be 100644 --- a/umonya/requirements.txt +++ b/umonya/requirements.txt @@ -1,6 +1,4 @@ Django==1.5.1 -Pillow-PIL -gdata==2.0.18 -httplib2==0.8 -oauth2client==1.1 -python-gflags==2.0 +django-recaptcha==0.0.6 +Pillow==2.0.0 +South==0.8.1 diff --git a/umonya/umonya/apps/main/admin.py b/umonya/umonya/apps/main/admin.py index f032a91..0825629 100644 --- a/umonya/umonya/apps/main/admin.py +++ b/umonya/umonya/apps/main/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from models import Announcement, About, Page, Registration, Dynamic_Section +from models import Announcement, About, Page, Registration #~ Ensuring that admin is aware of this class @@ -14,4 +14,3 @@ class AnnouncementAdmin(admin.ModelAdmin): admin.site.register(About) admin.site.register(Page) admin.site.register(Registration) -admin.site.register(Dynamic_Section) diff --git a/umonya/umonya/apps/main/context_processors.py b/umonya/umonya/apps/main/context_processors.py index ea81d02..457b5ab 100644 --- a/umonya/umonya/apps/main/context_processors.py +++ b/umonya/umonya/apps/main/context_processors.py @@ -1,7 +1,8 @@ def dynamic_menu(request): # Adds Dynamic Menu Template Context - from models import Dynamic_Section + from models import Registration try: - return{"registration": Dynamic_Section.objects.get(section="registration")} - except: - return {"registration": False} + Registration.objects.get(pk=1) + return{"registration_open": True} + except Registration.DoesNotExist: + return {"registration_open": False} diff --git a/umonya/umonya/apps/main/fixtures/main.json b/umonya/umonya/apps/main/fixtures/main.json index dbd96e9..e5b0395 100644 --- a/umonya/umonya/apps/main/fixtures/main.json +++ b/umonya/umonya/apps/main/fixtures/main.json @@ -1 +1 @@ -[{"pk": 1, "model": "main.announcement", "fields": {"body": "Umonya will be having a course on 12-14 October 2012 wherewe will teach 100 High School children how to program in Python. It will be taking place during Cape Town's first ever Software week (http://www.softwareweek.co.za)\r\n\r\nIn association with Silicon Cape and Cape Peninsula University of Technology.\r\n\r\nApplications for the course can be submitted here.\r\nIf you would like to get involved, please contact us.", "title": "Upcoming Course in October!", "venue": "", "event_date": "2012-10-12T10:00:00Z", "pub_date": "2013-06-18", "slug": "Upcoming_Course_in_October!"}}, {"pk": 2, "model": "main.announcement", "fields": {"body": "Umonya is an official partner of PyconZa (http://za.pycon.org/) and has tickets available for Students to attend the conference.\r\n\r\nThis is an exciting opportunity as the conference will offer a wide variety of talks for everyone from novice to expert. \r\nUmonya students will be accompanied by a mentor who will at all times be available for questions and guidance, sothere will be no need for students to ever feel overwhelmed. \r\n\r\nIf you are interested, sign up for our course happening on 12 - 14 October and tell us you are also interested in the conference.\r\n\r\nPage 1 of 2", "title": "Umonya and PyconZA!", "venue": "PyconZA", "event_date": "2012-10-12T10:00:00Z", "pub_date": "2013-06-18", "slug": "Umonya_and_PyconZA!"}}, {"pk": 3, "model": "main.announcement", "fields": {"body": "We're all super excited about the course this weekend! Please take note that the venue is now set for UCT.\r\n\r\nPlease contact us if you have any inquiries about the weekend. Otherwise, see you there!", "title": "UCT confirmed as venue!", "venue": "UCT", "event_date": "2012-10-12T10:00:00Z", "pub_date": "2013-06-18", "slug": "UCT_confirmed_as_venue!"}}, {"pk": 4, "model": "main.announcement", "fields": {"body": "Umonya's second 3 day event is on the horizon. We will be hosting 50 High School children who are keen to learn to code. It will be taking place towards the end of March, although exact dates are yet to be finalized.\r\n\r\nOur first event was a great success and we are looking forward to an even better one this year. Read about our last event here.\r\n\r\nApplications for the course can be submitted here.\r\nIf you would like to get involved in any other way, please contact us.", "title": "Upcoming Course in March!", "venue": "", "event_date": "2013-04-05T10:00:00Z", "pub_date": "2013-06-18", "slug": "Upcoming_Course_in_March!"}}, {"pk": 5, "model": "main.announcement", "fields": {"body": "The new dates for the upcoming Umonya event are now set for 5-7 April. Spread the word and if you haven't yet, register now!\r\n\r\nIf you would like to stay up to date on everything Umonya, follow us on Twitter, Facebook and Google+", "title": "IMPORTANT: New Dates!", "venue": "", "event_date": "2013-04-05T10:00:00Z", "pub_date": "2013-06-18", "slug": "IMPORTANT:_New_Dates!"}}, {"pk": 6, "model": "main.announcement", "fields": {"body": "We're all set for next weekend's course. The venueis confirmed as Abbotts College in Century City.\r\n\r\nWe have sent out several emails to all applicants. If you haven't received anything, please let us know. info@umonya.com\r\nWe hope you're all as excited as we are. See you there!", "title": "April course all set!", "venue": "", "event_date": "2013-04-05T10:00:00Z", "pub_date": "2013-06-18", "slug": "April_course_all_set!"}}, {"pk": 1, "model": "main.about", "fields": {"bios": "Est tortor amet et! Parturient placerat porttitor urna est mid tortor turpis mattis montes ac ac augue auctor scelerisque tincidunt urna. Eu, augue, dolor, arcu tincidunt placerat mauris lacus hac magna velit proin et. Ac, enim? In turpis tortor lectus, enim lectus dictumst mus a ultricies mauris aenean. Aenean duis, sit turpis rhoncus etiam. Auctor auctor arcu! Amet porttitor porttitor, placerat velit sagittis lorem elementum, sed? Non sed a tincidunt et mus! Turpis lorem mauris nisi montes! Ac purus adipiscing cursus penatibus facilisis lorem nunc tristique enim nascetur ac habitasse, proin parturient? Vel odio rhoncus montes. Lorem a, elementum in.", "pub_date": "2013-06-11T18:39:54Z", "name": "Nina Schiff", "bios_photo": "img/pic/bios/1370975998_08_nina.jpg"}}, {"pk": 2, "model": "main.about", "fields": {"bios": "Tincidunt sagittis aliquet augue nunc porta augue! Augue nisi odio elit elit tristique, etiam, nunc natoque, ac urna elementum integer nec ac vut pulvinar integer. Mid ridiculus odio diam, nisi adipiscing! Tortor, et, ultrices augue augue tempor adipiscing elementum, dapibus porttitor porttitor ut? Enim velit nisi cras porta elit platea urna placerat? Et etiam dictumst egestas porttitor, dictumst, ac nec in in pid, nec turpis vel mid diam, placerat purus montes quis turpis, est a parturient, elit porta sagittis, sociis turpis pid scelerisque pulvinar urna cursus. Porttitor, nisi in sociis massa, nisi tristique placerat, odio porta mauris, elementum dignissim.", "pub_date": "2013-06-11T18:40:48Z", "name": "Lyndsay Lawrence", "bios_photo": "img/pic/bios/1370976050_61_BlankFemale.jpg"}}, {"pk": 3, "model": "main.about", "fields": {"bios": "Turpis? Sociis massa nascetur purus integer placerat eu cras, est dis auctor, et a eros, penatibus, massa? Pulvinar, nec, nisi parturient pid sit enim, amet lundium eu, pid dignissim enim et etiam nunc! Porttitor a turpis, urna turpis lacus, mid et dignissim integer, amet montes arcu vut! Quis tempor porta integer est urna risus scelerisque? Platea scelerisque nunc dapibus dictumst magna tincidunt a amet tincidunt ac non natoque pellentesque. Porttitor arcu lectus, tristique rhoncus lectus ac mus habitasse ac. Natoque arcu sociis montes ut? Tristique habitasse ac nunc augue, mid magnis cum tristique tortor. Turpis diam, pulvinar nec pid.", "pub_date": "2013-06-11T18:41:30Z", "name": "Rizmari Versfeld", "bios_photo": "img/pic/bios/1370976092_93_rizmari.png"}}, {"pk": 4, "model": "main.about", "fields": {"bios": "Diam odio turpis, tristique et rhoncus egestas rhoncus ut tincidunt placerat etiam, sed etiam. Nunc pulvinar ultricies urna, nunc proin pulvinar. Pulvinar et augue sociis nec est facilisis pid integer, nunc placerat, cursus massa, sociis sed lundium mauris pellentesque. Nisi vel turpis arcu, nascetur, sit porttitor platea pulvinar? Turpis placerat et parturient, purus facilisis pellentesque pid dictumst. Porttitor aliquam massa! Magnis lacus eros in, tincidunt mauris purus placerat! Ut sit penatibus in nec quis augue platea, pulvinar, lacus a augue elementum sociis in pid, adipiscing phasellus augue, adipiscing, turpis in dapibus augue in pulvinar aenean augue eros lectus diam diam.", "pub_date": "2013-06-11T18:42:12Z", "name": "Bradly Lawrence", "bios_photo": "img/pic/bios/1370976134_01_images.jpg"}}, {"pk": 1, "model": "main.page", "fields": {"content": "
\r\n\t\t\t\tThere are relatively few IT teachers in South Africa, where we face problems \r\n\t\t\t\tof low skills base in IT. With the many employment opportunities in the field, \r\n\t\t\t\tit is difficult to increase the pool. In addition, many existing IT teachers \r\n\t\t\t\tlack modern skills and training in Computer Science.\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\tUmonya is an initiative that primarily aims to expand the availability and \r\n\t\t\t\taccessibility of computer science in South Africa. Allowing children who would \r\n\t\t\t\tusually not have the opportunity, to discover and pursue an interest in computer \r\n\t\t\t\tscience and programming.\r\n\t\t\t
\r\n\t\t\r\n\t\t\r\n\t\t\t\tUmonya's main objectives are to provide theoretic lectures and practical classes to \r\n\t\t\t\tteach high-school children how to program in Python as well as give them an environment \r\n\t\t\t\twhere they can be tutored and guided in their computer skills.\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\tUmonya will provide an online community where School children can teach themselves to program \r\n\t\t\t\tthrough a structured, easy to learn online course. It will provide forums and discussion groups \r\n\t\t\t\twhere they can freely seek help and guidance as well as find helpful information.\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\tUmonya's secondary objectives are to encourage children to enter the computer science field and educate \r\n\t\t\t\tthem in the importance and relevance of computers in today's world.\r\n\t\t\t
\r\n\t\t\r\n\t\t\r\n\t\t\t\tPython is simple and emphasizes being explicit over implicit. It's open-source, has support locally and \r\n\t\t\t\ta strong, active and open online community. More than that, it's fun!\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\tFor a more thorough discussion, read our blog post.\r\n\t\t\t
", "page": "about"}}, {"pk": 1, "model": "main.registration", "fields": {"priority": 1, "field_type": "CharField", "required": true, "name": "name", "text": "Name"}}, {"pk": 2, "model": "main.registration", "fields": {"priority": 2, "field_type": "EmailField", "required": true, "name": "email", "text": "Email Address"}}, {"pk": 3, "model": "main.registration", "fields": {"priority": 3, "field_type": "CharField", "required": true, "name": "diet", "text": "Dietary Requirements"}}, {"pk": 4, "model": "main.registration", "fields": {"priority": 4, "field_type": "CharField", "required": false, "name": "phone", "text": "Phone Number"}}, {"pk": 5, "model": "main.registration", "fields": {"priority": 8, "field_type": "CharField", "required": false, "name": "t_shirt", "text": "What is your T-shirt size?"}}, {"pk": 6, "model": "main.registration", "fields": {"priority": 9, "field_type": "TextField", "required": false, "name": "heard", "text": "Where did you hear about us?"}}, {"pk": 7, "model": "main.registration", "fields": {"priority": 7, "field_type": "CharField", "required": false, "name": "age", "text": "What is your age?"}}, {"pk": 1, "model": "main.dynamic_section", "fields": {"section": "registration", "enabled": true}}, {"pk": 1, "model": "contenttypes.contenttype", "fields": {"model": "announcement", "name": "announcement", "app_label": "main"}}, {"pk": 2, "model": "contenttypes.contenttype", "fields": {"model": "about", "name": "about", "app_label": "main"}}, {"pk": 3, "model": "contenttypes.contenttype", "fields": {"model": "page", "name": "page", "app_label": "main"}}, {"pk": 4, "model": "contenttypes.contenttype", "fields": {"model": "registration", "name": "registration", "app_label": "main"}}, {"pk": 5, "model": "contenttypes.contenttype", "fields": {"model": "dynamic_section", "name": "dynamic_ section", "app_label": "main"}}, {"pk": 6, "model": "contenttypes.contenttype", "fields": {"model": "contact", "name": "contact", "app_label": "main"}}, {"pk": 7, "model": "contenttypes.contenttype", "fields": {"model": "permission", "name": "permission", "app_label": "auth"}}, {"pk": 8, "model": "contenttypes.contenttype", "fields": {"model": "group", "name": "group", "app_label": "auth"}}, {"pk": 9, "model": "contenttypes.contenttype", "fields": {"model": "user", "name": "user", "app_label": "auth"}}, {"pk": 10, "model": "contenttypes.contenttype", "fields": {"model": "contenttype", "name": "content type", "app_label": "contenttypes"}}, {"pk": 11, "model": "contenttypes.contenttype", "fields": {"model": "session", "name": "session", "app_label": "sessions"}}, {"pk": 12, "model": "contenttypes.contenttype", "fields": {"model": "site", "name": "site", "app_label": "sites"}}, {"pk": 13, "model": "contenttypes.contenttype", "fields": {"model": "logentry", "name": "log entry", "app_label": "admin"}}, {"pk": "vls1kjkg462qevyxi6zpb9xvnnjool0t", "model": "sessions.session", "fields": {"expire_date": "2013-07-04T10:12:30.230Z", "session_data": "NzEwYjBjOTU3NGYzNTY2YWY3ODkzNmU1ZDA2NTg1ZTU4MTE5NTliOTqAAn1xAShVEl9hdXRoX3VzZXJfYmFja2VuZHECVSlkamFuZ28uY29udHJpYi5hdXRoLmJhY2tlbmRzLk1vZGVsQmFja2VuZHEDVQ1fYXV0aF91c2VyX2lkcQRLAXUu"}}, {"pk": 1, "model": "sites.site", "fields": {"domain": "example.com", "name": "example.com"}}, {"pk": 1, "model": "auth.permission", "fields": {"codename": "add_announcement", "name": "Can add announcement", "content_type": 1}}, {"pk": 2, "model": "auth.permission", "fields": {"codename": "change_announcement", "name": "Can change announcement", "content_type": 1}}, {"pk": 3, "model": "auth.permission", "fields": {"codename": "delete_announcement", "name": "Can delete announcement", "content_type": 1}}, {"pk": 4, "model": "auth.permission", "fields": {"codename": "add_about", "name": "Can add about", "content_type": 2}}, {"pk": 5, "model": "auth.permission", "fields": {"codename": "change_about", "name": "Can change about", "content_type": 2}}, {"pk": 6, "model": "auth.permission", "fields": {"codename": "delete_about", "name": "Can delete about", "content_type": 2}}, {"pk": 7, "model": "auth.permission", "fields": {"codename": "add_page", "name": "Can add page", "content_type": 3}}, {"pk": 8, "model": "auth.permission", "fields": {"codename": "change_page", "name": "Can change page", "content_type": 3}}, {"pk": 9, "model": "auth.permission", "fields": {"codename": "delete_page", "name": "Can delete page", "content_type": 3}}, {"pk": 10, "model": "auth.permission", "fields": {"codename": "add_registration", "name": "Can add registration", "content_type": 4}}, {"pk": 11, "model": "auth.permission", "fields": {"codename": "change_registration", "name": "Can change registration", "content_type": 4}}, {"pk": 12, "model": "auth.permission", "fields": {"codename": "delete_registration", "name": "Can delete registration", "content_type": 4}}, {"pk": 13, "model": "auth.permission", "fields": {"codename": "add_dynamic_section", "name": "Can add dynamic_ section", "content_type": 5}}, {"pk": 14, "model": "auth.permission", "fields": {"codename": "change_dynamic_section", "name": "Can change dynamic_ section", "content_type": 5}}, {"pk": 15, "model": "auth.permission", "fields": {"codename": "delete_dynamic_section", "name": "Can delete dynamic_ section", "content_type": 5}}, {"pk": 16, "model": "auth.permission", "fields": {"codename": "add_contact", "name": "Can add contact", "content_type": 6}}, {"pk": 17, "model": "auth.permission", "fields": {"codename": "change_contact", "name": "Can change contact", "content_type": 6}}, {"pk": 18, "model": "auth.permission", "fields": {"codename": "delete_contact", "name": "Can delete contact", "content_type": 6}}, {"pk": 19, "model": "auth.permission", "fields": {"codename": "add_permission", "name": "Can add permission", "content_type": 7}}, {"pk": 20, "model": "auth.permission", "fields": {"codename": "change_permission", "name": "Can change permission", "content_type": 7}}, {"pk": 21, "model": "auth.permission", "fields": {"codename": "delete_permission", "name": "Can delete permission", "content_type": 7}}, {"pk": 22, "model": "auth.permission", "fields": {"codename": "add_group", "name": "Can add group", "content_type": 8}}, {"pk": 23, "model": "auth.permission", "fields": {"codename": "change_group", "name": "Can change group", "content_type": 8}}, {"pk": 24, "model": "auth.permission", "fields": {"codename": "delete_group", "name": "Can delete group", "content_type": 8}}, {"pk": 25, "model": "auth.permission", "fields": {"codename": "add_user", "name": "Can add user", "content_type": 9}}, {"pk": 26, "model": "auth.permission", "fields": {"codename": "change_user", "name": "Can change user", "content_type": 9}}, {"pk": 27, "model": "auth.permission", "fields": {"codename": "delete_user", "name": "Can delete user", "content_type": 9}}, {"pk": 28, "model": "auth.permission", "fields": {"codename": "add_contenttype", "name": "Can add content type", "content_type": 10}}, {"pk": 29, "model": "auth.permission", "fields": {"codename": "change_contenttype", "name": "Can change content type", "content_type": 10}}, {"pk": 30, "model": "auth.permission", "fields": {"codename": "delete_contenttype", "name": "Can delete content type", "content_type": 10}}, {"pk": 31, "model": "auth.permission", "fields": {"codename": "add_session", "name": "Can add session", "content_type": 11}}, {"pk": 32, "model": "auth.permission", "fields": {"codename": "change_session", "name": "Can change session", "content_type": 11}}, {"pk": 33, "model": "auth.permission", "fields": {"codename": "delete_session", "name": "Can delete session", "content_type": 11}}, {"pk": 34, "model": "auth.permission", "fields": {"codename": "add_site", "name": "Can add site", "content_type": 12}}, {"pk": 35, "model": "auth.permission", "fields": {"codename": "change_site", "name": "Can change site", "content_type": 12}}, {"pk": 36, "model": "auth.permission", "fields": {"codename": "delete_site", "name": "Can delete site", "content_type": 12}}, {"pk": 37, "model": "auth.permission", "fields": {"codename": "add_logentry", "name": "Can add log entry", "content_type": 13}}, {"pk": 38, "model": "auth.permission", "fields": {"codename": "change_logentry", "name": "Can change log entry", "content_type": 13}}, {"pk": 39, "model": "auth.permission", "fields": {"codename": "delete_logentry", "name": "Can delete log entry", "content_type": 13}}, {"pk": 1, "model": "auth.user", "fields": {"username": "umonya", "first_name": "", "last_name": "", "is_active": true, "is_superuser": true, "is_staff": true, "last_login": "2013-06-20T10:12:30.128Z", "groups": [], "user_permissions": [], "password": "pbkdf2_sha256$10000$brk9UZ2n0Sy1$dVxb6TN5sELt6sRVFKrNWxHn+J0f6KbEx5arkjvO1qQ=", "email": "", "date_joined": "2013-06-20T10:11:49.173Z"}}, {"pk": 1, "model": "admin.logentry", "fields": {"action_flag": 2, "action_time": "2013-06-21T08:43:54.204Z", "object_repr": "registration", "object_id": "1", "change_message": "Changed enabled.", "user": 1, "content_type": 5}}, {"pk": 2, "model": "admin.logentry", "fields": {"action_flag": 2, "action_time": "2013-06-21T12:20:45.371Z", "object_repr": "registration", "object_id": "1", "change_message": "Changed enabled.", "user": 1, "content_type": 5}}] +[{"pk": 1, "model": "main.announcement", "fields": {"body": "Umonya will be having a course on 12-14 October 2012 wherewe will teach 100 High School children how to program in Python. It will be taking place during Cape Town's first ever Software week (http://www.softwareweek.co.za)\r\n\r\nIn association with Silicon Cape and Cape Peninsula University of Technology.\r\n\r\nApplications for the course can be submitted here.\r\nIf you would like to get involved, please contact us.", "title": "Upcoming Course in October!", "venue": "", "event_date": "2012-10-12T10:00:00Z", "pub_date": "2013-06-18", "slug": "Upcoming_Course_in_October!"}}, {"pk": 2, "model": "main.announcement", "fields": {"body": "Umonya is an official partner of PyconZa (http://za.pycon.org/) and has tickets available for Students to attend the conference.\r\n\r\nThis is an exciting opportunity as the conference will offer a wide variety of talks for everyone from novice to expert. \r\nUmonya students will be accompanied by a mentor who will at all times be available for questions and guidance, sothere will be no need for students to ever feel overwhelmed. \r\n\r\nIf you are interested, sign up for our course happening on 12 - 14 October and tell us you are also interested in the conference.\r\n\r\nPage 1 of 2", "title": "Umonya and PyconZA!", "venue": "PyconZA", "event_date": "2012-10-12T10:00:00Z", "pub_date": "2013-06-18", "slug": "Umonya_and_PyconZA!"}}, {"pk": 3, "model": "main.announcement", "fields": {"body": "We're all super excited about the course this weekend! Please take note that the venue is now set for UCT.\r\n\r\nPlease contact us if you have any inquiries about the weekend. Otherwise, see you there!", "title": "UCT confirmed as venue!", "venue": "UCT", "event_date": "2012-10-12T10:00:00Z", "pub_date": "2013-06-18", "slug": "UCT_confirmed_as_venue!"}}, {"pk": 4, "model": "main.announcement", "fields": {"body": "Umonya's second 3 day event is on the horizon. We will be hosting 50 High School children who are keen to learn to code. It will be taking place towards the end of March, although exact dates are yet to be finalized.\r\n\r\nOur first event was a great success and we are looking forward to an even better one this year. Read about our last event here.\r\n\r\nApplications for the course can be submitted here.\r\nIf you would like to get involved in any other way, please contact us.", "title": "Upcoming Course in March!", "venue": "", "event_date": "2013-04-05T10:00:00Z", "pub_date": "2013-06-18", "slug": "Upcoming_Course_in_March!"}}, {"pk": 5, "model": "main.announcement", "fields": {"body": "The new dates for the upcoming Umonya event are now set for 5-7 April. Spread the word and if you haven't yet, register now!\r\n\r\nIf you would like to stay up to date on everything Umonya, follow us on Twitter, Facebook and Google+", "title": "IMPORTANT: New Dates!", "venue": "", "event_date": "2013-04-05T10:00:00Z", "pub_date": "2013-06-18", "slug": "IMPORTANT:_New_Dates!"}}, {"pk": 6, "model": "main.announcement", "fields": {"body": "We're all set for next weekend's course. The venueis confirmed as Abbotts College in Century City.\r\n\r\nWe have sent out several emails to all applicants. If you haven't received anything, please let us know. info@umonya.com\r\nWe hope you're all as excited as we are. See you there!", "title": "April course all set!", "venue": "", "event_date": "2013-04-05T10:00:00Z", "pub_date": "2013-06-18", "slug": "April_course_all_set!"}}, {"pk": 1, "model": "main.about", "fields": {"bios": "Est tortor amet et! Parturient placerat porttitor urna est mid tortor turpis mattis montes ac ac augue auctor scelerisque tincidunt urna. Eu, augue, dolor, arcu tincidunt placerat mauris lacus hac magna velit proin et. Ac, enim? In turpis tortor lectus, enim lectus dictumst mus a ultricies mauris aenean. Aenean duis, sit turpis rhoncus etiam. Auctor auctor arcu! Amet porttitor porttitor, placerat velit sagittis lorem elementum, sed? Non sed a tincidunt et mus! Turpis lorem mauris nisi montes! Ac purus adipiscing cursus penatibus facilisis lorem nunc tristique enim nascetur ac habitasse, proin parturient? Vel odio rhoncus montes. Lorem a, elementum in.", "name": "Nina Schiff", "bios_photo": "img/pic/bios/1370975998_08_nina.jpg"}}, {"pk": 2, "model": "main.about", "fields": {"bios": "Tincidunt sagittis aliquet augue nunc porta augue! Augue nisi odio elit elit tristique, etiam, nunc natoque, ac urna elementum integer nec ac vut pulvinar integer. Mid ridiculus odio diam, nisi adipiscing! Tortor, et, ultrices augue augue tempor adipiscing elementum, dapibus porttitor porttitor ut? Enim velit nisi cras porta elit platea urna placerat? Et etiam dictumst egestas porttitor, dictumst, ac nec in in pid, nec turpis vel mid diam, placerat purus montes quis turpis, est a parturient, elit porta sagittis, sociis turpis pid scelerisque pulvinar urna cursus. Porttitor, nisi in sociis massa, nisi tristique placerat, odio porta mauris, elementum dignissim.", "name": "Lyndsay Lawrence", "bios_photo": "img/pic/bios/1370976050_61_BlankFemale.jpg"}}, {"pk": 3, "model": "main.about", "fields": {"bios": "Turpis? Sociis massa nascetur purus integer placerat eu cras, est dis auctor, et a eros, penatibus, massa? Pulvinar, nec, nisi parturient pid sit enim, amet lundium eu, pid dignissim enim et etiam nunc! Porttitor a turpis, urna turpis lacus, mid et dignissim integer, amet montes arcu vut! Quis tempor porta integer est urna risus scelerisque? Platea scelerisque nunc dapibus dictumst magna tincidunt a amet tincidunt ac non natoque pellentesque. Porttitor arcu lectus, tristique rhoncus lectus ac mus habitasse ac. Natoque arcu sociis montes ut? Tristique habitasse ac nunc augue, mid magnis cum tristique tortor. Turpis diam, pulvinar nec pid.", "name": "Rizmari Versfeld", "bios_photo": "img/pic/bios/1370976092_93_rizmari.png"}}, {"pk": 4, "model": "main.about", "fields": {"bios": "Diam odio turpis, tristique et rhoncus egestas rhoncus ut tincidunt placerat etiam, sed etiam. Nunc pulvinar ultricies urna, nunc proin pulvinar. Pulvinar et augue sociis nec est facilisis pid integer, nunc placerat, cursus massa, sociis sed lundium mauris pellentesque. Nisi vel turpis arcu, nascetur, sit porttitor platea pulvinar? Turpis placerat et parturient, purus facilisis pellentesque pid dictumst. Porttitor aliquam massa! Magnis lacus eros in, tincidunt mauris purus placerat! Ut sit penatibus in nec quis augue platea, pulvinar, lacus a augue elementum sociis in pid, adipiscing phasellus augue, adipiscing, turpis in dapibus augue in pulvinar aenean augue eros lectus diam diam.", "name": "Bradly Lawrence", "bios_photo": "img/pic/bios/1370976134_01_images.jpg"}}, {"pk": 1, "model": "main.page", "fields": {"content": "\r\n\t\t\t\tThere are relatively few IT teachers in South Africa, where we face problems \r\n\t\t\t\tof low skills base in IT. With the many employment opportunities in the field, \r\n\t\t\t\tit is difficult to increase the pool. In addition, many existing IT teachers \r\n\t\t\t\tlack modern skills and training in Computer Science.\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\tUmonya is an initiative that primarily aims to expand the availability and \r\n\t\t\t\taccessibility of computer science in South Africa. Allowing children who would \r\n\t\t\t\tusually not have the opportunity, to discover and pursue an interest in computer \r\n\t\t\t\tscience and programming.\r\n\t\t\t
\r\n\t\t\r\n\t\t\r\n\t\t\t\tUmonya's main objectives are to provide theoretic lectures and practical classes to \r\n\t\t\t\tteach high-school children how to program in Python as well as give them an environment \r\n\t\t\t\twhere they can be tutored and guided in their computer skills.\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\tUmonya will provide an online community where School children can teach themselves to program \r\n\t\t\t\tthrough a structured, easy to learn online course. It will provide forums and discussion groups \r\n\t\t\t\twhere they can freely seek help and guidance as well as find helpful information.\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\tUmonya's secondary objectives are to encourage children to enter the computer science field and educate \r\n\t\t\t\tthem in the importance and relevance of computers in today's world.\r\n\t\t\t
\r\n\t\t\r\n\t\t\r\n\t\t\t\tPython is simple and emphasizes being explicit over implicit. It's open-source, has support locally and \r\n\t\t\t\ta strong, active and open online community. More than that, it's fun!\r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\tFor a more thorough discussion, read our blog post.\r\n\t\t\t
", "page": "about"}}, {"pk": 1, "model": "main.dynamic_section", "fields": {"section": "registration", "enabled": true}}] \ No newline at end of file diff --git a/umonya/umonya/apps/main/forms.py b/umonya/umonya/apps/main/forms.py index 43783e1..e58f20c 100644 --- a/umonya/umonya/apps/main/forms.py +++ b/umonya/umonya/apps/main/forms.py @@ -1,35 +1,5 @@ from django import forms -from models import Registration - - -class RegistrationForm(forms.Form): - questions = Registration.objects.all().order_by("priority") - for item in questions: - required = "" - if item.required: - required = "required" - - if item.field_type == "CharField": - vars()[item.name] = forms.CharField(label=item.text, - required=item.required, - widget=forms.TextInput(attrs={"class": required, - required: ""})) - elif item.field_type == "EmailField": - vars()[item.name] = forms.EmailField(label=item.text, - required=item.required, - widget=forms.TextInput(attrs={"class": required, - required: "", - "type": "email"})) - elif item.field_type == "IntegerField": - vars()[item.name] = forms.IntegerField(label=item.text, - required=item.required, - widget=forms.TextInput(attrs={"class": required + - "digits", required: ""})) - elif item.field_type == "TextField": - vars()[item.name] = forms.CharField(label=item.text, - required=item.required, - widget=forms.Textarea(attrs={"class": required, - required: ""})) +from captcha.fields import ReCaptchaField class ContactForm(forms.Form): @@ -43,3 +13,5 @@ class ContactForm(forms.Form): text = forms.CharField(label="Talk to us", widget=forms.Textarea(attrs={})) + + captcha = ReCaptchaField() diff --git a/umonya/umonya/apps/main/migrations/0001_initial.py b/umonya/umonya/apps/main/migrations/0001_initial.py new file mode 100644 index 0000000..74b1530 --- /dev/null +++ b/umonya/umonya/apps/main/migrations/0001_initial.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'Announcement' + db.create_table(u'main_announcement', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('title', self.gf('django.db.models.fields.CharField')(unique=True, max_length=200)), + ('body', self.gf('django.db.models.fields.TextField')()), + ('pub_date', self.gf('django.db.models.fields.DateField')(default=datetime.datetime(2013, 7, 22, 0, 0))), + ('event_date', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2013, 7, 22, 0, 0))), + ('venue', self.gf('django.db.models.fields.CharField')(max_length=300, blank=True)), + ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50)), + )) + db.send_create_signal(u'main', ['Announcement']) + + # Adding model 'About' + db.create_table(u'main_about', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=200)), + ('bios', self.gf('django.db.models.fields.TextField')()), + ('bios_photo', self.gf('django.db.models.fields.files.ImageField')(max_length=100, null=True, blank=True)), + ('pub_date', self.gf('django.db.models.fields.DateTimeField')()), + )) + db.send_create_signal(u'main', ['About']) + + # Adding model 'Page' + db.create_table(u'main_page', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('page', self.gf('django.db.models.fields.CharField')(max_length=200)), + ('content', self.gf('django.db.models.fields.TextField')()), + )) + db.send_create_signal(u'main', ['Page']) + + # Adding model 'Dynamic_Section' + db.create_table(u'main_dynamic_section', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('section', self.gf('django.db.models.fields.CharField')(max_length=200)), + ('enabled', self.gf('django.db.models.fields.BooleanField')(default=False)), + )) + db.send_create_signal(u'main', ['Dynamic_Section']) + + # Adding model 'Contact' + db.create_table(u'main_contact', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal(u'main', ['Contact']) + + + def backwards(self, orm): + # Deleting model 'Announcement' + db.delete_table(u'main_announcement') + + # Deleting model 'About' + db.delete_table(u'main_about') + + # Deleting model 'Page' + db.delete_table(u'main_page') + + # Deleting model 'Dynamic_Section' + db.delete_table(u'main_dynamic_section') + + # Deleting model 'Contact' + db.delete_table(u'main_contact') + + + models = { + u'main.about': { + 'Meta': {'object_name': 'About'}, + 'bios': ('django.db.models.fields.TextField', [], {}), + 'bios_photo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}), + 'pub_date': ('django.db.models.fields.DateTimeField', [], {}) + }, + u'main.announcement': { + 'Meta': {'ordering': "['-pub_date']", 'object_name': 'Announcement'}, + 'body': ('django.db.models.fields.TextField', [], {}), + 'event_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 7, 22, 0, 0)'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'pub_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2013, 7, 22, 0, 0)'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}), + 'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}), + 'venue': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}) + }, + u'main.contact': { + 'Meta': {'object_name': 'Contact'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'main.dynamic_section': { + 'Meta': {'object_name': 'Dynamic_Section'}, + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'section': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.page': { + 'Meta': {'object_name': 'Page'}, + 'content': ('django.db.models.fields.TextField', [], {}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'page': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + } + } + + complete_apps = ['main'] \ No newline at end of file diff --git a/umonya/umonya/apps/main/migrations/0002_auto__del_field_about_pub_date.py b/umonya/umonya/apps/main/migrations/0002_auto__del_field_about_pub_date.py new file mode 100644 index 0000000..09f066a --- /dev/null +++ b/umonya/umonya/apps/main/migrations/0002_auto__del_field_about_pub_date.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Deleting field 'About.pub_date' + db.delete_column(u'main_about', 'pub_date') + + + def backwards(self, orm): + # Adding field 'About.pub_date' + db.add_column(u'main_about', 'pub_date', + self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2013, 7, 22, 0, 0)), + keep_default=False) + + + models = { + u'main.about': { + 'Meta': {'object_name': 'About'}, + 'bios': ('django.db.models.fields.TextField', [], {}), + 'bios_photo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.announcement': { + 'Meta': {'ordering': "['-pub_date']", 'object_name': 'Announcement'}, + 'body': ('django.db.models.fields.TextField', [], {}), + 'event_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 7, 22, 0, 0)'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'pub_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2013, 7, 22, 0, 0)'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}), + 'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}), + 'venue': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}) + }, + u'main.contact': { + 'Meta': {'object_name': 'Contact'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + u'main.dynamic_section': { + 'Meta': {'object_name': 'Dynamic_Section'}, + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'section': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.page': { + 'Meta': {'object_name': 'Page'}, + 'content': ('django.db.models.fields.TextField', [], {}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'page': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + } + } + + complete_apps = ['main'] \ No newline at end of file diff --git a/umonya/umonya/apps/main/migrations/0003_auto__del_contact__add_registration.py b/umonya/umonya/apps/main/migrations/0003_auto__del_contact__add_registration.py new file mode 100644 index 0000000..6f7f5dd --- /dev/null +++ b/umonya/umonya/apps/main/migrations/0003_auto__del_contact__add_registration.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Deleting model 'Contact' + db.delete_table(u'main_contact') + + # Adding model 'Registration' + db.create_table(u'main_registration', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('form_code', self.gf('django.db.models.fields.CharField')(max_length=500)), + )) + db.send_create_signal(u'main', ['Registration']) + + + def backwards(self, orm): + # Adding model 'Contact' + db.create_table(u'main_contact', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + )) + db.send_create_signal(u'main', ['Contact']) + + # Deleting model 'Registration' + db.delete_table(u'main_registration') + + + models = { + u'main.about': { + 'Meta': {'object_name': 'About'}, + 'bios': ('django.db.models.fields.TextField', [], {}), + 'bios_photo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.announcement': { + 'Meta': {'ordering': "['-pub_date']", 'object_name': 'Announcement'}, + 'body': ('django.db.models.fields.TextField', [], {}), + 'event_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 7, 23, 0, 0)'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'pub_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2013, 7, 23, 0, 0)'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}), + 'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}), + 'venue': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}) + }, + u'main.dynamic_section': { + 'Meta': {'object_name': 'Dynamic_Section'}, + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'section': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.page': { + 'Meta': {'object_name': 'Page'}, + 'content': ('django.db.models.fields.TextField', [], {}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'page': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.registration': { + 'Meta': {'object_name': 'Registration'}, + 'form_code': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['main'] \ No newline at end of file diff --git a/umonya/umonya/apps/main/migrations/0004_auto__chg_field_registration_form_code.py b/umonya/umonya/apps/main/migrations/0004_auto__chg_field_registration_form_code.py new file mode 100644 index 0000000..a9d5479 --- /dev/null +++ b/umonya/umonya/apps/main/migrations/0004_auto__chg_field_registration_form_code.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Changing field 'Registration.form_code' + db.alter_column(u'main_registration', 'form_code', self.gf('django.db.models.fields.URLField')(max_length=500)) + + def backwards(self, orm): + + # Changing field 'Registration.form_code' + db.alter_column(u'main_registration', 'form_code', self.gf('django.db.models.fields.CharField')(max_length=500)) + + models = { + u'main.about': { + 'Meta': {'object_name': 'About'}, + 'bios': ('django.db.models.fields.TextField', [], {}), + 'bios_photo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.announcement': { + 'Meta': {'ordering': "['-pub_date']", 'object_name': 'Announcement'}, + 'body': ('django.db.models.fields.TextField', [], {}), + 'event_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 7, 23, 0, 0)'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'pub_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2013, 7, 23, 0, 0)'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}), + 'title': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}), + 'venue': ('django.db.models.fields.CharField', [], {'max_length': '300', 'blank': 'True'}) + }, + u'main.dynamic_section': { + 'Meta': {'object_name': 'Dynamic_Section'}, + 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'section': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.page': { + 'Meta': {'object_name': 'Page'}, + 'content': ('django.db.models.fields.TextField', [], {}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'page': ('django.db.models.fields.CharField', [], {'max_length': '200'}) + }, + u'main.registration': { + 'Meta': {'object_name': 'Registration'}, + 'form_code': ('django.db.models.fields.URLField', [], {'max_length': '500'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + } + } + + complete_apps = ['main'] \ No newline at end of file diff --git a/umonya/umonya/apps/main/models.py b/umonya/umonya/apps/main/models.py index b4bd3a2..2fbfae9 100644 --- a/umonya/umonya/apps/main/models.py +++ b/umonya/umonya/apps/main/models.py @@ -61,7 +61,6 @@ class About(models.Model): bios = models.TextField() bios_photo = models.ImageField(upload_to=get_image_path, blank=True, null=True) - pub_date = models.DateTimeField("Date Published") def __unicode__(self): return self.name @@ -81,32 +80,9 @@ def __unicode__(self): class Registration(models.Model): """ - Model that generates specific sections in the User Form + Specify the registration section via admin """ - TYPE_OF_Q = (("CharField", "CharField"), ("EmailField", "EmailField"), - ("IntegerField", "IntegerField"), ("TextField", "TextField")) - - name = models.CharField(max_length=200) - field_type = models.CharField(max_length=200, choices=TYPE_OF_Q) - text = models.CharField(max_length=200) - priority = models.IntegerField() - required = models.BooleanField() + form_code = models.CharField(max_length=500) def __unicode__(self): - return self.name - - -class Dynamic_Section(models.Model): - """ - Sections that can be enabled or disabled by admin such - as registration form and menu - """ - section = models.CharField(max_length=200) - enabled = models.BooleanField() - - def __unicode__(self): - return self.section - - -class Contact(models.Model): - pass + return self.form_code diff --git a/umonya/umonya/apps/main/tests/test_forms.py b/umonya/umonya/apps/main/tests/test_forms.py index 6459016..6335737 100644 --- a/umonya/umonya/apps/main/tests/test_forms.py +++ b/umonya/umonya/apps/main/tests/test_forms.py @@ -1,31 +1,9 @@ -from umonya.apps.main.forms import RegistrationForm, ContactForm +from umonya.apps.main.forms import ContactForm from django.test import TestCase -from umonya.apps.main.models import Registration, Dynamic_Section from umonya.apps.main.views import send_email_f class TestForms(TestCase): - """ - The tests below are failing, commenting them out for now - """ - # def test_form_rendering(self): - # Dynamic_Section.objects.create(section="registration", enabled=True) - # Registration.objects.create(name="name", field_type="CharField", text="What is Your Name?", priority=1, required=True) - # Registration.objects.create(name="age", field_type="IntegerField", text="How Old are you", priority=5, required=False) - # response = self.client.get("/registration/") - # self.assertTrue('form' in response.context) - # self.assertContains(response, "What is Your Name?") - - # def test_empty_registration_form(self): - # # Testing the processing of the registration form in the views functionRegistration_Question.objects.create(name="name", field_type="CharField", text="What is Your Name?", priority=1, required=True) - # Registration.objects.create(name="name", field_type="CharField", text="What is Your Name?", priority=1, required=True) - # Registration.objects.create(name="age", field_type="IntegerField", - # text="How Old are you", priority=5, required=False) - # data = {"name": "", "age": ""} - # form = RegistrationForm(data=data) - # self.assertEqual(form["name"].errors, [u'This field is required.']) - # self.assertEqual(form["age"].errors, [u'This field is required.']) - def test_contactform_good_fields(self): form_data = {"name": "Mark Gituma", "email": "Email@mail.com", "text": "Hello World"} form = ContactForm(data=form_data) @@ -45,8 +23,3 @@ def test_contactform_bad_fields(self): form_data = {"name": "", "email": "umonya", "text": ""} form = ContactForm(data=form_data) self.assertEqual(form["email"].errors, [u'Enter a valid email address.']) - - def test_contact_form_post(self): - form_data = {"name": "Mark Gituma", "email": "Email@mail.com", "text": "Hello World"} - response = self.client.post("/contact/", form_data) - self.assertIn("success", response.context) diff --git a/umonya/umonya/apps/main/tests/test_page_rendering.py b/umonya/umonya/apps/main/tests/test_page_rendering.py index a9e0480..6d23cc0 100644 --- a/umonya/umonya/apps/main/tests/test_page_rendering.py +++ b/umonya/umonya/apps/main/tests/test_page_rendering.py @@ -1,7 +1,5 @@ from django.test import TestCase -from umonya.apps.main.models import About, Page, Dynamic_Section -import datetime -from django.utils.timezone import utc +from umonya.apps.main.models import About, Page, Registration from django.core.urlresolvers import reverse @@ -24,7 +22,7 @@ def test_about(self): self.assertTemplateUsed(response, "about.html") def test_registration(self): - Dynamic_Section.objects.create(section="registration", enabled=True) + Registration.objects.create(form_code="") response = self.client.get("/registration/") self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "registration.html") @@ -59,9 +57,7 @@ def test_about_content(self): def test_about_bios(self): About.objects.create(name="Umonya Name", bios="Umonya Bios", - bios_photo="path/2/Um/Photo.png", - pub_date=datetime.datetime.utcnow(). - replace(tzinfo=utc)) + bios_photo="path/2/Um/Photo.png") response = self.client.get("/about/") content = response.context['about'][0] @@ -71,18 +67,17 @@ def test_about_bios(self): self.assertEqual(content.bios_photo, "path/2/Um/Photo.png") def test_registration_open(self): - Dynamic_Section.objects.create(section="registration", enabled=True) + Registration.objects.create(form_code="") response = self.client.get("/registration/") - self.assertTrue("section" in response.context) - self.assertEqual(response.context["section"].enabled, True) - self.assertContains(response, "") + self.assertTrue("registration_open" in response.context) + self.assertEqual(response.context["registration_open"], True) + self.assertContains(response, "") self.assertNotContains(response, "registration has closed") def test_registration_closed(self): - Dynamic_Section.objects.create(section="registration", enabled=False) response = self.client.get("/registration/") - self.assertTrue("section" in response.context) - self.assertEqual(response.context["section"].enabled, False) + self.assertTrue("registration_open" in response.context) + self.assertEqual(response.context["registration_open"], False) self.assertNotContains(response, "") self.assertContains(response, "registration has closed") diff --git a/umonya/umonya/apps/main/urls.py b/umonya/umonya/apps/main/urls.py index 956a9e5..ba107c5 100644 --- a/umonya/umonya/apps/main/urls.py +++ b/umonya/umonya/apps/main/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import patterns, url #~ Creating the App importable urlpatterns = patterns('', diff --git a/umonya/umonya/apps/main/views.py b/umonya/umonya/apps/main/views.py index 2a47cb6..d12d51b 100644 --- a/umonya/umonya/apps/main/views.py +++ b/umonya/umonya/apps/main/views.py @@ -1,10 +1,10 @@ from django.shortcuts import render_to_response, get_object_or_404 -from models import About, Page, Dynamic_Section, Announcement -from forms import RegistrationForm, ContactForm -from django.http import HttpResponseRedirect +from models import About, Page, Announcement, Registration +from forms import ContactForm from django.core.context_processors import csrf from django.template import RequestContext + def home(request, page_number=1): """ Renders the home.html view which is used as the index page i.e @@ -73,8 +73,7 @@ def custom_404(request, page_number, slug): def about(request): about = About.objects.all() page_content = Page.objects.all().filter(page="about") - return render_to_response("about.html", {'about': about, - "page_content": page_content}, + return render_to_response("about.html", {'about': about, "page_content": page_content}, context_instance=RequestContext(request)) @@ -83,27 +82,14 @@ def resources(request): def registration(request): - if request.method == "POST": - f = RegistrationForm(request.POST) - - if f.is_valid(): - send_email_f(f) - success = {"success": "success"} - return render_to_response("registration.html", success, - context_instance=RequestContext(request)) - + registration = Registration.objects.all() + if registration.exists(): + registration = registration[0] else: - f = RegistrationForm() + registration = None - try: - section = Dynamic_Section.objects.get(section="registration") - except Dynamic_Section.DoesNotExist: - section = False - - args = {} + args = {"registration": registration} args.update(csrf(request)) - args["section"] = section - args["form"] = f return render_to_response("registration.html", args, context_instance=RequestContext(request)) @@ -138,9 +124,11 @@ def send_email_f(f): from django.core.mail import send_mail subject = "User Registration" message = '' - for item in f.cleaned_data: - message = message + item.upper() + "\n" + str(f.cleaned_data[item]) + "\n\n" + + for key, value in f.cleaned_data.iteritems(): + message = "%s %s\n%s\n\n" % (message, key.upper(), value) + sender = "umonya@admin.com" recipients = ["umonya@admin.com"] - if send_mail(subject, message, sender, recipients): - return True + + return send_mail(subject, message, sender, recipients) diff --git a/umonya/umonya/settings.py b/umonya/umonya/settings.py index a1c2b9b..d64dce8 100644 --- a/umonya/umonya/settings.py +++ b/umonya/umonya/settings.py @@ -137,6 +137,8 @@ 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', + 'captcha', + 'south', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', ) @@ -183,3 +185,7 @@ # For development only if no mail server is present logs mail to console EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + +# CAPTCHA STUFF +RECAPTCHA_PUBLIC_KEY = "6Le5IuQSAAAAAGeTlu2uuj2AcOG-1eDB-qdtz8Xf" +RECAPTCHA_PRIVATE_KEY = "6Le5IuQSAAAAABqGjiSAhyEVgBM-X0xkJGpKrJCG" diff --git a/umonya/umonya/static/js/umonya.js b/umonya/umonya/static/js/umonya.js index 665a502..360512f 100644 --- a/umonya/umonya/static/js/umonya.js +++ b/umonya/umonya/static/js/umonya.js @@ -1,20 +1,24 @@ /* Adds .active class to the Menu Tabs for extra styling */ $(function(){ function stripTrailingSlash(str) { - if(str.substr(-1) == '/') { - return str.substr(0, str.length - 1); - } - return str; + if(str.substr(-1) == '/') { + return str.substr(0, str.length - 1); + } + return str; } var url = window.location.pathname; var activePage = stripTrailingSlash(url); $('.nav li a').each(function(){ - var currentPage = stripTrailingSlash($(this).attr('href')); + var currentPage = stripTrailingSlash($(this).attr('href')); - if (activePage == currentPage) { - $(this).parent().addClass('active'); - } + if (activePage == currentPage) { + $(this).parent().addClass('active'); + } }); +}); + +$().ready(function(){ + $("#contactForm").validate() }); \ No newline at end of file diff --git a/umonya/umonya/templates/base.html b/umonya/umonya/templates/base.html index 4bf1fbf..9efd75c 100644 --- a/umonya/umonya/templates/base.html +++ b/umonya/umonya/templates/base.html @@ -46,7 +46,7 @@