# HG changeset patch # User Sverre Rabbelier # Date 1256426611 25200 # Node ID 187c1709756b5822c737429242085846ba7c3acb # Parent 72eec4d724711b576eb5ca9cbe9b2331f9432271 GSoC Views diff -r 72eec4d72471 -r 187c1709756b app/settings.py --- a/app/settings.py Sun Oct 25 19:21:43 2009 +0000 +++ b/app/settings.py Sat Oct 24 16:23:31 2009 -0700 @@ -128,4 +128,5 @@ MODULE_FMT = 'soc.modules.%s.callback' # TODO: to enable GHOP change the MODULES line have the following entries: #MODULES = ['ghop'] +#MODULES = ['gsoc'] MODULES = [] diff -r 72eec4d72471 -r 187c1709756b app/soc/modules/gsoc/callback.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/modules/gsoc/callback.py Sat Oct 24 16:23:31 2009 -0700 @@ -0,0 +1,69 @@ +# Copyright 2009 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Module containing the GSoC Callback. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + +from soc.modules.gsoc.views.models import mentor +from soc.modules.gsoc.views.models import org_admin +from soc.modules.gsoc.views.models import organization +from soc.modules.gsoc.views.models import program +from soc.modules.gsoc.views.models import student +from soc.modules.gsoc.views.models import timeline + + +class Callback(object): + """Callback object that handles interaction between the core. + """ + + API_VERSION = 1 + + def __init__(self, core): + """Initializes a new Callback object for the specified core. + """ + + self.core = core + + def registerWithSitemap(self): + """Called by the server when sitemap entries should be registered. + """ + + self.core.requireUniqueService('registerWithSitemap') + + # register the GSoC Views + self.core.registerSitemapEntry(mentor.view.getDjangoURLPatterns()) + self.core.registerSitemapEntry(org_admin.view.getDjangoURLPatterns()) + self.core.registerSitemapEntry(organization.view.getDjangoURLPatterns()) + self.core.registerSitemapEntry(program.view.getDjangoURLPatterns()) + self.core.registerSitemapEntry(student.view.getDjangoURLPatterns()) + self.core.registerSitemapEntry(timeline.view.getDjangoURLPatterns()) + + def registerWithSidebar(self): + """Called by the server when sidebar entries should be registered. + """ + + # require that we had the chance to register the urls we need with the sitemap + self.core.requireUniqueService('registerWithSidebar') + + # register the GHOP menu entries + self.core.registerSidebarEntry(mentor.view.getSidebarMenus) + self.core.registerSidebarEntry(org_admin.view.getSidebarMenus) + self.core.registerSidebarEntry(organization.view.getSidebarMenus) + self.core.registerSidebarEntry(program.view.getSidebarMenus) + self.core.registerSidebarEntry(student.view.getSidebarMenus) + self.core.registerSidebarEntry(timeline.view.getSidebarMenus) diff -r 72eec4d72471 -r 187c1709756b app/soc/modules/gsoc/views/models/mentor.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/modules/gsoc/views/models/mentor.py Sat Oct 24 16:23:31 2009 -0700 @@ -0,0 +1,103 @@ +#!/usr/bin/python2.5 +# +# Copyright 2009 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Views for GSoCMentor. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + + +from soc.logic import dicts +from soc.views.helper import decorators +from soc.views.models import mentor + +from soc.modules.gsoc.logic.models.mentor import logic as mentor_logic +from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic +from soc.modules.gsoc.logic.models.organization import logic as org_logic +from soc.modules.gsoc.logic.models.student import logic as student_logic +from soc.modules.gsoc.views.models import organization as org_view +from soc.views.helper import access # TODO + + +class View(mentor.View): + """View methods for the GSoCMentor model. + """ + + def __init__(self, params=None): + """Defines the fields and methods required for the base View class + to provide the user with list, public, create, edit and delete views. + + Params: + params: a dict with params for this View + """ + + rights = access.Checker(params) + rights['create'] = ['checkIsDeveloper'] + rights['edit'] = [('checkIsMyActiveRole', mentor_logic)] + rights['delete'] = ['checkIsDeveloper'] + rights['invite'] = [('checkHasActiveRoleForScope', org_admin_logic)] + rights['accept_invite'] = [('checkCanCreateFromRequest', 'mentor'), + ('checkIsNotStudentForProgramOfOrg', [org_logic, + student_logic])] + rights['request'] = [ + ('checkIsNotStudentForProgramOfOrg', + [org_logic, student_logic]), + ('checkCanMakeRequestToGroup', org_logic)] + rights['process_request'] = [ + ('checkHasActiveRoleForScope', org_admin_logic), + ('checkCanProcessRequest', 'mentor')] + rights['manage'] = [ + ('checkIsAllowedToManageRole', [mentor_logic, org_admin_logic])] + + new_params = {} + new_params['logic'] = mentor_logic + new_params['group_logic'] = org_logic + new_params['group_view'] = org_view.view + new_params['rights'] = rights + + new_params['scope_view'] = org_view + + new_params['name'] = "GSoC Mentor" + new_params['module_name'] = "mentor" + new_params['sidebar_grouping'] = 'Organizations' + + new_params['module_package'] = 'soc.modules.gsoc.views.models' + new_params['url_name'] = 'gsoc/mentor' + + new_params['role'] = 'gsoc/mentor' + + params = dicts.merge(params, new_params, sub_merge=True) + + super(View, self).__init__(params) + + +view = View() + +accept_invite = decorators.view(view.acceptInvite) +admin = decorators.view(view.admin) +create = decorators.view(view.create) +delete = decorators.view(view.delete) +edit = decorators.view(view.edit) +invite = decorators.view(view.invite) +list = decorators.view(view.list) +manage = decorators.view(view.manage) +process_request = decorators.view(view.processRequest) +role_request = decorators.view(view.request) +public = decorators.view(view.public) +export = decorators.view(view.export) +pick = decorators.view(view.pick) diff -r 72eec4d72471 -r 187c1709756b app/soc/modules/gsoc/views/models/org_admin.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/modules/gsoc/views/models/org_admin.py Sat Oct 24 16:23:31 2009 -0700 @@ -0,0 +1,97 @@ +#!/usr/bin/python2.5 +# +# Copyright 2009 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Views for GSoCOrgAdmin. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + + +from soc.logic import dicts +from soc.views.helper import decorators +from soc.views.models import mentor + +from soc.modules.gsoc.logic.models.mentor import logic as mentor_logic +from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic +from soc.modules.gsoc.logic.models.organization import logic as org_logic +from soc.modules.gsoc.logic.models.student import logic as student_logic +from soc.modules.gsoc.views.models import organization as org_view # TODO +from soc.views.helper import access # TODO + + +class View(mentor.View): + """View methods for the GSoCMentor model. + """ + + def __init__(self, params=None): + """Defines the fields and methods required for the base View class + to provide the user with list, public, create, edit and delete views. + + Params: + params: a dict with params for this View + """ + + rights = access.Checker(params) + rights['create'] = ['checkIsDeveloper'] + rights['edit'] = [('checkIsMyActiveRole', org_admin_logic)] + rights['delete'] = ['checkIsDeveloper'] + rights['invite'] = [('checkHasActiveRoleForScope', + org_admin_logic)] + rights['accept_invite'] = [('checkCanCreateFromRequest', 'org_admin'), + ('checkIsNotStudentForProgramOfOrg', [org_logic, student_logic])] + rights['process_request'] = [ + ('checkHasActiveRoleForScope', org_admin_logic), + ('checkCanProcessRequest', 'org_admin')] + rights['manage'] = [ + ('checkIsAllowedToManageRole', [org_admin_logic, org_admin_logic])] + + new_params = {} + new_params['logic'] = org_admin_logic + new_params['group_logic'] = org_logic + new_params['group_view'] = org_view.view + new_params['rights'] = rights + + new_params['scope_view'] = org_view + + new_params['name'] = "GSoC Organization Admin" + new_params['module_name'] = "org_admin" + new_params['sidebar_grouping'] = 'Organizations' + + new_params['module_package'] = 'soc.modules.gsoc.views.models' + new_params['url_name'] = 'gsoc/org_admin' + + new_params['role'] = 'gsoc/org_admin' + + params = dicts.merge(params, new_params, sub_merge=True) + + super(View, self).__init__(params) + + +view = View() + +accept_invite = decorators.view(view.acceptInvite) +admin = decorators.view(view.admin) +create = decorators.view(view.create) +delete = decorators.view(view.delete) +edit = decorators.view(view.edit) +invite = decorators.view(view.invite) +list = decorators.view(view.list) +manage = decorators.view(view.manage) +process_request = decorators.view(view.processRequest) +public = decorators.view(view.public) +export = decorators.view(view.export) diff -r 72eec4d72471 -r 187c1709756b app/soc/modules/gsoc/views/models/organization.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/modules/gsoc/views/models/organization.py Sat Oct 24 16:23:31 2009 -0700 @@ -0,0 +1,109 @@ +#!/usr/bin/python2.5 +# +# Copyright 2009 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Views for GSoCOrganization. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + + +from soc.logic import dicts +from soc.logic.models.org_app import logic as org_app_logic +from soc.views.helper import decorators +from soc.views.models import organization +from soc.views.helper import access # TODO +from soc.views.models import group + +from soc.modules.gsoc.logic.models.mentor import logic as mentor_logic +from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic +from soc.modules.gsoc.logic.models.organization import logic as org_logic +from soc.modules.gsoc.views.models import program as program_view + + +class View(organization.View): + """View methods for the Organization model. + """ + + def __init__(self, params=None): + """Defines the fields and methods required for the base View class + to provide the user with list, public, create, edit and delete views. + + Params: + params: a dict with params for this View + """ + + rights = access.Checker(params) + rights['any_access'] = ['allow'] + rights['show'] = ['allow'] + rights['create'] = ['checkIsDeveloper'] + rights['edit'] = [('checkHasActiveRoleForKeyFieldsAsScope', + org_admin_logic), + ('checkGroupIsActiveForLinkId', org_logic)] + rights['delete'] = ['checkIsDeveloper'] + rights['home'] = ['allow'] + rights['public_list'] = ['allow'] + rights['apply_mentor'] = ['checkIsUser'] + rights['list_requests'] = [('checkHasActiveRoleForKeyFieldsAsScope', + org_admin_logic)] + rights['list_roles'] = [('checkHasActiveRoleForKeyFieldsAsScope', + org_admin_logic)] + rights['applicant'] = [('checkIsApplicationAccepted', + org_app_logic)] + rights['list_proposals'] = [('checkHasAny', [ + [('checkHasActiveRoleForKeyFieldsAsScope', [org_admin_logic]), + ('checkHasActiveRoleForKeyFieldsAsScope', [mentor_logic])] + ])] + + new_params = {} + new_params['logic'] = org_logic + new_params['rights'] = rights + + new_params['scope_view'] = program_view + + new_params['name'] = "GSoC Organization" + new_params['module_name'] = "organization" + new_params['sidebar_grouping'] = 'Organizations' + + new_params['module_package'] = 'soc.modules.gsoc.views.models' + new_params['url_name'] = 'gsoc/org' + new_params['document_prefix'] = 'gsoc_org' + + new_params['mentor_role_name'] = 'gsoc_mentor' + + params = dicts.merge(params, new_params, sub_merge=True) + + super(View, self).__init__(params) + + +view = View() + +admin = decorators.view(view.admin) +#applicant = decorators.view(view.applicant) # TODO +apply_mentor = decorators.view(view.applyMentor) +create = decorators.view(view.create) +delete = decorators.view(view.delete) +edit = decorators.view(view.edit) +home = decorators.view(view.home) +list = decorators.view(view.list) +list_proposals = decorators.view(view.listProposals) +list_public = decorators.view(view.listPublic) +list_requests = decorators.view(view.listRequests) +list_roles = decorators.view(view.listRoles) +public = decorators.view(view.public) +export = decorators.view(view.export) +pick = decorators.view(view.pick) diff -r 72eec4d72471 -r 187c1709756b app/soc/modules/gsoc/views/models/program.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/modules/gsoc/views/models/program.py Sat Oct 24 16:23:31 2009 -0700 @@ -0,0 +1,97 @@ +#!/usr/bin/python2.5 +# +# Copyright 2009 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Views for GSoCProgram. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + + +from soc.logic import dicts +from soc.views.helper import decorators +from soc.views.helper import access # TODO +from soc.views.models import program + +from soc.logic.models.host import logic as host_logic +from soc.modules.gsoc.logic.models.program import logic as program_logic +from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic + + +class View(program.View): + """View methods for the Program model. + """ + + def __init__(self, params=None): + """Defines the fields and methods required for the base View class + to provide the user with list, public, create, edit and delete views. + + Params: + params: a dict with params for this View + """ + + rights = access.Checker(params) + rights['any_access'] = ['allow'] + rights['show'] = ['allow'] + rights['create'] = [('checkSeeded', ['checkHasActiveRoleForScope', + host_logic])] + rights['edit'] = ['checkIsHostForProgram'] + rights['delete'] = ['checkIsDeveloper'] + rights['assign_slots'] = ['checkIsHostForProgram'] + rights['slots'] = ['checkIsHostForProgram'] + rights['show_duplicates'] = ['checkIsHostForProgram'] + rights['assigned_proposals'] = ['checkIsHostForProgram'] + rights['accepted_orgs'] = [('checkIsAfterEvent', + ['accepted_organization_announced_deadline', + '__all__', program_logic])] + rights['list_projects'] = [('checkIsAfterEvent', + ['accepted_students_announced_deadline', + '__all__', program_logic])] + + new_params = {} + new_params['logic'] = program_logic + new_params['rights'] = rights + + new_params['name'] = "GSoC Program" + new_params['module_name'] = "program" + new_params['sidebar_grouping'] = 'Programs' + + new_params['module_package'] = 'soc.modules.gsoc.views.models' + new_params['url_name'] = 'gsoc/program' + + params = dicts.merge(params, new_params, sub_merge=True) + + super(View, self).__init__(params) + + +view = View() + +accepted_orgs = decorators.view(view.acceptedOrgs) +list_projects = decorators.view(view.acceptedProjects) +admin = decorators.view(view.admin) +assign_slots = decorators.view(view.assignSlots) +assigned_proposals = decorators.view(view.assignedProposals) +create = decorators.view(view.create) +delete = decorators.view(view.delete) +edit = decorators.view(view.edit) +list = decorators.view(view.list) +public = decorators.view(view.public) +export = decorators.view(view.export) +show_duplicates = decorators.view(view.showDuplicates) +slots = decorators.view(view.slots) +home = decorators.view(view.home) +pick = decorators.view(view.pick) diff -r 72eec4d72471 -r 187c1709756b app/soc/modules/gsoc/views/models/student.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/modules/gsoc/views/models/student.py Sat Oct 24 16:23:31 2009 -0700 @@ -0,0 +1,98 @@ +#!/usr/bin/python2.5 +# +# Copyright 2009 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Views for GSoCStudent. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + + +from soc.logic import dicts +from soc.views.helper import decorators +from soc.views.helper import access # TODO +from soc.views.models import student + +from soc.logic.models.host import logic as host_logic +from soc.modules.gsoc.logic.models.program import logic as program_logic +from soc.modules.gsoc.logic.models.student import logic as student_logic +from soc.modules.gsoc.logic.models.mentor import logic as mentor_logic +from soc.modules.gsoc.logic.models.org_admin import logic as org_admin_logic +from soc.modules.gsoc.views.models import program as program_view + + +class View(student.View): + """View methods for the Student model. + """ + + def __init__(self, params=None): + """Defines the fields and methods required for the base View class + to provide the user with list, public, create, edit and delete views. + + Params: + params: a dict with params for this View + """ + + rights = access.Checker(params) + rights['create'] = ['checkIsDeveloper'] + rights['edit'] = [('checkIsMyActiveRole', student_logic)] + rights['delete'] = ['checkIsDeveloper'] + rights['apply'] = [ + 'checkIsUser', + ('checkIsActivePeriod', + ['student_signup', 'scope_path', program_logic]), + ('checkIsNotParticipatingInProgramInScope', [program_logic, + student_logic, org_admin_logic, mentor_logic]), + ] + rights['manage'] = [('checkIsMyActiveRole', student_logic)] + rights['list_projects'] = [ + ('checkHasActiveRoleForScope', student_logic), + ('checkIsAfterEvent', ['accepted_students_announced_deadline', + 'scope_path', program_logic])] + + new_params = {} + new_params['logic'] = student_logic + new_params['rights'] = rights + + new_params['group_logic'] = program_logic + new_params['group_view'] = program_view.view + + new_params['scope_view'] = program_view + + new_params['name'] = "GSoC Student" + new_params['module_name'] = "student" + new_params['sidebar_grouping'] = 'Students' + + new_params['module_package'] = 'soc.modules.gsoc.views.models' + new_params['url_name'] = 'gsoc/student' + + params = dicts.merge(params, new_params, sub_merge=True) + + super(View, self).__init__(params) + + +view = View() + +apply = decorators.view(view.apply) +create = decorators.view(view.create) +delete = decorators.view(view.delete) +edit = decorators.view(view.edit) +list = decorators.view(view.list) +list_projects = decorators.view(view.listProjects) +manage = decorators.view(view.manage) +public = decorators.view(view.public) +export = decorators.view(view.export) diff -r 72eec4d72471 -r 187c1709756b app/soc/modules/gsoc/views/models/timeline.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/modules/gsoc/views/models/timeline.py Sat Oct 24 16:23:31 2009 -0700 @@ -0,0 +1,69 @@ +#!/usr/bin/python2.5 +# +# Copyright 2009 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Views for GSoCTimeline. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + +from soc.logic import dicts +from soc.views.helper import access # TODO +from soc.views.helper import decorators +from soc.views.models import timeline + +from soc.modules.gsoc.logic.models.program import logic as program_logic +from soc.modules.gsoc.logic.models.timeline import logic as timeline_logic + + +import soc.modules.ghop.logic.models.timeline + + +class View(timeline.View): + """View methods for the Timeline model. + """ + + def __init__(self, params=None): + """Defines the fields and methods required for the base View class + to provide the user with list, public, create, edit and delete views. + + Params: + params: a dict with params for this View + """ + + rights = access.Checker(params) + rights['edit'] = [('checkCanEditTimeline', [program_logic])] + + new_params = {} + new_params['logic'] = timeline_logic + new_params['rights'] = rights + + new_params['name'] = "GSoC Timeline" + new_params['module_name'] = "timeline" + + new_params['module_package'] = 'soc.modules.gsoc.views.models' + new_params['url_name'] = 'gsoc/timeline' + + params = dicts.merge(params, new_params, sub_merge=True) + + super(View, self).__init__(params=params) + + +view = View() + +edit = decorators.view(view.edit) +public = decorators.view(view.public)