[Zope-CVS] CVS: Packages/JobBoardEx - ApproveJobsView.py:1.1 JobCreateView.py:1.1 JobListTraverser.py:1.1 ApproveJobs.pt:1.8 IJob.py:1.8 IJobList.py:1.5 JobCreateView.pt:1.3 JobList.py:1.11 JobList.zcml:1.19 JobListView.pt:1.6 JobView.pt:1.8 ApproveJobs.py:NONE JobEditView.pt:NONE JobListView.py:NONE JobPreviewView.pt:NONE JobView.py:NONE Tutorial.html:NONE add_confirmed.pt:NONE

Jim Fulton jim@zope.com
Tue, 11 Jun 2002 16:07:47 -0400


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

Modified Files:
	ApproveJobs.pt IJob.py IJobList.py JobCreateView.pt JobList.py 
	JobList.zcml JobListView.pt JobView.pt 
Added Files:
	ApproveJobsView.py JobCreateView.py JobListTraverser.py 
Removed Files:
	ApproveJobs.py JobEditView.pt JobListView.py JobPreviewView.pt 
	JobView.py Tutorial.html add_confirmed.pt 
Log Message:
Jim and Guido redid (nearly) from scratch using new ZCML/Zope3-isms
and a simpler design.

Guido plans to clean this up.



=== Added File Packages/JobBoardEx/ApproveJobsView.py ===
from Zope.App.PageTemplate.ViewPageTemplateFile import ViewPageTemplateFile
from Zope.Publisher.Browser.BrowserView import BrowserView

class ApproveJobsView(BrowserView):

    form = ViewPageTemplateFile('ApproveJobs.pt')

    def action(self):
        form = self.request.form

        for variable in form:
            try:
                id = int(variable)
            except:
                continue

            job = self.context.lookup(id)
            action = form[variable]
            if action == 'approve':
                job.approve()
            elif action == 'discard':
                self.context.remove(job)

        self.request.getResponse().redirect('approveForm.html')


=== Added File Packages/JobBoardEx/JobCreateView.py ===
from Zope.App.PageTemplate.ViewPageTemplateFile import ViewPageTemplateFile
from Zope.Publisher.Browser.BrowserView import BrowserView
from Job import Job

class JobCreateView(BrowserView):

    form = ViewPageTemplateFile('JobCreateView.pt')

    def action(self, summary):
        job = Job('', summary, '', '')
        self.context.add(job)
        self.request.getResponse().redirect('index.html')
        


=== Added File Packages/JobBoardEx/JobListTraverser.py ===
"""Traverser component that lets us traverse to jobs
"""

from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.ComponentArchitecture import getView
from IJobList import IJobList

class JobListTraverser(BrowserView):

    __used_for__ = IJobList

    def publishTraverse(self, request, name):

        try:
            id = int(name)
        except:
            # It's not an id, it must be a view
            return getView(self.context, name, request)
        else:
            return self.context.lookup(id)

    def browserDefault(self, request):
        return self.context, ('index.html', )



=== Packages/JobBoardEx/ApproveJobs.pt 1.7 => 1.8 ===
 
 
-    <form action="." method="post" tal:attributes="action request/URL/-1">
+    <form action="approve" 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 view/getPendingJobs"
+    <tr tal:repeat="job context/getPendingJobs"
         style="text-align:center">
-        <td><input name="job_N" type="radio" value="defer" checked
-                   tal:attributes="name string:job_${job/id}"></td>
-        <td><input name="job_N" type="radio" value="approve"
-                   tal:attributes="name string:job_${job/id}"></td>
-        <td><input name="job_N" type="radio" value="discard"
-                   tal:attributes="name string:job_${job/id}"></td>
+        <td><input type="radio" checked
+                   tal:attributes="name job/id"></td>
+        <td><input type="radio" value="approve"
+                   tal:attributes="name job/id"></td>
+        <td><input type="radio" value="discard"
+                   tal:attributes="name 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="back:method" type="submit" value="Back to summary">
+        <input type="submit" value="Submit">
+        <a href="index.html">Back to summary</a>
     </td></tr>
     </table>
     </form>


