This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_project(request): | |
form = ProjectForm() | |
if request.method == 'POST': | |
form = ProjectForm(request.POST or None, request.FILES or None) | |
if form.is_valid(): | |
project = form.save(commit=False) | |
project.save() | |
messages.success(request, "Directory entry added successfully!", extra_tags='alert-success') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('protected', array('before' => 'auth|role:admin', function() { | |
return "Only admins can see this"; | |
})); | |
Route::filter('role', function ($role) { | |
if ( ! Auth::user()->has_role( $role ) ) | |
{ | |
return Response::error("401"); // not authorized |