Changeset 1025 in main


Ignore:
Timestamp:
04/24/12 11:52:18 (7 years ago)
Author:
pcosquer
Message:

views.main: replaces from spam import * with a import spam ... spam.egg

File:
1 edited

Legend:

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

    r996 r1025  
    5555from collections import defaultdict 
    5656 
     57from django.conf import settings 
    5758from django.shortcuts import render_to_response 
    5859from django.http import HttpResponseRedirect, HttpResponse,\ 
     
    6768from django.views.i18n import set_language as dj_set_language 
    6869from django.contrib import messages 
     70from django.contrib.auth.models import User 
    6971 
    7072from haystack.views import SearchView 
     
    7577from openPLM.plmapp.controllers import get_controller  
    7678from openPLM.plmapp.utils import level_to_sign_str, get_next_revision 
    77 from openPLM.plmapp.forms import * 
    7879import openPLM.plmapp.forms as forms 
    7980from openPLM.plmapp.decomposers.base import DecomposersManager 
     
    275276        
    276277        if request.method == "POST" and request.POST: 
    277             add_form = AddRevisionForm(request.POST) 
     278            add_form = forms.AddRevisionForm(request.POST) 
    278279            selected_parts = [] 
    279280            valid_forms = True 
     
    298299                return HttpResponseRedirect(".") 
    299300        else: 
    300             add_form = AddRevisionForm({"revision" : get_next_revision(obj.revision)}) 
     301            add_form = forms.AddRevisionForm({"revision" : get_next_revision(obj.revision)}) 
    301302            if confirmation: 
    302303                ctx["part_formset"] = forms.SelectPartFormset(queryset=parts) 
     
    320321 
    321322        if request.method == "POST" and request.POST: 
    322             add_form = AddRevisionForm(request.POST) 
     323            add_form = forms.AddRevisionForm(request.POST) 
    323324            valid_forms = True 
    324325            selected_children = [] 
     
    373374                return HttpResponseRedirect(".") 
    374375        else: 
    375             add_form = AddRevisionForm({"revision" : get_next_revision(obj.revision)}) 
     376            add_form = forms.AddRevisionForm({"revision" : get_next_revision(obj.revision)}) 
    376377            if confirmation: 
    377378                initial = [dict(link=link) for link in children] 
     
    438439    state = "all" 
    439440    if request.GET: 
    440         display_form = DisplayChildrenForm(request.GET) 
     441        display_form = forms.DisplayChildrenForm(request.GET) 
    441442        if display_form.is_valid(): 
    442443            date = display_form.cleaned_data["date"] 
     
    444445            state = display_form.cleaned_data["state"] 
    445446    else: 
    446         display_form = DisplayChildrenForm(initial={"date" : datetime.datetime.now(), 
     447        display_form = forms.DisplayChildrenForm(initial={"date" : datetime.datetime.now(), 
    447448            "level" : "first", "state":"all"}) 
    448449    max_level = 1 if level == "first" else -1 
     
    499500        raise TypeError() 
    500501    if request.method == "POST": 
    501         formset = get_children_formset(obj, request.POST) 
     502        formset = forms.get_children_formset(obj, request.POST) 
    502503        if formset.is_valid(): 
    503504            obj.update_children(formset) 
    504505            return HttpResponseRedirect("..") 
    505506    else: 
    506         formset = get_children_formset(obj) 
     507        formset = forms.get_children_formset(obj) 
    507508    extra_columns = [] 
    508509    extra_fields = [] 
     
    532533     
    533534    if request.POST: 
    534         add_child_form = AddChildForm(obj.object, request.POST) 
     535        add_child_form = forms.AddChildForm(obj.object, request.POST) 
    535536        if add_child_form.is_valid(): 
    536537            child_obj = get_obj_from_form(add_child_form, request.user) 
     
    542543            return HttpResponseRedirect(obj.plmobject_url + "BOM-child/")  
    543544    else: 
    544         add_child_form = AddChildForm(obj.object) 
     545        add_child_form = forms.AddChildForm(obj.object) 
    545546        ctx['current_page'] = 'BOM-child' 
    546547    ctx.update({'link_creation': True, 
     
    567568    state = "all" 
    568569    if request.GET: 
    569         display_form = DisplayChildrenForm(request.GET) 
     570        display_form = forms.DisplayChildrenForm(request.GET) 
    570571        if display_form.is_valid(): 
    571572            date = display_form.cleaned_data["date"] 
     
    573574            state = display_form.cleaned_data["state"] 
    574575    else: 
    575         display_form = DisplayChildrenForm(initial={"date" : datetime.datetime.now(), 
     576        display_form = forms.DisplayChildrenForm(initial={"date" : datetime.datetime.now(), 
    576577            "level" : "first", "state" : "all"}) 
    577578    max_level = 1 if level == "first" else -1 
     
    602603        raise TypeError() 
    603604    if request.method == "POST": 
    604         formset = get_doc_cad_formset(obj, request.POST) 
     605        formset = forms.get_doc_cad_formset(obj, request.POST) 
    605606        if formset.is_valid(): 
    606607            obj.update_doc_cad(formset) 
    607608            return HttpResponseRedirect(".") 
    608609    else: 
    609         formset = get_doc_cad_formset(obj) 
     610        formset = forms.get_doc_cad_formset(obj) 
    610611    dforms = dict((form.instance.id, form) for form in formset.forms) 
    611612    archive_form = forms.ArchiveForm() 
     
    630631     
    631632    if request.POST: 
    632         add_doc_cad_form = AddDocCadForm(request.POST) 
     633        add_doc_cad_form = forms.AddDocCadForm(request.POST) 
    633634        if add_doc_cad_form.is_valid(): 
    634635            doc_cad_obj = get_obj_from_form(add_doc_cad_form, request.user) 
     
    636637            return HttpResponseRedirect(obj.plmobject_url + "doc-cad/") 
    637638    else: 
    638         add_doc_cad_form = AddDocCadForm() 
     639        add_doc_cad_form = forms.AddDocCadForm() 
    639640    ctx.update({'link_creation': True, 
    640641                'add_doc_cad_form': add_doc_cad_form, 
     
    659660        raise TypeError() 
    660661    if request.method == "POST": 
    661         formset = get_rel_part_formset(obj, request.POST) 
     662        formset = forms.get_rel_part_formset(obj, request.POST) 
    662663        if formset.is_valid(): 
    663664            obj.update_rel_part(formset) 
    664665            return HttpResponseRedirect(".") 
    665666    else: 
    666         formset = get_rel_part_formset(obj) 
    667     forms = dict((form.instance.id, form) for form in formset.forms) 
     667        formset = forms.get_rel_part_formset(obj) 
     668    rforms = dict((form.instance.id, form) for form in formset.forms) 
    668669 
    669670    ctx.update({'current_page':'parts',  
    670671                'all_parts': obj.get_attached_parts(), 
    671                 'forms' : forms, 
     672                'forms' : rforms, 
    672673                'parts_formset': formset}) 
    673674    return r2r('documents/parts.html', ctx, request) 
     
    685686     
    686687    if request.POST: 
    687         add_rel_part_form = AddRelPartForm(request.POST) 
     688        add_rel_part_form = forms.AddRelPartForm(request.POST) 
    688689        if add_rel_part_form.is_valid(): 
    689690            part_obj = get_obj_from_form(add_rel_part_form, request.user) 
     
    692693            return HttpResponseRedirect(obj.plmobject_url + "parts/") 
    693694    else: 
    694         add_rel_part_form = AddRelPartForm() 
     695        add_rel_part_form = forms.AddRelPartForm() 
    695696    ctx.update({'link_creation': True, 
    696697                'add_rel_part_form': add_rel_part_form, 
     
    712713        raise TypeError() 
    713714    if request.method == "POST": 
    714         formset = get_file_formset(obj, request.POST) 
     715        formset = forms.get_file_formset(obj, request.POST) 
    715716        if formset.is_valid(): 
    716717            obj.update_file(formset) 
    717718            return HttpResponseRedirect(".") 
    718719    else: 
    719         formset = get_file_formset(obj) 
     720        formset = forms.get_file_formset(obj) 
    720721 
    721722    archive_form = forms.ArchiveForm() 
     
    740741     
    741742    if request.method == "POST": 
    742         add_file_form = AddFileForm(request.POST, request.FILES) 
     743        add_file_form = forms.AddFileForm(request.POST, request.FILES) 
    743744        if add_file_form.is_valid(): 
    744745            obj.add_file(request.FILES["filename"]) 
     
    746747            return HttpResponseRedirect(obj.plmobject_url + "files/") 
    747748    else: 
    748         add_file_form = AddFileForm() 
     749        add_file_form = forms.AddFileForm() 
    749750    ctx.update({ 'add_file_form': add_file_form, }) 
    750751    return r2r('documents/files_add.html', ctx, request) 
     
    774775                        "username" : request.user.username 
    775776                      } 
    776             form = SelectUserForm(initial=initial) 
     777            form = forms.SelectUserForm(initial=initial) 
    777778            for field in ("type", "username"): 
    778779                form.fields[field].widget = HiddenInput()  
     
    800801     
    801802    if request.method == "POST": 
    802         replace_management_form = SelectUserForm(request.POST) 
     803        replace_management_form = forms.SelectUserForm(request.POST) 
    803804        if replace_management_form.is_valid(): 
    804805            if replace_management_form.cleaned_data["type"] == "User": 
     
    809810            return HttpResponseRedirect("../..") 
    810811    else: 
    811         replace_management_form = SelectUserForm() 
     812        replace_management_form = forms.SelectUserForm() 
    812813     
    813814    ctx.update({'current_page':'management',  
     
    830831     
    831832    if request.method == "POST": 
    832         add_management_form = SelectUserForm(request.POST) 
     833        add_management_form = forms.SelectUserForm(request.POST) 
    833834        if add_management_form.is_valid(): 
    834835            if add_management_form.cleaned_data["type"] == "User": 
     
    837838            return HttpResponseRedirect("..") 
    838839    else: 
    839         add_management_form = SelectUserForm() 
     840        add_management_form = forms.SelectUserForm() 
    840841     
    841842    ctx.update({'current_page':'management',  
     
    920921 
    921922    if request.method == 'GET' and creation_form is None: 
    922         creation_form = get_creation_form(request.user, cls) 
     923        creation_form = forms.get_creation_form(request.user, cls) 
    923924        if related is not None: 
    924925            creation_form.fields["group"].initial = related.group 
     
    926927    elif request.method == 'POST': 
    927928        if creation_form is None: 
    928             creation_form = get_creation_form(request.user, cls, request.POST) 
     929            creation_form = forms.get_creation_form(request.user, cls, request.POST) 
    929930        if creation_form.is_valid(): 
    930931            ctrl_cls = get_controller(type_) 
     
    966967    cls = models.get_all_plmobjects()[obj_type] 
    967968    if request.method == 'POST' and request.POST: 
    968         modification_form = get_modification_form(cls, request.POST) 
     969        modification_form = forms.get_modification_form(cls, request.POST) 
    969970        if modification_form.is_valid(): 
    970971            obj.update_from_form(modification_form) 
    971972            return HttpResponseRedirect(obj.plmobject_url + "attributes/") 
    972973    else: 
    973         modification_form = get_modification_form(cls, instance=obj.object) 
     974        modification_form = forms.get_modification_form(cls, instance=obj.object) 
    974975     
    975976    ctx['modification_form'] = modification_form 
     
    995996    class_for_div="ActiveBox4User" 
    996997    if request.method == 'POST' and request.POST: 
    997         modification_form = OpenPLMUserChangeForm(request.POST) 
     998        modification_form = forms.OpenPLMUserChangeForm(request.POST) 
    998999        if modification_form.is_valid(): 
    9991000            obj.update_from_form(modification_form) 
    10001001            return HttpResponseRedirect("/user/%s/" % obj.username) 
    10011002    else: 
    1002         modification_form = OpenPLMUserChangeForm(instance=obj.object) 
     1003        modification_form = forms.OpenPLMUserChangeForm(instance=obj.object) 
    10031004     
    10041005    ctx.update({'class4div': class_for_div, 'modification_form': modification_form}) 
     
    11071108     
    11081109    if request.method == "POST": 
    1109         delegation_form = SelectUserForm(request.POST) 
     1110        delegation_form = forms.SelectUserForm(request.POST) 
    11101111        if delegation_form.is_valid(): 
    11111112            if delegation_form.cleaned_data["type"] == "User": 
     
    11221123                        return HttpResponseRedirect("../../..") 
    11231124    else: 
    1124         delegation_form = SelectUserForm() 
     1125        delegation_form = forms.SelectUserForm() 
    11251126    if role == 'sign': 
    11261127        if sign_level.isdigit(): 
     
    11551156    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) 
    11561157    if request.POST: 
    1157         checkin_file_form = AddFileForm(request.POST, request.FILES) 
     1158        checkin_file_form = forms.AddFileForm(request.POST, request.FILES) 
    11581159        if checkin_file_form.is_valid(): 
    11591160            obj.checkin(models.DocumentFile.objects.get(id=file_id_value), 
     
    11611162            return HttpResponseRedirect(obj.plmobject_url + "files/") 
    11621163    else: 
    1163         checkin_file_form = AddFileForm() 
     1164        checkin_file_form = forms.AddFileForm() 
    11641165    ctx['add_file_form'] =  checkin_file_form 
    11651166    return r2r('documents/files_add.html', ctx, request) 
     
    13071308    obj, ctx = get_generic_data(request, "Group", obj_ref) 
    13081309    if request.method == "POST": 
    1309         form = SelectUserForm(request.POST) 
     1310        form = forms.SelectUserForm(request.POST) 
    13101311        if form.is_valid(): 
    13111312            obj.add_user(User.objects.get(username=form.cleaned_data["username"])) 
     
    13581359            return HttpResponseRedirect("..") 
    13591360    else: 
    1360         form = SponsorForm(initial={"sponsor":obj.id}, sponsor=obj.id) 
     1361        form = forms.SponsorForm(initial={"sponsor":obj.id}, sponsor=obj.id) 
    13611362    ctx["sponsor_form"] = form 
    13621363    ctx['current_page'] = 'delegation'  
     
    14431444    obj, ctx = get_generic_data(request) 
    14441445    if request.method == "POST": 
    1445         csv_form = CSVForm(request.POST, request.FILES) 
     1446        csv_form = forms.CSVForm(request.POST, request.FILES) 
    14461447        if csv_form.is_valid(): 
    14471448            f = request.FILES["file"] 
     
    14561457                                        encoding)) 
    14571458    else: 
    1458         csv_form = CSVForm() 
     1459        csv_form = forms.CSVForm() 
    14591460    ctx["csv_form"] = csv_form 
    14601461    ctx["step"] = 1 
     
    15031504    ctx["has_critical_error"] = ctx["io_error"] or ctx["encoding_error"] \ 
    15041505            or "errors" in ctx 
    1505     ctx["csv_form"] = CSVForm(initial={"encoding" : encoding}) 
     1506    ctx["csv_form"] = forms.CSVForm(initial={"encoding" : encoding}) 
    15061507    ctx["step"] = 2 
    15071508    ctx["target"] = target 
Note: See TracChangeset for help on using the changeset viewer.