~anubhav929/sahana-eden/websetup

« back to all changes in this revision

Viewing changes to controllers/inv.py

  • Committer: Fran Boon
  • Date: 2011-03-26 15:41:31 UTC
  • mfrom: (1612.1.96 eden)
  • Revision ID: fran@aidiq.com-20110326154131-wvoa7xyo3rip11zh
merge michael: Improved error messages for shn_site_based_permissions & separate inv & req menus; Make Modules less intertwined: Tabs/Menus appended optionally, remove HMS FK from CR

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
module = request.controller
13
13
resourcename = request.function
14
14
 
 
15
if not deployment_settings.has_module(module):
 
16
    session.error = T("Module disabled!")
 
17
    redirect(URL(r=request, c="default", f="index"))
 
18
 
15
19
response.menu_options = inv_menu
16
20
 
17
 
NO_PERM_RECV_SHIPMENT = T("You do not have permission to receive a shipment.")
18
 
NO_PERM_SEND_SHIPMENT = T("You do not have permission to send a shipment.")
19
 
 
20
21
def index():
21
22
    """
22
23
        Application Home page
76
77
 
77
78
        # Filter out people which are already staff for this warehouse
78
79
        shn_staff_prep(r) 
79
 
        # Filter out items which are already in this inventory
80
 
        shn_inv_prep(r)
 
80
        if deployment_settings.has_module("inv"):
 
81
            # Filter out items which are already in this inventory
 
82
            shn_inv_prep(r)
81
83
          
82
84
        # Cascade the organisation_id from the Warehouse to the staff
83
85
        if r.record:
118
120
    
119
121
    # Limit site_id to sites the user has permissions for
120
122
    shn_site_based_permissions(table,
121
 
                               NO_PERM_RECV_SHIPMENT )
 
123
                               T("You do not have permission for any site to add an inventory item."))
122
124
 
123
125
    return s3_rest_controller(module, resourcename)
124
126
#------------------------------------------------------------------------------
147
149
 
148
150
    # Limit site_id to sites the user has permissions for
149
151
    shn_site_based_permissions(table,
150
 
                               NO_PERM_RECV_SHIPMENT )
 
152
                               T("You do not have permission for any site to receive a shipment."))
151
153
 
152
154
    output = s3_rest_controller(module,
153
155
                                resourcename,
296
298
    
297
299
    # Limit site_id to sites the user has permissions for
298
300
    shn_site_based_permissions(table,
299
 
                               NO_PERM_SEND_SHIPMENT )
 
301
                               T("You do not have permission for any site to send a shipment.") )
300
302
    
301
303
    # Set Validator for checking against the number of items in the warehouse
302
304
    if (request.vars.inv_item_id):
1035
1037
        function to send items according to a commit.
1036
1038
        copy data from a commit into a send 
1037
1039
        arg: req_id
 
1040
        @ToDo: This function needs to be able to detect the site to send the items from,
 
1041
        site_id is currently undefined and this will not work.
1038
1042
    """    
1039
1043
    
1040
1044
    commit_id = request.args[0]
1045
1049
    if not auth.s3_has_permission("update", 
1046
1050
                                  db["%s_%s" % (prefix, resourcename)], 
1047
1051
                                  record_id=id):    
1048
 
        session.error = NO_PERM_SEND_SHIPMENT   
 
1052
        session.error = T("You do not have permission to send a shipment from this site.")   
1049
1053
        redirect(URL(r = request,
1050
1054
                     c = "req",
1051
1055
                     f = "commit",