Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. ============
  2. Contributing
  3. ============
  4. Some ground rules:
  5. * To avoid disappointment, new features should be discussed on the mailing list
  6. (django-oscar@googlegroups.com) before serious work starts.
  7. * Write tests! Pull requests will be rejected if sufficient tests aren't
  8. provided. See the guidance below on the testing conventions that oscar uses
  9. * Write docs! Please update the documentation when altering behaviour or introducing new features.
  10. * Write good commit messages: see `Tim Pope's excellent note`_.
  11. .. _`Tim Pope's excellent note`: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
  12. * Make pull requests against Oscar's master branch unless instructed otherwise.
  13. Installation
  14. ============
  15. After forking, run::
  16. git clone git@github.com:<username>/django-oscar.git
  17. cd django-oscar
  18. mkvirtualenv oscar # optional but recommended
  19. make install
  20. Running tests
  21. =============
  22. Oscar uses a nose_ testrunner which can be invoked using::
  23. ./runtests.py
  24. .. _nose: http://nose.readthedocs.org/en/latest/
  25. To run a subset of tests, you can use filesystem or module paths. These two
  26. commands will run the same set of tests::
  27. ./runtests.py tests/unit/order
  28. ./runtests.py tests.unit.order
  29. To run an individual test class use one of::
  30. ./runtests.py tests/unit/order:TestSuccessfulOrderCreation
  31. ./runtests.py tests.unit.order:TestSuccessfulOrderCreation
  32. (Note the ':'.)
  33. To run an individual test, use one of::
  34. ./runtests.py tests/unit/order:TestSuccessfulOrderCreation.test_creates_order_and_line_models
  35. ./runtests.py tests.unit.order:TestSuccessfulOrderCreation.test_creates_order_and_line_models
  36. Oscar's testrunner uses the progressive_ plugin when running all tests, but uses
  37. the spec_ plugin when running a subset. It is a good practice to name your test
  38. cases and methods so that the spec output reads well. For example::
  39. $ ./runtests.py tests/unit/offer/benefit_tests.py:TestAbsoluteDiscount
  40. nosetests --verbosity 1 tests/unit/offer/benefit_tests.py:TestAbsoluteDiscount -s -x --with-spec
  41. Creating test database for alias 'default'...
  42. Absolute discount
  43. - consumes all lines for multi item basket cheaper than threshold
  44. - consumes all products for heterogeneous basket
  45. - consumes correct quantity for multi item basket more expensive than threshold
  46. - correctly discounts line
  47. - discount is applied to lines
  48. - gives correct discount for multi item basket cheaper than threshold
  49. - gives correct discount for multi item basket more expensive than threshold
  50. - gives correct discount for multi item basket with max affected items set
  51. - gives correct discount for single item basket cheaper than threshold
  52. - gives correct discount for single item basket equal to threshold
  53. - gives correct discount for single item basket more expensive than threshold
  54. - gives correct discounts when applied multiple times
  55. - gives correct discounts when applied multiple times with condition
  56. - gives no discount for a non discountable product
  57. - gives no discount for an empty basket
  58. ----------------------------------------------------------------------
  59. Ran 15 tests in 0.295s
  60. .. _progressive: http://pypi.python.org/pypi/nose-progressive/
  61. .. _spec: http://darcs.idyll.org/~t/projects/pinocchio/doc/#spec-generate-test-description-from-test-class-method-names
  62. Playing in the sandbox
  63. ======================
  64. Oscar ships with a 'sandbox' site which can be run locally to play around with
  65. Oscar using a browser. Set it up by::
  66. make sandbox
  67. cd sites/sandbox
  68. ./manage.py runserver
  69. This will create the database and load some fixtures for categories and shipping
  70. countries.
  71. Writing docs
  72. ============
  73. There's a helper script for building the docs locally::
  74. cd docs
  75. ./test_docs.sh
  76. Conventions
  77. ===========
  78. General
  79. -------
  80. * PEP8 everywhere while remaining sensible
  81. URLs
  82. ----
  83. * List pages should use plurals, eg ``/products/``, ``/notifications/``
  84. * Detail pages should simply be a PK/slug on top of the list page, eg
  85. ``/products/the-bible/``, ``/notifications/1/``
  86. * Create pages should have 'create' as the final path segment, eg
  87. ``/dashboard/notifications/create/``
  88. * Update pages are sometimes the same as detail pages (ie when in the
  89. dashboard). In those cases, just use the detail convention, eg
  90. ``/dashboard/notifications/3/``. If there is a distinction between the detail
  91. page and the update page, use ``/dashboard/notifications/3/update/``.
  92. * Delete pages, eg ``/dashboard/notifications/3/delete/``
  93. View class names
  94. ----------------
  95. Classes should be named according to::
  96. '%s%sView' % (class_name, verb)
  97. For example, ``ProductUpdateView``, ``OfferCreateView`` and
  98. ``PromotionDeleteView``. This doesn't fit all situations but it's a good basis.