Browse Source

Neues Update

Daniel Müllers 11 years ago
parent
commit
114e658b7b

+ 31 - 0
app/database/migrations/2013_11_09_184814_system.php

@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+
+class System extends Migration {
+
+	/**
+	 * Run the migrations.
+	 *
+	 * @return void
+	 */
+	public function up()
+	{
+		Schema::create('system', function($table) {
+			$table->increments('id');
+			$table->integer('nextfilm');
+			$table->timestamps();
+		});
+	}
+
+	/**
+	 * Reverse the migrations.
+	 *
+	 * @return void
+	 */
+	public function down()
+	{
+		Schema::drop('system');
+	}
+
+}

+ 5 - 1
app/models/Comment.php

@@ -7,7 +7,11 @@ class Comment extends Eloquent {
 		return $this->belongsTo('User', 'user');
 		return $this->belongsTo('User', 'user');
 	}
 	}
 
 
-	public function film() {
+	public function objekt() {
 		return $this->belongsTo('Film', 'film');
 		return $this->belongsTo('Film', 'film');
 	}
 	}
+
+	public function scopeNeueste($query) {
+		return $query->orderBy('updated_at', 'DESC')->take(5);
+	}
 }
 }

+ 13 - 0
app/models/Dumbo.php

@@ -0,0 +1,13 @@
+<?php
+
+class Dumbo extends Eloquent {
+	protected $table = "system";
+
+	public function film() {
+		return $this->belongsTo('Film', 'nextfilm');
+	}
+
+	public function scopeNextFilm($query) {
+		return $query->find(1);
+	}
+}

+ 26 - 0
app/routes.php

@@ -16,6 +16,7 @@ Route::get('/', function()
 	$gesehen = Film::zuletztGesehen()->get();
 	$gesehen = Film::zuletztGesehen()->get();
 	$vorgeschlagen = Film::neuesteVorschlage()->get();
 	$vorgeschlagen = Film::neuesteVorschlage()->get();
 	$news = News::aktuell()->get();
 	$news = News::aktuell()->get();
+	$nextfilm = Dumbo::find(1)->film;
 
 
 	$topfilm = DB::table(DB::raw('film_films'))
 	$topfilm = DB::table(DB::raw('film_films'))
 	->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes, 
 	->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes, 
@@ -23,6 +24,7 @@ Route::get('/', function()
 		COUNT(case when film_votes.stimme IS TRUE then 1 end) - COUNT(case when film_votes.stimme IS FALSE then 1 end) as vcount'))
 		COUNT(case when film_votes.stimme IS TRUE then 1 end) - COUNT(case when film_votes.stimme IS FALSE then 1 end) as vcount'))
 	->leftJoin('votes', 'votes.film', '=', 'films.id')
 	->leftJoin('votes', 'votes.film', '=', 'films.id')
 	->whereNull('films.gesehen')
 	->whereNull('films.gesehen')
+	->where('films.id', "!=", is_object($nextfilm) ? $nextfilm->id : 0)
 	->groupBy('id')
 	->groupBy('id')
 	->orderBy('vcount', 'DESC')->orderBy('vorgeschlagen', 'ASC')
 	->orderBy('vcount', 'DESC')->orderBy('vorgeschlagen', 'ASC')
 	->first();
 	->first();
@@ -31,11 +33,23 @@ Route::get('/', function()
 	$tmovie = $tmdb->getMovie($topfilm->tvdbid);
 	$tmovie = $tmdb->getMovie($topfilm->tvdbid);
 	$image = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
 	$image = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
 
 
+	if(is_object($nextfilm)) {
+		$tmovie = $tmdb->getMovie($nextfilm->tvdbid);
+		$nimage = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
+	} else {
+		$nimage = "http://d3a8mw37cqal2z.cloudfront.net/assets/7ea4ac6f271e37d/images/no-poster-w130.jpg";
+	}
+
+	$kommentare = Comment::neueste()->get();
+
 	return View::make('index')
 	return View::make('index')
 		->with('gesehen', $gesehen)
 		->with('gesehen', $gesehen)
 		->with('vorgeschlagen', $vorgeschlagen)
 		->with('vorgeschlagen', $vorgeschlagen)
 		->with('image', $image)
 		->with('image', $image)
+		->with('nimage', $nimage)
 		->with('news', $news)
 		->with('news', $news)
+		->with('kommentare', $kommentare)
+		->with('nextfilm', $nextfilm)
 		->with('topfilm', $topfilm);
 		->with('topfilm', $topfilm);
 });
 });
 
 
@@ -201,9 +215,21 @@ Route::get('mark-read/{id}', array('before' => 'auth', function($id) {
 	$film = Film::findOrFail($id);
 	$film = Film::findOrFail($id);
 	$film->gesehen = \Carbon\Carbon::today();
 	$film->gesehen = \Carbon\Carbon::today();
 	$film->save();
 	$film->save();
+	if(Dumbo::find(1)->nextfilm == $film->id) {
+		$system = Dumbo::findOrFail(1);
+		$system->nextfilm = 0;
+		$system->save();
+	}
 	return Redirect::to('film/' . $film->id);
 	return Redirect::to('film/' . $film->id);
 }));
 }));
 
 
