[Zope-CVS] CVS: Packages/JobBoardEx - ApproveJobs.pt:1.1 ApproveJobs.py:1.1 EndUserJobDisplay.pt:1.1 JobListView.py:1.8 JobView.pt:1.1 JobView.py:1.1 NewJob.pt:1.1 NewJob.py:1.1 Preview.pt:1.1 Waiting.pt:1.1 summary.pt:1.6 JobList.zcml:1.7

Guido van Rossum guido@python.org
Thu, 21 Mar 2002 11:03:16 -0500


Update of /cvs-repository/Packages/JobBoardEx
In directory cvs.zope.org:/tmp/cvs-serv23758

Modified Files:
	JobList.zcml 
Added Files:
	ApproveJobs.pt ApproveJobs.py EndUserJobDisplay.pt 
	JobListView.py JobView.pt JobView.py NewJob.pt NewJob.py 
	Preview.pt Waiting.pt summary.pt 
Log Message:
Reorganization:

- Move the contents of Views/Browser directory to main directory
  (losing the history; but I've tagged the old situation with
  -r before-reorg).

- Combined and cleaned up the zcml files (found several duplications!).



=== Added File Packages/JobBoardEx/ApproveJobs.pt ===
<html>
<head></head>
<body>

    <form action="." method="post">
    <table border=0>
    <tr><th colspan=3>Action</th>
	<th rowspan=2>Summary</th>
    </tr>
    <tr><th>Defer</th><th>Approve</th><th>Discard</th>
    </tr>
    <tr tal:repeat="job python:here.query('pending approval')"
	style="text-align:center">
	<td><input name="job_N" type="radio" value="defer" checked
		   tal:attributes="name python:'job_%s' % job.id"></td>
	<td><input name="job_N" type="radio" value="approve"
		   tal:attributes="name python:'job_%s' % job.id"></td>
	<td><input name="job_N" type="radio" value="discard"
		   tal:attributes="name python:'job_%s' % job.id"></td>
	<td tal:content="job/summary">The best job on the Internet</td>
    </tr>
    <tr><td colspan="3">
	<input name="submit:method" type="submit" value="Submit">
	<input name="cancel:method" type="submit" value="Cancel">
	<input hame="back:method" type="submit" value="Back to summary">
    </td></tr>
    </table>
    </form>
	    
</body>
</html>


=== Added File Packages/JobBoardEx/ApproveJobs.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: ApproveJobs.py,v 1.1 2002/03/21 16:03:15 gvanrossum Exp $
"""

from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.ComponentArchitecture.ContextDependent import ContextDependent

from ZopeProducts.JobBoardEx.IJob import JobState

class ApproveJobs(AttributePublisher, ContextDependent):
    index = PageTemplateFile('ApproveJobs.pt')

    def cancel(self, REQUEST):
        return REQUEST.response.redirect('..')

    back = cancel

    def submit(self, REQUEST):
        """Approve a job."""
        joblist = self.getContext()
        for job in joblist.query(JobState.PendingApproval):
            jobid = 'job_%s' % job.id
            value = REQUEST.get(jobid, None)
            if value == 'defer':
                pass
            elif value == 'approve':
                job.approve()
            elif value == 'discard':
                # XXX This might change
                joblist.remove(job)
            else:
                # Malicious form poster!
                pass
        return self.index(REQUEST)


=== Added File Packages/JobBoardEx/EndUserJobDisplay.pt ===
<html>
<head></head>
<body>

    <form action="../../" method="post">
    <div metal:use-macro="container/shared_display" />

    <table border=0>
	<tr><td>
	<input name="back" type="submit" value="Back to summary">
	</td></tr>
    </table>
    </form>    

</body>
</html>


=== Packages/JobBoardEx/JobListView.py 1.7 => 1.8 ===
+from Zope.PageTemplate import PageTemplateFile
+
+from ZopeProducts.JobBoardEx.IJobList import IJobList
+from ZopeProducts.JobBoardEx.IJob import JobState
+
+class JobListSummaryView(AttributePublisher):
+
+    def __init__(self, joblist):
+        self.joblist = joblist
+
+    def getContext(self):
+        return self.joblist
+
+    __used_for__ = IJobList
+
+    def getApprovedJobs(self):
+        return self.joblist.query(JobState.Approved)
+
+    index = PageTemplateFile("summary.pt", globals())


=== Added File Packages/JobBoardEx/JobView.pt ===
<table border=0 metal:define-macro="shared_display">
<tr><td>Submitter:</td>
    <td tal:content="container/getSubmitter">aperson@dom.ain</td>
</tr>
<tr><td>Summary:</td>
    <td tal:content="container/getSummary">The best job on the Internet</td>
</tr>
<tr><td>Description:</td>
    <td tal:content="container/getDescription">This is really really
	    really the best job on the Internet</td>
</tr>
<tr><td>Contact:</td>
    <td tal:content="container/getContact">bperson@dom.ain</td>
</tr>
</table>


=== Added File Packages/JobBoardEx/JobView.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: JobView.py,v 1.1 2002/03/21 16:03:15 gvanrossum Exp $
"""

