# HG changeset patch # User Madhusudan.C.S # Date 1249570236 -19800 # Node ID 294ff7ac9cb6344b4d03505145018e1a49a41252 # Parent 3e6916eb3d2c89f3c6db1216b37d41dd0df11309 Added new set of files. diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/projrev/views/helpers/access.py --- a/app/projrev/views/helpers/access.py Thu Aug 06 18:49:06 2009 +0530 +++ b/app/projrev/views/helpers/access.py Thu Aug 06 20:20:36 2009 +0530 @@ -7,21 +7,47 @@ ] -def checkAccess(func, request): +from functools import wraps + +from django.shortcuts import render_to_response +from django.template import RequestContext + + +rights = {} +rights['getMicr'] = 'proposer' + +def checkAccess(func): """ To check the access of the user and then return the appropriate function -object + object. """ - user_kind = rights[func.__name__] - if user.is_authenticated(): - if user_kind == 'staff': - if user.is_staff: - return func(request) - else: - return - - if user_kind == 'proposer': - if not user.is_staff: - return func(request) - else: - return - \ No newline at end of file + + @wraps(func) + def wrapper(request, *args, **kwargs): + """The decorator for access check. + """ + + user_kind = rights[func.__name__] + user = request.user + + template = 'projrev/error.html' + context = {} + + if user.is_authenticated(): + if user_kind == 'staff': + if user.is_staff: + return func(request, *args, **kwargs) + else: + context['not_staff'] = True + return render_to_response(template, RequestContext(request, context)) + + if user_kind == 'proposer': + if not user.is_staff: + return func(request, *args, **kwargs) + else: + context['not_proposer'] = True + return render_to_response(template, RequestContext(request, context)) + else: + context['not_authenticated'] = True + return render_to_response(template, RequestContext(request, context)) + + return wrapper \ No newline at end of file diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/projrev/views/login.py --- a/app/projrev/views/login.py Thu Aug 06 18:49:06 2009 +0530 +++ b/app/projrev/views/login.py Thu Aug 06 20:20:36 2009 +0530 @@ -9,8 +9,10 @@ from django.contrib.auth import authenticate from django.contrib.auth import login +from django.contrib.auth import logout from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.models import User +from django.core.urlresolvers import reverse from django.db import IntegrityError from django.http import HttpResponseRedirect from django.shortcuts import render_to_response @@ -21,6 +23,9 @@ """Validate the user and log him in. """ + template = 'projrev/auth/login.html' + context = {} + if request.POST: username = request.POST['username'] password = request.POST['password'] @@ -34,10 +39,7 @@ # Return a 'disabled account' error message else: # Return an 'invalid login' error message. - pass - else: - context = {} - template = 'projrev/auth/login.html' + context['error'] = True return render_to_response(template, context) @@ -87,4 +89,6 @@ def logout_view(request): """Logout the user """ - \ No newline at end of file + + logout(request) + return HttpResponseRedirect(reverse('app.projrev.views.base.home')) diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/projrev/views/proposal.py --- a/app/projrev/views/proposal.py Thu Aug 06 18:49:06 2009 +0530 +++ b/app/projrev/views/proposal.py Thu Aug 06 20:20:36 2009 +0530 @@ -13,7 +13,7 @@ from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect -from django.shortcuts import render_to_response, get_object_or_404 +from django.shortcuts import render_to_response from django.template import RequestContext from projrev.models import Project diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/site-content/css/colorbox.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/site-content/css/colorbox.css Thu Aug 06 20:20:36 2009 +0530 @@ -0,0 +1,35 @@ +/* + ColorBox Core Style + The following rules are the styles that are consistant between all ColorBox themes +*/ +#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;} +#cboxOverlay{position:fixed; width:100%; height:100%;} +#cboxMiddleLeft, #cboxBottomLeft{clear:left;} +#cboxContent{position:relative; overflow:visible;} +#cboxLoadedContent{overflow:auto;} +#cboxLoadedContent iframe{display:block; width:100%; height:100%; border:0;} +#cboxTitle{margin:0;} +#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%;} +#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;} + +/* + ColorBox example user style + These rules are ordered and tabbed in a way that represents the order/nesting of the generated HTML, + in hope that this will make the relationship easier to understand. Thanks, jack@colorpowered.com +*/ +#cboxOverlay{background:#000;} + +#colorbox{} + #cboxContent{background:#000; margin-top:20px;} + #cboxLoadedContent{background:#000; padding:5px;} + #cboxTitle{position:absolute; top:-20px; left:0; color:#ccc;} + #cboxCurrent{position:absolute; top:-20px; right:0px; color:#ccc;} + #cboxSlideshow{position:absolute; top:-20px; right:90px; color:#fff;} + #cboxPrevious{position:absolute; top:50%; left:5px; margin-top:-32px; background:url(/site-content/images/controls.png) top left no-repeat; width:28px; height:65px; text-indent:-9999px;} + #cboxPrevious.hover{background-position:bottom left;} + #cboxNext{position:absolute; top:50%; right:5px; margin-top:-32px; background:url(/site-content/images/controls.png) top right no-repeat; width:28px; height:65px; text-indent:-9999px;} + #cboxNext.hover{background-position:bottom right;} + #cboxLoadingOverlay{background:#000;} + #cboxLoadingGraphic{background:url(/site-content/images/loading.gif) center center no-repeat;} + #cboxClose{position:absolute; top:5px; right:5px; display:block; background:url(/site-content/images/controls.png) top center no-repeat; width:38px; height:19px; text-indent:-9999px;} + #cboxClose.hover{background-position:bottom center;} diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/site-content/css/login.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/site-content/css/login.css Thu Aug 06 20:20:36 2009 +0530 @@ -0,0 +1,21 @@ +* { margin: 0; padding: 0; } +body { font-family: Georgia, serif; background: url(/site-content/images/login-page-bg.jpg) top center no-repeat #c4c4c4; color: #3a3a3a; } + +.clear { clear: both; } + +form { width: 406px; margin: 170px auto 0; } + +legend { display: none; } + +fieldset { border: 0; } + +label { width: 115px; text-align: right; float: left; margin: 0 10px 0 0; padding: 9px 0 0 0; font-size: 16px; } + +input { width: 220px; display: block; padding: 4px; margin: 0 0 10px 0; font-size: 18px; + color: #3a3a3a; font-family: Georgia, serif;} +input[type=checkbox]{ width: 20px; margin: 0; display: inline-block; } + +.button { background: url(/site-content/images/button-bg.png) repeat-x top center; border: 1px solid #999; + -moz-border-radius: 5px; padding: 5px; color: black; font-weight: bold; + -webkit-border-radius: 5px; font-size: 13px; width: 70px; } +.button:hover { background: white; color: black; } diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/site-content/css/projrev.css --- a/app/site-content/css/projrev.css Thu Aug 06 18:49:06 2009 +0530 +++ b/app/site-content/css/projrev.css Thu Aug 06 20:20:36 2009 +0530 @@ -483,4 +483,12 @@ left: 22%; font: normal 1em "Trebuchet MS", Tahoma, sans-serif; color:#f00; +} + +div.access-error { + padding: 3px; + margin-left: 3%; + width: auto; + font: normal 1em "Trebuchet MS", Tahoma, sans-serif; + color:#f00; } \ No newline at end of file diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/site-content/images/button-bg.png Binary file app/site-content/images/button-bg.png has changed diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/site-content/images/controls.png Binary file app/site-content/images/controls.png has changed diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/site-content/images/loading.gif Binary file app/site-content/images/loading.gif has changed diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/site-content/images/login-page-bg.jpg Binary file app/site-content/images/login-page-bg.jpg has changed diff -r 3e6916eb3d2c -r 294ff7ac9cb6 app/site-content/js/jquery.colorbox-min.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/site-content/js/jquery.colorbox-min.js Thu Aug 06 20:20:36 2009 +0530 @@ -0,0 +1,3 @@ +// ColorBox v1.2.7 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 + +(function(B){var G,V,W,d,z,k,b,F,c,Q,D,e,s,j,m,P,l,H,t;var X,i,g,a,p,A,T,w,I,q="colorbox",o="hover";var y,f,R,L,K,J,r,M;var x="cbox_open",O="cbox_load",u="cbox_complete",h="cbox_close",n="cbox_closed";var C={transition:"elastic",speed:350,width:false,height:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,resize:true,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:true,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:true,slideshow:false,slideshowAuto:true,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow"};B(function(){R()});function N(Y){if(Y.keyCode==37){Y.preventDefault();H.click()}else{if(Y.keyCode==39){Y.preventDefault();l.click()}}}function E(Y,Z){Z=Z=="x"?document.documentElement.clientWidth:document.documentElement.clientHeight;return(typeof Y=="string")?(Y.match(/%/)?(Z/100)*parseInt(Y,10):parseInt(Y,10)):Y}function v(Y){return T.photo?true:Y.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(.*))?$/i)}function U(){for(var Y in T){if(typeof(T[Y])=="function"){T[Y]=T[Y].call(p)}}}B.fn.colorbox=function(Z,Y){if(this.length){this.each(function(){var aa=B(this).data(q)?B.extend({},B(this).data(q),Z):B.extend({},C,Z);B(this).data(q,aa).addClass("cboxelement")})}else{B(this).data(q,B.extend({},C,Z))}B(this).unbind("click.colorbox").bind("click.colorbox",function(ab){p=this;T=B(p).data(q);U();B().bind("keydown.cbox_close",function(ac){if(ac.keyCode==27){ac.preventDefault();t.click()}});if(T.overlayClose===true){G.css({cursor:"pointer"}).one("click",M)}p.blur();I=Y||false;var aa=T.rel||p.rel;if(aa&&aa!="nofollow"){c=B(".cboxelement").filter(function(){var ac=B(this).data(q).rel||this.rel;return(ac==aa)});A=c.index(p);if(A<0){c=c.add(p);A=c.length-1}}else{c=B(p);A=0}if(!w){B.event.trigger(x);t.html(T.close);G.css({opacity:T.opacity}).show();w=true;K(E(T.initialWidth,"x"),E(T.initialHeight,"y"),0);if(B.browser.msie&&B.browser.version<7){Q.bind("resize.cboxie6 scroll.cboxie6",function(){G.css({width:Q.width(),height:Q.height(),top:Q.scrollTop(),left:Q.scrollLeft()})})}}r();L();ab.preventDefault()});if(Z&&Z.open){B(this).triggerHandler("click.colorbox")}return this};R=function(){function Y(Z){return B('
')}Q=B(window);V=B('
');G=Y("Overlay").hide();W=Y("Wrapper");d=Y("Content").append(D=Y("LoadedContent").css({width:0,height:0}),e=Y("LoadingOverlay"),s=Y("LoadingGraphic"),j=Y("Title"),m=Y("Current"),P=Y("Slideshow"),l=Y("Next"),H=Y("Previous"),t=Y("Close"));W.append(B("
").append(Y("TopLeft"),z=Y("TopCenter"),Y("TopRight")),B("
").append(k=Y("MiddleLeft"),d,b=Y("MiddleRight")),B("
").append(Y("BottomLeft"),F=Y("BottomCenter"),Y("BottomRight"))).children().children().css({"float":"left"});B("body").prepend(G,V.append(W));if(B.browser.msie&&B.browser.version<7){G.css("position","absolute")}d.children().addClass(o).mouseover(function(){B(this).addClass(o)}).mouseout(function(){B(this).removeClass(o)}).hide();X=z.height()+F.height()+d.outerHeight(true)-d.height();i=k.width()+b.width()+d.outerWidth(true)-d.width();g=D.outerHeight(true);a=D.outerWidth(true);V.css({"padding-bottom":X,"padding-right":i}).hide();l.click(f);H.click(y);t.click(M);d.children().removeClass(o)};K=function(ab,aa,Z,ac){var ad=document.documentElement.clientHeight;var af=ad/2-aa/2;var ae=document.documentElement.clientWidth/2-ab/2;if(aa>ad){af-=(aa-ad)}if(af<0){af=0}if(ae<0){ae=0}af+=Q.scrollTop();ae+=Q.scrollLeft();ab=ab-i;aa=aa-X;W[0].style.width=W[0].style.height="9999px";function ag(ah){z[0].style.width=F[0].style.width=d[0].style.width=ah.style.width;s[0].style.height=e[0].style.height=d[0].style.height=k[0].style.height=b[0].style.height=ah.style.height}var Y=(V.width()===ab&&V.height()===aa)?0:Z;V.dequeue().animate({height:aa,width:ab,top:af,left:ae},{duration:Y,complete:function(){ag(this);W[0].style.width=(ab+i)+"px";W[0].style.height=(aa+X)+"px";if(ac){ac()}},step:function(){ag(this)}})};J=function(ad){if(!w){return}Q.unbind("resize.cbox_resize");var ab=T.transition=="none"?0:T.speed;D.remove();D=B(ad);var Z;var aj;function ah(){if(T.width){Z=maxWidth}else{Z=maxWidth&&maxWidth0?ae:0)+"px"}function ai(am){var al=Z+a+i;var an=aj+g+X;K(al,an,am,function(){if(!w){return}if(B.browser.msie){if(Y){D.fadeIn(100)}V.css("filter","")}d.children().show();B("#cboxIframeTemp").after("