+Route::get('view-next/{id}', array('before' => 'auth', function($id) {
+	$system = Dumbo::findOrFail(1);
+	$system->nextfilm = $id;
+	$system->save();
+	return Redirect::to('film/' . $id);
+}));
+
 Route::get('register', function() {
 Route::get('register', function() {
 	return View::make('register');
 	return View::make('register');
 });
 });

+ 1 - 1
app/views/film.blade.php

@@ -233,7 +233,7 @@
 			placement: "right",
 			placement: "right",
 			trigger: "click",
 			trigger: "click",
 			title: "Als gesehen markieren",
 			title: "Als gesehen markieren",
-			content: "<div class='container'><a href='{{ url('mark-read/' . $film->id) }}' class='btn btn-success'>Film als gesehen markieren</a></div>"
+			content: "<div class='container'><a href='{{ url('mark-read/' . $film->id) }}' class='btn btn-success'>Gesehen</a><a href='{{ url('view-next/' . $film->id) }}' class='btn btn-warning'>Als n&auml;chstes sehen</a></div>"
 		});
 		});
 	});
 	});
 </script>
 </script>

+ 61 - 20
app/views/index.blade.php

@@ -3,13 +3,16 @@
 @section('content')
 @section('content')
 <div class="row">
 <div class="row">
 	<div class="col-md-6">
 	<div class="col-md-6">
-		<div class="panel panel-default">
+		<div class="panel panel-info">
 			<div class="panel-heading">Meistgew&uuml;nschter Film</div>
 			<div class="panel-heading">Meistgew&uuml;nschter Film</div>
 			<div class="panel-body">
 			<div class="panel-body">
 				<img src="{{$image}}" class="pull-left thumbnail" style="max-height: 100px; margin-right: 15px;">
 				<img src="{{$image}}" class="pull-left thumbnail" style="max-height: 100px; margin-right: 15px;">
 				<h4>{{$topfilm->name}}</h4>
 				<h4>{{$topfilm->name}}</h4>
 				<p><span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{{$topfilm->upvotes}} 
 				<p><span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{{$topfilm->upvotes}} 
 					<span class="glyphicon glyphicon-thumbs-down"></span>&nbsp;{{$topfilm->downvotes}}</p>
 					<span class="glyphicon glyphicon-thumbs-down"></span>&nbsp;{{$topfilm->downvotes}}</p>
+				@if(!is_null(Auth::user()) && Auth::user()->admin)
+					<a href='{{ url('view-next/' . $topfilm->id) }}' class='btn btn-success btn-xs'>Als n&auml;chstes sehen</a>
+				@endif
 			</div>
 			</div>
 
 
 			<div class="list-group">
 			<div class="list-group">
@@ -19,30 +22,31 @@
 	</div>
 	</div>
 
 
 	<div class="col-md-6">
 	<div class="col-md-6">
-		<div class="panel-group" id="accordion">
-			@foreach ($news as $new)
-				<div class="panel panel-warning">
-					<div class="panel-heading">
-						<h4 class="panel-title">
-							<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#news{{$new->id}}">{{$new->headline}}</a>
-							<small>{{$new->ersteller->name}} - {{\Carbon\Carbon::parse($new->updated_at)->format('d.m.Y')}}</small>
-						</h5>
-					</div>
-					<div id="news{{$new->id}}" class="panel-collapse collapse">
-						<div class="panel-body">{{nl2br(htmlentities($new->body))}}</div>
-					</div>
-				</div>					
-			@endforeach	
+		<div class="panel panel-primary">
+			<div class="panel-heading">N&auml;chster Film</div>
+			<div class="panel-body">
+				<img src="{{$nimage}}" class="pull-left thumbnail" style="max-height: 100px; margin-right: 15px;">
+				<h4>{{is_object($nextfilm) ? $nextfilm->name : "Steht nicht fest"}}</h4>
+				@if(is_object($nextfilm))	<a href='{{ url('mark-read/' . $nextfilm->id) }}' class='btn btn-success btn-xs'>Gesehen</a>
+				@endif
+			</div>
+
+			@if(is_object($nextfilm))
+			<div class="list-group">
+				{{ link_to_route('film', "Filmdetails", array($nextfilm->id), array('class' => 'list-group-item'))}}
+			</div>
+			@endif
 		</div>
 		</div>
 	</div>
 	</div>
+
+
 </div>
 </div>
 
 
 <div class="row">
 <div class="row">
 	<div class="col-md-6">
 	<div class="col-md-6">
 		<div class="panel panel-success">
 		<div class="panel panel-success">
 			<div class="panel-heading">Neue Vorschl&auml;ge</div>
 			<div class="panel-heading">Neue Vorschl&auml;ge</div>
