Anonymous avatar Anonymous committed 8e2c1e7

Imported from svn by Bitbucket

Comments (0)

Files changed (4)

+[egg_info]
+tag_build = dev
+tag_svn_revision = true
+#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+
+from setuptools import setup
+
+setup(
+    name = 'TracSimpleTicket',
+    version = '5.0',
+    packages = ['simpleticket'],
+    author = 'Noah Kantrowitz',
+    author_email = 'noah+tracplugins@coderanger.net',
+    maintainer = 'Ryan J Ollos',
+    maintainer_email = 'ryan.j.ollos@gmail.com',
+    description = 'Restricted ticket entry form for Trac',
+    long_description = 'A Trac plugin that provides a configurable ticket entry form, with selected fields hidden from the user.',
+    license = 'BSD',
+    keywords = 'trac plugin restricted ticket',
+    url = 'http://trac-hacks.org/wiki/SimpleTicketPlugin',
+    classifiers = [
+        'Framework :: Trac',
+    ],    
+    install_requires = ['Trac'],    
+    entry_points = {
+        'trac.plugins': [
+            'simpleticket.web_ui = simpleticket.web_ui',
+        ],
+    }
+)
Add a comment to this file

simpleticket/__init__.py

Empty file added.

simpleticket/web_ui.py

+# Created by Noah Kantrowitz on 2008-03-11.
+# Copyright (c) 2008 Noah Kantrowitz. All rights reserved.
+
+from trac.config import ListOption, BoolOption
+from trac.core import *
+from trac.perm import IPermissionRequestor, PermissionSystem
+from trac.web.api import IRequestFilter
+
+class SimpleTicketModule(Component):
+    """A request filter to implement the SimpleTicket reduced ticket entry form."""
+    
+    fields = ListOption('simpleticket', 'fields', default='',
+                         doc='Fields to hide for the simple ticket entry form.')
+    
+    show_only = BoolOption('simpleticket', 'show_only', default=False,
+                           doc='If True, show only the specified fields rather than hiding the specified fields')
+
+    implements(IRequestFilter, IPermissionRequestor)
+
+    # IRequestFilter methods
+    def pre_process_request(self, req, handler):
+        return handler
+            
+    def post_process_request(self, req, template, data, content_type):
+        if req.path_info == '/newticket':
+            do_filter = 'TICKET_CREATE_SIMPLE' in req.perm and not 'TRAC_ADMIN' in req.perm            
+            
+            self.log.debug('SimpleTicket: Filtering new ticket form for %s', req.authname)
+            if do_filter:
+                if self.show_only:
+                    data['fields'] = [f for f in data['fields'] if f['name'] in self.fields and f is not None]
+                else: 
+                    data['fields'] = [f for f in data['fields'] if f['name'] not in self.fields and f is not None]
+
+        return template, data, content_type
+    # IPermissionRequestor methods
+    def get_permission_actions(self):
+        yield 'TICKET_CREATE_SIMPLE', ['TICKET_CREATE']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.