summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 7dc0108393..89c02d41ab 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1768,17 +1768,42 @@ def managedcontextprocessor(request):
1768# a default "page not available" simple functions for interactive mode 1768# a default "page not available" simple functions for interactive mode
1769if toastermain.settings.MANAGED: 1769if toastermain.settings.MANAGED:
1770 1770
1771 from django.contrib.auth.models import User
1772 from django.contrib.auth import authenticate, login
1773 from django.contrib.auth.decorators import login_required
1774
1775
1771 # new project 1776 # new project
1772 def newproject(request): 1777 def newproject(request):
1773 template = "newproject.html" 1778 template = "newproject.html"
1774 context = {} 1779 context = {
1780 'email': request.user.email if request.user.is_authenticated() else '',
1781 'username': request.user.username if request.user.is_authenticated() else '',
1782 }
1783
1784
1775 if request.method == "GET": 1785 if request.method == "GET":
1776 # render new project page 1786 # render new project page
1777 return render(request, template, context) 1787 return render(request, template, context)
1778 elif request.method == "POST": 1788 elif request.method == "POST":
1779 if request.method: 1789 mandatory_fields = ['projectname', 'email', 'username', 'projectversion']
1790 if reduce( lambda x, y: x and y, map(lambda x: x in request.POST and len(request.POST[x]) > 0, mandatory_fields)):
1791 if not request.user.is_authenticated():
1792 user = authenticate(username = request.POST['username'], password = 'nopass')
1793 if user is None:
1794 user = User.objects.create_user(username = request.POST['username'], email = request.POST['email'], password = "nopass")
1795 raise Exception("User cannot be authed, creating")
1796 user = authenticate(username = request.POST['username'], password = '')
1797 login(request, user)
1798
1780 return redirect(project) 1799 return redirect(project)
1781 else: 1800 else:
1801 alerts = []
1802 # set alerts for missing fields
1803 map(lambda x: alerts.append('Field '+ x + ' not filled in') if not x in request.POST or len(request.POST[x]) == 0 else None, mandatory_fields)
1804 # fill in new page with already submitted values
1805 map(lambda x: context.__setitem__(x, request.POST[x]), mandatory_fields)
1806 context['alerts'] = alerts
1782 return render(request, template, context) 1807 return render(request, template, context)
1783 raise Exception("Invalid HTTP method for this page") 1808 raise Exception("Invalid HTTP method for this page")
1784 1809