-			<div class="panel-body"><p>Die neuesten Vorschläge für den nächsten Filmabend. Klicke einen der Vorschläge an, um Filmdetails zu sehen und darüber abzustimmen.</p></div>
-
+			
 			<div class="list-group">
 			<div class="list-group">
 				@foreach ($vorgeschlagen as $film)
 				@foreach ($vorgeschlagen as $film)
 					{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
 					{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
@@ -51,10 +55,9 @@
 		</div>
 		</div>
 	</div>
 	</div>
 	<div class="col-md-6">
 	<div class="col-md-6">
-		<div class="panel panel-primary">
+		<div class="panel panel-danger">
 			<div class="panel-heading">Gesehene Filme</div>
 			<div class="panel-heading">Gesehene Filme</div>
-			<div class="panel-body"><p>Die Filme, die wir kürzlich gesehen haben. Klicke einen der Titel an, um Kommentare und Filmdetails sowie ein etwaiges Abstimmungsergebnis zu sehen.</p></div>
-
+	
 			<div class="list-group">
 			<div class="list-group">
 				@foreach ($gesehen as $film)
 				@foreach ($gesehen as $film)
 					{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
 					{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
@@ -63,4 +66,42 @@
 		</div>
 		</div>
 	</div>
 	</div>
 </div>
 </div>
+<div class="row">
+	<div class="col-md-6">
+		<div class="panel-group" id="accordion">
+			@foreach ($news as $new)
+				<div class="panel panel-warning">
+					<div class="panel-heading">
+						<h4 class="panel-title">
+							<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#news{{$new->id}}">{{$new->headline}}</a>
+							<small>{{$new->ersteller->name}} - {{\Carbon\Carbon::parse($new->updated_at)->format('d.m.Y')}}</small>
+						</h5>
+					</div>
+					<div id="news{{$new->id}}" class="panel-collapse collapse">
+						<div class="panel-body">{{nl2br(htmlentities($new->body))}}</div>
+					</div>
+				</div>					
+			@endforeach	
+		</div>
+	</div>
+	<div class="col-md-6">
+		<div class="panel panel-default">
+			<div class="panel-heading">Letzte Kommentare</div>
+	
+			<div class="list-group">
+				@foreach ($kommentare as $kommentar)
+					<a href="{{ url("film/" . $kommentar->film) }}" class="list-group-item">
+						<h6 class='list-group-item-heading'>{{$kommentar->autor->name}}
+							<small>in {{ $kommentar->objekt->name }}</small>
+						</h6>
+					<p class='list-group-item-text'>
+						{{ substr($kommentar->text, 0, 55)}}<?php if(strlen($kommentar->text) > 55) echo "..." ?>
+					</p>
+					</a>
+				@endforeach		
+			</div>
+		</div>
+	</div>
+</div>
+
 @stop
 @stop

+ 18 - 4
app/views/suggest.blade.php

@@ -14,18 +14,32 @@
 	</tr>
 	</tr>
 @foreach($filme as $film)
 @foreach($filme as $film)
 	<tr>
 	<tr>
-		<td>{{ HTML::link('film/' . $film->id, $film->name) }}</td>
+		<td>
+			<?php
+				$stimme = 2;
+				if(!is_null(Auth::user()) && Vote::where('film', $film->id)->where('user', Auth::user()->id)->count())
+					$stimme = Vote::where('film', $film->id)->where('user', Auth::user()->id)->first()->stimme;
+			?>
+			{{ HTML::link('film/' . $film->id, $film->name) }} 
+		</td>
 		<td>
 		<td>
 			<?php 
 			<?php 
 				$vp = $film->upvotes; 
 				$vp = $film->upvotes; 
 				$np = $film->downvotes;
 				$np = $film->downvotes;
-			?>
-			
+				?>
 			<span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{{ $vp }}, 
 			<span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{{ $vp }}, 
 			<span class="glyphicon glyphicon-thumbs-down"></span>&nbsp;{{ $np }}
 			<span class="glyphicon glyphicon-thumbs-down"></span>&nbsp;{{ $np }}
 		</td>
 		</td>
 		<td>
 		<td>
-			<span class='label label-{{ ($vp - $np) > 0 ? "success'>+" . ($vp - $np) : "danger'>".($vp - $np) }}</span>
+			@if(($vp - $np) > 0) 		<span class="label label-success">+{{$vp - $np}}</span>
+			@elseif(($vp - $np) < 0)	<span class="label label-danger">{{$vp - $np}}</span>
+			@else 						<span class="label label-warning">{{$vp - $np}}</span>
+			@endif
+			@if($stimme == 1)
+			&nbsp;<span class="label label-success tooltip-enable" data-toggle="tooltip" title="Daf&uuml;r gestimmt."><span class="glyphicon glyphicon-thumbs-up"></span></span>
+			@elseif($stimme == 0)
+			&nbsp;<span class="label label-danger tooltip-enable"  data-toggle="tooltip" title="Dagegen gestimmt."><span class="glyphicon glyphicon-thumbs-down"></span></span>
+			@endif
 		</td>
 		</td>
 		<td>{{ \Carbon\Carbon::parse($film->vorgeschlagen)->format('d.m.Y')}}</td>
 		<td>{{ \Carbon\Carbon::parse($film->vorgeschlagen)->format('d.m.Y')}}</td>
 		<td>{{ Film::find($film->id)->besitzer->name }}</td>
 		<td>{{ Film::find($film->id)->besitzer->name }}</td>