We were thrilled to receive such a strong pool of submissions for our code competition. We ended up in a three-way tie, and it took the judges an extra day to agree on a winner. It was a very difficult decision, but today we are pleased to congratulate Stephan Bauer as the winner of the contest.
Stephan's submission:
// Allows visitors to like each Page once per IP
// Code submitted by relaxt confusion labs
class Page extends SiteTree {
private static $has_many = array(
'Likes' => 'Page_Like'
);
}
class Page_Controller extends ContentController {
// Enables liking a Page by appending "likethispage" to a Page's url
private static $allowed_actions = array(
'likethispage'
);
public function likethispage(SS_HTTPRequest $request) {
$ip = $request->getIP();
if($this->Likes()->filter('IP', $ip)->Count() == 0) {
$pageLike = Page_Like::create();
$pageLike->IP = $ip;
$this->Likes()->add($pageLike);
}
$this->redirectBack();
}
}
class Page_Like extends DataObject {
private static $db = array(
'IP' => 'Varchar(45)'
);
private static $has_one = array(
'LikedPage' => 'Page'
);
}
Stephan's submission stood out to the judges due to the variety of functionality it demonstrated, including ORM filtering, a custom controller action, and a custom DataObject type. Plus, the code is coherent and functional, and the judges could easily imagine it being used in production. Great work, Stephan!
Due honourable mention are the runners up:
- Jono Menz (https://gist.github.com/jonom/9b42115a21107e2e3537)
- Lamin Barrow (https://gist.github.com/laminbarrow/b8adc674bd8e396d3069)
Thanks again for all the submissions. It was a pleasure to see such a great response from the community. We look forward to showcasing Stephan's work on our Software page.
Stephan, we'll be in touch soon to work out arrangements on getting you that drone!
Post your comment
Comments
Posted by Jono, 13/08/2015 7:37am (9 years ago)
Posted by Otterpocket, 12/08/2015 9:51pm (9 years ago)
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments