Send notification if error occurs

Use Django error reporting feature, Django will email the users
listed in the ADMINS setting whenever your code raises an unhandled
exception, just requires a few settings:
    https://docs.djangoproject.com/en/1.6/howto/error-reporting/

Fixes: #2014

Change-Id: I336e451c1ad475b05c23f6869eedf7ff3cd7124c
Signed-off-by: gaoxuesx <xuesongx.gao@intel.com>
Dont cache template in develpment settings.

Reset TEAMPLTE_LOADERS to default value in development settings.

https://docs.djangoproject.com/en/1.6/ref/settings/#template-loaders

Otherwise it's very annoy that we have to restart server everytime
when template code is changed.

However we keep the cached settings in production env.

Change-Id: I2ed7b07cad6a6f4f9fd808342a95067287bab375
Fixes: #2078
Revise models for submissions.

Problems about current models:

* Submission has a commit field but many git trees. It’s wrong.
* Submission has many git trees and many submitters, but without
  information about which submitter submit to which git tree.
* Same as package builds and git trees, there are both many to
  many fields. Lack of information about which package build
  belongs to which git tree.
* SubmissionGroup is a group of Submissions. But in actually, we
  have two levels of groups. Submission Group and Build Group.
  Submission Group is the interface to users, users use a same tag
  as a group identifier. However Build Group is a implementation
  detail, Jenkins scripts and Repa don’t group user’s submissions,
  they group OBS packages into OBS projects which I named it
  Build Group. Build Group is the actual minimal unit of submission
  to target project. And for different Build Group it may have
  different status. If a Build Group to Tizen:IVI had been accepted
  but a build Group for Tizen:Common has been rejected. We can’t
  simply say a submission group was accepted or was rejected.
* Submission has a product field and SubmissionGroup also has a
  product field. They can be inconsistent.

So I changed some fields and add two new models:

* SubmissionBuild which represent a build of a git tree against a
  product. So it has a product field.
* BuildGroup which represent a group of builds with the same product.
  It can be a group created by Jenkins script using a same tag name
  or by Repa to just group two OBS projects as need.

I can add a another model named SubmissionGroup to include multiple
Submissions, but when I added I found the only common part of a
group submissions is their tag name. It’s not very useful to add
that model then I removed. It’s very difficult to give status name
to a submission group, for example, some packages in Tizen:IVI
built failed, but for Tizen:Common it had been accepted.

Since models changed, it's hard to keep the old unit tests pass.
So comment some tests, when we implement those features by using
the new models, I will change it back.

Change-Id: I8b3cbbe8701031dce861ff9e9c8f4176964456ab
Fixes: #1694
Add api view to consume "submitted" event.

All RESTful APIs for Jenkins scripts to publish submissions
events to IRIS should follow steps as follows:
- requires POST method
- requires certain permission
- validate fields in POST
- group database operations in the view into a transaction
- encode output to json

APIView in rest_framework can be used to implement these
RESTful view functions.

Also add test cases for this API.

Change-Id: I8115a83ace3ecbb232e346617a11207f661d4f10
Add event "pre_created" restful api.

This event occurs when a pre-release project was created.

It includes information about the submittion tag and corresponding
target product and the OBS project name created.

Also add several test cases for this api.

Change-Id: Iefc1262ac6f69ae4f86aaa7be7c9e6d61796b26c
Add APIs for image_building and image_created

image_building event occurs when a image starts to build. It
contains fields of image name and the pre-release project which
trigger this image building.

image_created occurs when a image had been created, either
succeed or failed. It contains fields of status, name, project,
url and log.

Change-Id: I34334919656a1efd999ed952a3f85bf7f772c835
Add API for event "repa_action"

This event happens when RE accepts or rejects some submission
with repa. It contains information like who, when, project,
status and the reason.

Change-Id: Ib4be1d15013f5fb75bb369b7c09a0721c314498b
Add API for event package_built

This event happens when a package was built, either succeeded or
failed. It contains information like package name, repo, arch
live repo url, build log url.

Change-Id: Ib781d8a8da48e285c23094bf9a5d2e258ae7f733
Modify submission summary and detail pages.

Change the views and templates to adopt new models.

Change-Id: I7b002527f924af734a13fd6fd7be468395c47da3
Fixes bug in merge_user()

Add try except block to handle DoesNotExist exception.

Fixes: #2080

Change-Id: Ifc744250a049fbe1dcddb1ee6e2c69ff02a04d1f
Signed-off-by: gaoxuesx <xuesongx.gao@intel.com>