import os

from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.ComponentArchitecture.ContextDependent import ContextDependent


class JobView(AttributePublisher, ContextDependent):
    index = PageTemplateFile('EndUserJobDisplay.pt')

    simpleView = PageTemplateFile('JobView.pt')

    def shared_display(self):
        return self.simpleView.macros['shared_display']

    # Add accessor methods so the security framework can do assertion.  The
    # page template can't use the attributes on the Job object directly. :(
    def getSubmitter(self):
        return self.getContext().submitter

    def getSummary(self):
        return self.getContext().summary

    def getDescription(self):
        return self.getContext().description

    def getContact(self):
        return self.getContext().contact


=== Added File Packages/JobBoardEx/NewJob.pt ===
<html>
<head>
<title>Enter new job data</title>
</head>
<body>
<h1>Enter new job data</h1>
    <form action="." method="post">
    <table border=0>
    <tr><td>Submitter:</td>
	<td><input name="submitter" type="text" value="" size="72"
	           tal:attributes="value request/submitter|default" />
	</td>
    </tr>
    <tr><td>Summary:</td>
	<td><input name="summary" type="text" value="" size="72"
	           tal:attributes="value request/summary|default" />
	</td>
    </tr>
    <tr><td>Description:</td>
	<td><textarea cols=72 rows=20 name="description" type="text" value=""
	     ><span tal:replace="request/description|nothing"/></textarea>
	</td>
    </tr>
    <tr><td>Contact:</td>
	<td><input name="contact" type="text" value="" size="72"
	           tal:attributes="value request/contact|default" />
	</td>
    </tr>
    <tr><td colspan="2">
	<input name="preview:method" type="submit" value="Preview">
	<input name="cancel:method" type="submit" value="Cancel">
	<input name="reset" type="reset" value="Reset">
	</td>
    </tr>
    </table>
    </form>    

</body>
</html>


