Changeset 1425 in main for trunk


Ignore:
Timestamp:
07/11/12 12:44:25 (9 years ago)
Author:
pcosquer
Message:

views: more docs

Location:
trunk/openPLM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/views/main.py

    r1422 r1425  
    12931293def display_files(request, obj_type, obj_ref, obj_revi): 
    12941294    """ 
    1295     Manage html page which displays the files (:class:`DocumentFile`) uploaded in the selected object. 
    1296     It computes a context dictionary based on 
    1297      
    1298     .. include:: views_params.txt  
     1295    Files view. 
     1296     
     1297    That view displays files of the given document.  
     1298     
     1299    :url: :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/files/` 
     1300     
     1301    .. include:: views_params.txt 
     1302 
     1303    **Template:** 
     1304     
     1305    :file:`documents/files.html` 
     1306 
     1307    **Context:** 
     1308 
     1309    ``RequestContext`` 
     1310    
     1311    ``file_formset`` 
     1312        a formset to remove files 
     1313 
     1314    ``archive_form`` 
     1315        form to download all files in a single archive (tar, zip) 
     1316     
     1317    ``add_file_form`` 
     1318        form to add a file 
    12991319    """ 
    13001320    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) 
     
    13031323        return HttpResponseBadRequest("object must be a document") 
    13041324    if request.method == "POST": 
     1325        if request.FILES: 
     1326            # from a browser where js is disabled 
     1327            return add_file(request, obj_type, obj_ref, obj_revi) 
    13051328        formset = forms.get_file_formset(obj, request.POST) 
    13061329        if formset.is_valid(): 
     
    13171340                'deprecated_files' : obj.deprecated_files, 
    13181341                'add_file_form': add_file_form, 
    1319                 'document_type': obj_type, 
    13201342               }) 
    13211343    return r2r('documents/files.html', ctx, request) 
     
    13261348def add_file(request, obj_type, obj_ref, obj_revi): 
    13271349    """ 
    1328     Manage html page for the files (:class:`DocumentFile`) addition in the selected object. 
    1329     It computes a context dictionary based on 
    1330      
    1331     .. include:: views_params.txt  
     1350    That view displays the form to upload a file.  
     1351 
     1352    .. note:: 
     1353 
     1354        This view show a simple form (no javascript) and is here 
     1355     
     1356    :url: :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/files/add/` 
     1357     
     1358    .. include:: views_params.txt 
     1359 
     1360    **Template:** 
     1361     
     1362    :file:`documents/files_add_noscript.html` 
     1363 
     1364    **Context:** 
     1365 
     1366    ``RequestContext`` 
     1367 
     1368    ``add_file_form`` 
     1369        form to add a file 
    13321370    """ 
    13331371    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) 
     
    13461384                return HttpResponse("false:") 
    13471385        add_file_form = forms.AddFileForm() 
    1348         files = forms.get_file_formset(obj) 
    1349         ctx['files_list'] =  files 
    1350     ctx.update({ 
    1351         'add_file_form': add_file_form,  
    1352         'document_type': obj_type, 
    1353     }) 
     1386    ctx['add_file_form'] = add_file_form  
    13541387    return r2r('documents/files_add_noscript.html', ctx, request) 
    13551388 
     
    14041437def replace_management(request, obj_type, obj_ref, obj_revi, link_id): 
    14051438    """ 
    1406     Manage html page for the modification of the Users who manage the selected object (:class:`PLMObjectUserLink`). 
    1407     It computes a context dictionary based on 
    1408      
    1409     .. include:: views_params.txt  
    1410     :param link_id: :attr:`.PLMObjectUserLink.id` 
    1411     :type link_id: str 
     1439    View to replace a manager (owner, signer, reader...) by another one. 
     1440 
     1441    :url: :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/management/replace/{link_id}/` 
     1442     
     1443    .. include:: views_params.txt 
     1444    :param link_id: id of the :class:`.PLMObjectUserLink` being replaced 
     1445 
     1446    **Template:** 
     1447     
     1448    :file:`management_replace.html` 
     1449 
     1450    **Context:** 
     1451 
     1452    ``RequestContext`` 
     1453    
     1454    ``replace_manager_form`` 
     1455        a form to select the new manager (an user) 
     1456 
     1457    ``link_creation`` 
     1458        Set to True 
     1459 
     1460    ``role`` 
     1461        role of the link being replace 
     1462 
     1463    ``attach`` 
     1464        set to (*obj*, "delegate") or (*obj*, "delegate-reader*) according to 
     1465        the role of the link 
    14121466    """ 
    14131467    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) 
     
    14171471     
    14181472    if request.method == "POST": 
    1419         replace_management_form = forms.SelectUserForm(request.POST) 
    1420         if replace_management_form.is_valid(): 
    1421             if replace_management_form.cleaned_data["type"] == "User": 
    1422                 user_obj = get_obj_from_form(replace_management_form, request.user) 
     1473        replace_manager_form = forms.SelectUserForm(request.POST) 
     1474        if replace_manager_form.is_valid(): 
     1475            if replace_manager_form.cleaned_data["type"] == "User": 
     1476                user_obj = get_obj_from_form(replace_manager_form, request.user) 
    14231477                obj.set_role(user_obj.object, link.role) 
    14241478                if link.role == models.ROLE_NOTIFIED: 
     
    14281482            return HttpResponseRedirect("../../../lifecycle/") 
    14291483    else: 
    1430         replace_management_form = forms.SelectUserForm() 
     1484        replace_manager_form = forms.SelectUserForm() 
    14311485     
    14321486    ctx.update({'current_page':'lifecycle',  
    1433                 'replace_management_form': replace_management_form, 
     1487                'replace_manager_form': replace_manager_form, 
    14341488                'link_creation': True, 
     1489                'role' : link.role, 
    14351490                'attach' : (obj, "delegate-reader" if link.role == models.ROLE_READER else "delegate")}) 
    14361491    return r2r('management_replace.html', ctx, request) 
     
    14401495def add_management(request, obj_type, obj_ref, obj_revi, reader=False): 
    14411496    """ 
    1442     Manage html page for the addition of a "notification" link 
    1443     (:class:`PLMObjectUserLink`) between some Users and the selected object.  
    1444     It computes a context dictionary based on 
    1445      
    1446     .. include:: views_params.txt  
     1497    View to add a manager (notified user or restricted reader). 
     1498 
     1499    :url: :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/management/add/` 
     1500    or  
     1501    :url: :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/management/add-reader/` 
     1502 
     1503    .. include:: views_params.txt 
     1504    :param reader: True to add a restricted reader instead of a notified user 
     1505 
     1506    **Template:** 
     1507     
     1508    :file:`management_replace.html` 
     1509 
     1510    **Context:** 
     1511 
     1512    ``RequestContext`` 
     1513    
     1514    ``replace_manager_form`` 
     1515        a form to select the new manager (an user) 
     1516 
     1517    ``link_creation`` 
     1518        Set to True 
     1519 
     1520    ``role`` 
     1521        role of the new user (:const:`.ROLE_NOTIFIED` or :const:`.ROLE_READER`) 
     1522 
     1523    ``attach`` 
     1524        set to (*obj*, "delegate") or (*obj*, "delegate-reader*) according to 
     1525        *reader* 
     1526 
    14471527    """ 
    14481528    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) 
    1449      
     1529    role =  models.ROLE_READER if reader else models.ROLE_NOTIFIED 
    14501530    if request.method == "POST": 
    14511531        add_management_form = forms.SelectUserForm(request.POST) 
     
    14531533            if add_management_form.cleaned_data["type"] == "User": 
    14541534                user_obj = get_obj_from_form(add_management_form, request.user) 
    1455                 obj.set_role(user_obj.object, models.ROLE_READER if reader else models.ROLE_NOTIFIED) 
     1535                obj.set_role(user_obj.object, role) 
    14561536            return HttpResponseRedirect("../../lifecycle/") 
    14571537    else: 
     
    14591539     
    14601540    ctx.update({'current_page':'lifecycle',  
    1461                 'replace_management_form': add_management_form, 
     1541                'replace_manager_form': add_management_form, 
    14621542                'link_creation': True, 
     1543                'role' : role, 
    14631544                "attach" : (obj, "delegate-reader" if reader else "delegate")}) 
    14641545    return r2r('management_replace.html', ctx, request) 
     
    14681549def delete_management(request, obj_type, obj_ref, obj_revi): 
    14691550    """ 
    1470     Manage html page for the deletion of a "notification" link (:class:`PLMObjectUserLink`) between some Users and the selected object. 
    1471     It computes a context dictionary based on 
    1472      
    1473     .. include:: views_params.txt  
     1551    View to remove a notified user or a restricted user. 
     1552 
     1553    :url: :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/management/delete/` 
     1554 
     1555    The request must be a POST request containing the key ``link_id``. 
     1556    It should be the id of one of the :class:`.PLMObjectUserLink` related to 
     1557    the object. 
     1558    The role of this link must be :const:`.ROLE_NOTIFIED` or :class:`.ROLE_READER`. 
     1559 
     1560    Redirects to :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/management/lifecycle/` 
     1561    in case of a success. 
    14741562    """ 
    14751563    obj = get_obj(obj_type, obj_ref, obj_revi, request.user) 
     
    19132001     
    19142002    ctx.update({'current_page':'delegation', 
    1915                 'replace_management_form': delegation_form, 
     2003                'replace_manager_form': delegation_form, 
    19162004                'link_creation': True, 
    19172005                'attach' : (obj, "delegate"), 
  • trunk/openPLM/templates/documents/files_add.html

    r1408 r1425  
    3030        {% endfor %} 
    3131    {% endwith %} 
    32     doc_type="{{document_type}}"; 
     32    doc_type="{{object_type}}"; 
    3333    trans["Select at least one file"]="{% trans 'Select at least one file' %}"; 
    3434    trans["A STEP file is already linked to this document."]="{% trans 'A STEP file is already linked to this document.' %}"; 
  • trunk/openPLM/templates/documents/files_add_noscript.html

    r1124 r1425  
    77 
    88{% block content %} 
    9 {% include "documents/files_add.html" %} 
     9    {% with add_file_form as form %} 
     10        {% include "snippets/undo_form.html" %} 
     11    {% endwith %} 
    1012{% endblock %} 
  • trunk/openPLM/templates/management_replace.html

    r808 r1425  
    66{% block content %} 
    77    {% trans "Select a user for your delegation as : " %}{{role}} 
    8     {% with replace_management_form as form %} 
     8    {% with replace_manager_form as form %} 
    99        {% include "snippets/undo_form.html" %} 
    1010    {% endwith %} 
Note: See TracChangeset for help on using the changeset viewer.