Changeset 464 in main


Ignore:
Timestamp:
11/10/11 10:20:23 (8 years ago)
Author:
pcosquer
Message:

doc: update 'how-to add a new model (application)'

Location:
trunk/docs
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/Makefile

    r329 r464  
    3737        -rm -rf $(BUILDDIR)/* 
    3838 
    39 html: 
     39tuto: 
     40        cd code && tar -pczf bicycle.tar.gz bicycle/*.py && cd ..  
     41 
     42html: tuto 
    4043        $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 
    4144        @echo 
    4245        @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 
    4346 
    44 dirhtml: 
     47dirhtml: tuto 
    4548        $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 
    4649        @echo 
    4750        @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 
    4851 
    49 singlehtml: 
     52singlehtml: tuto 
    5053        $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 
    5154        @echo 
    5255        @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 
    5356 
    54 pickle: 
     57pickle: tuto 
    5558        $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 
    5659        @echo 
    5760        @echo "Build finished; now you can process the pickle files." 
    5861 
    59 json: 
     62json: tuto 
    6063        $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 
    6164        @echo 
    6265        @echo "Build finished; now you can process the JSON files." 
    6366 
    64 htmlhelp: 
     67htmlhelp: tuto 
    6568        $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 
    6669        @echo 
     
    6871              ".hhp project file in $(BUILDDIR)/htmlhelp." 
    6972 
    70 qthelp: 
     73qthelp: tuto 
    7174        $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 
    7275        @echo 
     
    7780        @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/test.qhc" 
    7881 
    79 devhelp: 
     82devhelp: tuto 
    8083        $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 
    8184        @echo 
     
    8689        @echo "# devhelp" 
    8790 
    88 epub: 
     91epub: tuto 
    8992        $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 
    9093        @echo 
    9194        @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 
    9295 
    93 latex: 
     96latex: tuto 
    9497        $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 
    9598        @echo 
     
    104107        @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 
    105108 
    106 text: 
     109text: tuto 
    107110        $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 
    108111        @echo 
    109112        @echo "Build finished. The text files are in $(BUILDDIR)/text." 
    110113 
    111 man: 
     114man: tuto 
    112115        $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 
    113116        @echo 
  • trunk/docs/_build

    • Property svn:ignore set to
      *
  • trunk/docs/code

    • Property svn:ignore set to
      bicycle.tar.gz
  • trunk/docs/code/bicycle/tests.py

    r210 r464  
    11from openPLM.plmapp.tests.controllers import PartControllerTest 
    2 from openPLM.plmapp.tests.views import ViewTest 
     2from openPLM.plmapp.tests.views import PartViewTestCase 
    33 
    44from openPLM.bicycle.models import BicycleController 
     
    1010 
    1111 
    12 class BicycleViewTest(ViewTest): 
     12class BicycleViewTestCase(PartViewTestCase): 
    1313    TYPE = "Bicycle" 
    1414    DATA = {"nb_wheels" : 2, 
  • trunk/docs/code/bicycle/views.py

    r322 r464  
    1 from django.shortcuts import render_to_response 
    2 from django.template import RequestContext 
    3  
    41import openPLM.plmapp.views as pviews 
    52 
     
    85    """ Manage html page for attributes """ 
    96    obj_type = "Bicycle" 
    10     obj, ctx, request_dict = pviews.get_generic_data(request, obj_type, obj_ref, obj_revi) 
     7    obj, ctx = pviews.get_generic_data(request, obj_type, obj_ref, obj_revi) 
    118    object_attributes = [] 
    129    for attr in obj.attributes: 
     
    1512    ctx.update({'current_page':'attributes',  
    1613                'object_attributes': object_attributes}) 
    17     request.session.update(request_dict) 
    18     return render_to_response('DisplayObject.htm', ctx, 
    19                               context_instance=RequestContext(request)) 
     14    return pviews.r2r('DisplayObject.htm', ctx, request) 
    2015 
  • trunk/docs/ht_3_add_models2.rst

    r257 r464  
    1313         
    1414        #. copy openPLM's directory in another place 
    15         #. use the :file:`settings.py.sqlite` as settings file (rename it 
    16            :file:`settings.py`) 
    17         #. run :command:`./manage.py sql all` 
    18         #. run :command:`./manage.py syncdb` (this should ask you if you want to  
     15        #. change your settings: use a sqlite3 database (the file 
     16           :file:`settings_tests.py` is a good candidate for a settings file) 
     17        #. checks that your settings do not conflict with another installation 
     18           of openPLM (:const:`~settings.DOCUMENTS_DIR`, etc.) 
     19        #. run ``./manage.py sql all`` 
     20        #. run ``./manage.py syncdb --all`` (this should ask you if you want to  
    1921           create a superuser, accept it) 
     22        #. run ``migrate --all --fake`` 
    2023        #. edit the superuser profile (model UserProfile in the plmapp section) 
    2124           and set him as an administrator and a contributor 
     
    4750        'django.contrib.sites', 
    4851        'django.contrib.admin', 
     52        'django.contrib.comments', 
     53        'django.contrib.humanize', 
     54        'djcelery', 
     55        'haystack', 
     56        'south', 
    4957        'openPLM.plmapp', 
    5058        # you can add your application after this line 
     
    198206    :linenos: 
    199207 
    200 syncdb 
    201 ====================== 
    202  
    203 Now you can test your model. Run the following commands: 
    204  
    205     #. :command:`manage.py sql app_name` 
    206     #. :command:`manage.py syncdb` 
    207  
    208 The last command should output:: 
    209  
    210    Installing json fixture 'initial_data' from absolute path. 
    211    Installed 10 object(s) from 1 fixture(s) 
    212  
    213 Then you can run the server with the :command:`./manage.py runserver localhost:8000`. 
     208schemamigration and migrate 
     209=========================== 
     210 
     211 
     212Then you must create a *migration* for your application. openPLM uses 
     213`South <http://south.aeracode.org/>`_ to manage migrations of database. 
     214You can also read `the South's tutorial <http://south.aeracode.org/docs/tutorial/index.html>`_. 
     215 
     216    #. ``/manage.py schemamigration app_name --initial`` 
     217 
     218        This command will create a :file:`app_name/migrations` directory. 
     219 
     220    #. ``./manage.py migrate app_name`` 
     221 
     222        This command will create the table in the database. 
     223 
     224    #. ``./manage.py rebuild_index`` 
     225         
     226        This command will rebuild the search index. 
     227 
     228Then you can run the server with ``./runserver.sh``. 
    214229Open the url http://localhost:8000/home/ and try to create a bicycle. 
     230 
    215231 
    216232 
     
    244260.. seealso:: 
    245261 
    246     mod:`controllers` and :ref:`how-to-add-a-controller` for more 
     262    :mod:`.controllers` and :ref:`how-to-add-a-controller` for more 
    247263    details about controllers. 
    248264 
     
    303319    :linenos: 
    304320 
     321Add your application to the :file:`settings_tests.py` file. 
     322 
    305323You can run the tests with the command ``./manage.py test app_name 
    306324--settings=settings_tests``. 
Note: See TracChangeset for help on using the changeset viewer.