=== Added File Packages/JobBoardEx/NewJob.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information: $Id: NewJob.py,v 1.1 2002/03/21 16:03:15 gvanrossum Exp $
"""

from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.ComponentArchitecture.ContextDependent import ContextDependent
from Zope.ComponentArchitecture import getRequestView

from ZopeProducts.JobBoardEx.Job import Job


class NewJob(AttributePublisher, ContextDependent):
    index = PageTemplateFile('NewJob.pt')

    preview = PageTemplateFile('Preview.pt')

    waiting = PageTemplateFile('Waiting.pt')

    def setViewRequest(self, REQUEST):
        self.request = REQUEST
        # If we're viewing the NewJob page, this method will still get called,
        # but there won't be any form variables, so just ignore the KeyErrors
        try:
            self.job = Job(REQUEST['submitter'],
                           REQUEST['summary'],
                           REQUEST['description'],
                           REQUEST['contact'])
        except KeyError:
            self.job = None

    def getJobView(self):
        view = getRequestView(self.job, 'JobView', self.request)
        return view.simpleView(self.request)

    def cancel(self, REQUEST):
        return REQUEST.response.redirect('..')

    home = cancel

    def submit(self, submitter, summary, description, contact, REQUEST):
        """Edits a job object."""
        joblist = self.getContext()
        job = Job(submitter, summary, description, contact)
        joblist.add(job)
        return self.waiting(REQUEST)


=== Added File Packages/JobBoardEx/Preview.pt ===
<html>
<body>

    <form action="." method="post">
    <div tal:replace="structure container/getJobView" />

    <table border=0>
	<tr><td>
	<input name="submit:method" type="submit" value="Submit">
	<input name="index:method" type="submit" value="Edit">
	<input name="cancel:method" type="submit" value="Cancel">
	</td></tr>
    </table>
	<input name="submitter" type="hidden" value="Submitter" size="72"
	           tal:attributes="value request/submitter" />
	<input name="summary" type="hidden" value="Summary" size="72"
	           tal:attributes="value request/summary" />
	<input name="description" type="hidden" value=""
	           tal:attributes="value request/description" />
	<input name="contact" type="hidden" value="" size="72"
	           tal:attributes="value request/contact" />
    </form>    

</body>
</html>


=== Added File Packages/JobBoardEx/Waiting.pt ===
<html>
<body>
    <h3>Your job submission has been successfully completed, do you
	want to submit another one?
    </h3>
    <form action="." method="post">
    <input name="index:method" type="submit" value="Submit another job" />
    <input name="home:method" type="submit" value="Go back to home page" />

</body>
</html>

=== Packages/JobBoardEx/summary.pt 1.5 => 1.6 ===
+<HEAD>
+<TITLE>Job Board</TITLE>
+</HEAD>
+<BODY>
+<h1>Job Board</h1>
+
+<A href="../NewJob">Submit a new job</A>
+
+<H2>Job Listings</H2>
+
+<table>
+
+<tr tal:repeat="job container/getApprovedJobs">
+    <td>
+    <a href="jobid" tal:attributes="href string:../${job/id}/JobView;;view">
+    <span tal:replace="job/summary">A job summary</span></A>
+    </td>
+</tr>
+</table>
+
+<!-- XXX this should only appear if the user has the proper permissions -->
+<h2>Other operations</h2>
+<a href="../ApproveJobs">Approve submitted jobs</a>
+
+</BODY>
+</HTML>


=== Packages/JobBoardEx/JobList.zcml 1.6 => 1.7 ===
-<!ENTITY summaryView
-         ".JobBoardEx.Views.Browser.JobListView.JobListSummaryView">
-]>
-
 <zopeConfigure
          xmlns='http://namespaces.zope.org/zope'
          xmlns:zmi='http://namespaces.zope.org/zmi'
@@ -10,10 +5,16 @@
          xmlns:browser='http://namespaces.zope.org/browser'
 >
 
+
+<!-- *** Content classes *** -->
+
+<!-- JobList -->
+
 <zmi:factoryFromClass 
          name=".JobBoardEx.JobList." 
          permission_id="Zope.Public"
-         title="JobList" />
+         title="JobList"
+/>
 
 <security:protectClass 
          name=".JobBoardEx.JobList."
@@ -21,36 +22,84 @@
 	 methods="query"
 />
 
+<!-- Job -->
+
+<!-- This doesn't need a factory, since jobs are always created by
+     Python code. -->
+
+<security:protectClass
+	name=".JobBoardEx.Job."
+	permission_id="Zope.Public"
+/>
+
+
+<!-- *** Views *** -->
+
+<!-- JobListTraverser -->
+
+<browser:view
+	for=".JobBoardEx.IJobList."
+        name="_traverse"
+        factory=".JobBoardEx.JobList.JobListTraverser" 
+/>
+
+<!-- JobListSummaryView -->
+
 <browser:defaultView 
         for=".JobBoardEx.IJobList."
         name="summary"
-        factory="&summaryView;"
+        factory=".JobBoardEx.JobListView.JobListSummaryView"
 />
 
 <security:protectClass 
-        name="&summaryView;"
+        name=".JobBoardEx.JobListView.JobListSummaryView"
         permission_id="Zope.Public"
         methods="index, getApprovedJobs"
 />
 
-<browser:view for=".JobBoardEx.IJobList."
-        name="_traverse"
-        factory=".JobBoardEx.JobList.JobListTraverser" 
+<!-- JobView -->
+
+<browser:view for=".JobBoardEx.IJob."
+              name="JobView"
+              factory=".JobBoardEx.JobView."
 />
 
-<security:protectClass 
-        name="&summaryView;"
-        permission_id="Zope.Public"
-        methods="index, getApprovedJobs"
+<security:protectClass
+	name=".JobBoardEx.JobView."
+	permission_id="Zope.View"
+	methods="index, simpleView, getSubmitter, getSummary,
+	         getDescription, getContact, shared_display"
+/>
+
+
+<!-- *** Actions *** -->
+
+<!-- NewJob -->
+
+<browser:view
+	for=".JobBoardEx.IJobList."
+	name="NewJob"
+	factory=".JobBoardEx.NewJob."
 />
 
 <security:protectClass
-	name=".JobBoardEx.Job."
-	permission_id="Zope.Public"
+	name=".JobBoardEx.NewJob."
+	permission_id="Zope.View"
+	methods="index, preview, waiting, getJobView, cancel, home, submit"
 />
 
-<include package=".JobBoardEx.Views"
-	 file="views.zcml"
-	 />
+<!-- ApproveJobs -->
+
+<browser:view
+	for=".JobBoardEx.IJobList."
+	name="ApproveJobs"
+	factory=".JobBoardEx.ApproveJobs."
+/>
+
+<security:protectClass
+	name=".JobBoardEx.ApproveJobs."
+	permission_id="Zope.View"
+	methods="index, cancel, submit"
+/>
 
 </zopeConfigure>