=== Packages/JobBoardEx/IJob.py 1.7 => 1.8 ===
 from Interface.Attribute import Attribute
 
-class IJobCreator(Interface):
-    """marker for pre-creation view of object"""
-
 class IJob(Interface):
     """Interface for the basic Job"""
 
@@ -15,17 +12,8 @@
                    "Unique ID relative to the containing job list.\n"
                    "This can be set at most once.")
 
-    submitter = Attribute("submitter",
-                          "Email address of the submitter")
-
     summary = Attribute("summary",
                         "One-line summary of the job")
-
-    description = Attribute("description",
-                            "Longer description of the job")
-
-    contact = Attribute("contact",
-                        "Email address to contact about the job")
 
     state = Attribute("state",
                       "Current state of the job listing.\n"


=== Packages/JobBoardEx/IJobList.py 1.4 => 1.5 ===
         """Returns a list of Job objects"""
 
+    def getApprovedJobs():
+        """Returns a sequence of the jobs that are in the approved state
+        """
+
+    def getPendingJobs():
+        """Returns a sequence of the jobs that are in the pending state
+        """
+
     def lookup(jobid):
         """Returns the job corresponding to jobid.
 


=== Packages/JobBoardEx/JobCreateView.pt 1.2 => 1.3 ===
 <body>
 <h1>Enter new job data</h1>
-    <form action="." method="post" tal:attributes="action request/URL/-1">
+    <form action="create" 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"
-	tal:content="request/description|default"
-	     ></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="action:method" type="submit" value="Create">
-	<input name="reset" type="reset" value="Reset">
+	<input type="submit" value="Create">
 	</td>
     </tr>
     </table>


=== Packages/JobBoardEx/JobList.py 1.10 => 1.11 ===
 
+
 from IJobList import IJobList
+from IJob import JobState
 
 class JobList(Persistent):
 
@@ -10,11 +12,7 @@
         self.id = 0
         self.jobs = PersistentList()
 
-    def getContext(self):
-        return self.joblist
-
     def add(self, job):
-        # XXX do we have to worry about thread safety?
         job.id = self.id
         self.id += 1
         self.jobs.append(job)
@@ -31,3 +29,9 @@
             if job.id == jobid:
                 return job
         raise KeyError, jobid
+
+    def getPendingJobs(self):
+        return self.query(JobState.PendingApproval)
+
+    def getApprovedJobs(self):
+        return self.query(JobState.Approved)


=== Packages/JobBoardEx/JobList.zcml 1.18 => 1.19 ===
 >
 
+<content class=".JobList.">
+   <zmi:factory title="Job List"
+                permission="Zope.ManageContent" 
+                />
+   <security:allow interface=".IJobList." />
+</content>
+
+<content class=".Job.">
+   <security:allow interface=".IJob." />
+</content>
+
+<browser:view name="index.html"
+              for=".IJobList."
+              template="JobListView.pt"
+              permission="Zope.Public" 
+              />
+
+<browser:view name="_traverse"
+              for=".IJobList."
+              factory=".JobListTraverser." 
+              />
+
+<browser:view for=".IJobList."
+              factory=".JobCreateView."
+              permission="Zope.ManageContent"
+              >
+
+  <browser:page name="createForm.html" attribute="form" />
+  <browser:page name="create"          attribute="action" />
+
+</browser:view>
+
+<browser:view name="index.html"
+              for=".IJob."
+              template="JobView.pt"
+              permission="Zope.Public" 
+              />
+
+<browser:defaultView for=".IJob."
+                     name="index.html"
+                     />
+
+<browser:view for=".IJobList."
+              factory=".ApproveJobsView."
+              permission="Zope.ManageContent"
+              >
 
-<!-- *** Content classes *** -->
+  <browser:page name="approveForm.html" attribute="form" />
+  <browser:page name="approve"          attribute="action" />
 
-<!-- JobList -->
-<zmi:factoryFromClass name="JobList"
-                      class=".JobList."
-                      permission_id="Zope.ManageContent"
-                      title="JobList"
-                      description="A Job Board" />
-
-<security:protectClass
-         class=".JobList."
-         permission_id="Zope.Public"
-/>
-
-<!-- Job -->
-
-<!-- ideally jobs would be created within a placeful factory, only to
-be within a JobList; that is not an option now, so "Job" will be
-available everywhere at the moment. Note the marker_interface is the
-only new animal here. -->
-
-<zmi:factoryFromClass
-        name="Job"
-        class=".Job."
-        permission_id="Zope.Public"
-        title="A job to be placed within a JobList"
-        creation_markers=".IJob.IJobCreator." 
-/>
-
-<security:protectClass
-        class=".Job."
-        permission_id="Zope.Public"
-/>
-
-
-<!-- *** Views *** -->
-
-<!-- pre-creation job view -->
-
-<browser:defaultView
-    for=".IJob.IJobCreator"
-    name="create"
-    factory=".JobView.CreateJobView"
-/>
-
-<security:protectClass
-        class=".JobView.CreateJobView"
-        permission_id="Zope.Public"
-        names="index, action, preview, cancel"
-/>
-
-<!-- JobListTraverser -->
-
-<!-- Declaring the custom traverser as a view is a bit of a hack -->
-
-<browser:view
-        for=".IJobList."
-        name="_traverse"
-        factory=".JobListView.JobListTraverser"
-/>
-
-<!-- JobListSummaryView -->
-
-<browser:defaultView
-        for=".IJobList."
-        name="summary"
-        factory=".JobListView.JobListSummaryView"
-/>
-
-<security:protectClass
-        class=".JobListView.JobListSummaryView"
-        permission_id="Zope.Public"
-        names="index, getApprovedJobs"
-/>
-
-<!-- JobView -->
-
-<browser:view
-        for=".IJob."
-        name="JobView"
-        factory=".JobView."
-/>
-
-<browser:defaultView
-        for=".IJob."
-        name="display"
-        factory=".JobView."
-/>
-
-<security:protectClass
-        class=".JobView."
-        permission_id="Zope.View"
-        names="index, getSubmitter, getSummary, getDescription, getContact"
-/>
-
-<!-- JobEditView -->
-
-<browser:view
-        for=".IJob."
-        name="edit"
-        factory=".JobView.JobEditView"
-/>
-
-<security:protectClass
-        class=".JobView.JobEditView"
-        permission_id="Zope.Public"
-        names="index, preview, cancel, edit, submit"
-/>
-
-
-<!-- *** Actions *** -->
-
-<!-- ApproveJobs -->
-
-<browser:view
-        for=".IJobList."
-        name="ApproveJobs"
-        factory=".ApproveJobs."
-/>
-
-<security:protectClass
-        class=".ApproveJobs."
-        permission_id="Zope.View"
-        names="index, back, submit, getPendingJobs"
-/>
+</browser:view>
 
 </zopeConfigure>


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


=== Packages/JobBoardEx/JobView.pt 1.7 => 1.8 ===
 <body>
 
-    <form action=".." method="get">
-
         <table border=0>
-        <tr><td>Submitter:</td>
-            <td tal:content="view/getSubmitter">aperson@dom.ain</td>
-        </tr>
         <tr><td>Summary:</td>
-            <td tal:content="view/getSummary">The best job on the net</td>
-        </tr>
-        <tr><td>Description:</td>
-            <td tal:content="view/getDescription">This is really really
-                    really the best job on the Internet</td>
-        </tr>
-        <tr><td>Contact:</td>
-            <td tal:content="view/getContact">bperson@dom.ain</td>
+            <td tal:content="context/summary">The best job on the net</td>
         </tr>
         </table>
 
     <table border=0>
         <tr><td>
-        <input type="submit" value="Back to summary">
+        <a href="..">Back to jobs</a>
         </td></tr>
     </table>
-    </form>    
 
 </body>
 </html>

=== Removed File Packages/JobBoardEx/ApproveJobs.py ===

=== Removed File Packages/JobBoardEx/JobEditView.pt ===

=== Removed File Packages/JobBoardEx/JobListView.py ===

=== Removed File Packages/JobBoardEx/JobPreviewView.pt ===

=== Removed File Packages/JobBoardEx/JobView.py ===

=== Removed File Packages/JobBoardEx/Tutorial.html ===

=== Removed File Packages/JobBoardEx/add_confirmed.pt ===