Просмотр исходного кода

Added user level badge to testers table.

Alan Lam 8 лет назад
Родитель
Сommit
be88c419e8
3 измененных файлов с 16 добавлено и 6 удалено
  1. 11 3
      controllers/project_ajax.php
  2. 2 0
      public/js/app-project.js
  3. 3 3
      views/project.php

+ 11 - 3
controllers/project_ajax.php

@@ -122,8 +122,6 @@ if($submit) {
 					"status" => Test::STATUS_ASSIGNED,
 				]);
 
-				$age_constraint = false;
-
 				usort($addresses, function($a, $b) use ($location) {
 					$lat_lng = $location->getGeolocation();
 					return Geolocation::getDistance($lat_lng, $a->getGeolocation()) <=> Geolocation::getDistance($lat_lng, $b->getGeolocation());
@@ -135,6 +133,11 @@ if($submit) {
 					$user = $address->getUser();
 
 					$is_current_tester = $user->id == $test->tester_id;
+					$is_deactivated = $user->level == User::LEVEL_DEACTIVATED;
+					$is_registered = $user->level == User::LEVEL_REGISTERED;
+					$is_unverified = $user->level == User::LEVEL_UNVERIFIED;
+
+					if($is_deactivated) continue;
 
 					$distance_miles = Geolocation::getDistance($location->getGeolocation(), $address->getGeolocation());
 					$distance_kilometers = $distance_miles * Geolocation::KMS_IN_MILE;
@@ -174,7 +177,11 @@ if($submit) {
 						"latitude" => (float) $address->latitude,
 						"longitude" => (float) $address->longitude,
 						"pendingTestCount" => $pending_test_count,
-						"isCurrentTester" => $is_current_tester
+						"isCurrentTester" => $is_current_tester,
+						"isRegistered" => $is_registered,
+						"isUnverified" => $is_unverified,
+						"levelText" => $user->getLevelText(),
+						"levelClass" => $user->getLevelClass(),
 					];
 
 				}
@@ -208,6 +215,7 @@ if($submit) {
 				if(!$address) throw new Exception("User address cannot be found.");
 
 				$user = $address->getUser();
+				if($user->level == User::LEVEL_BANNED) throw new Exception("A test cannot be assigned to an banned user.");
 				if($user->level == User::LEVEL_UNVERIFIED) throw new Exception("A test cannot be assigned to an unverified user.");
 				if($user->level == User::LEVEL_DEACTIVATED) throw new Exception("A test cannot be assigned to a deactivated user.");
 				if($user->level >= User::LEVEL_VENUE) throw new Exception("A test cannot be assigned to a user that's not a tester.");

+ 2 - 0
public/js/app-project.js

@@ -202,6 +202,8 @@ function initialiseTesters() {
 			tr.append(td);
 
 			td = $("<td class=\"text-right align-middle\"></td>");
+			td.append("<span class=\"badge badge-" + tester.levelClass + "\">" + tester.levelText + "</span>");
+			td.append("<br />");
 			td.append(tester.phone);
 			tr.append(td);
 

+ 3 - 3
views/project.php

@@ -122,9 +122,9 @@ var projectID = <?=$project->id?>;
 				<thead>
 					<tr>
 						<th>Name / Distance</th>
-						<th>Age</th>
-						<th>Score</th>
-						<th>Phone</th>
+						<th class="text-right">Age</th>
+						<th class="text-right">Score</th>
+						<th class="text-right">User Level / Phone</th>
 						<th></th>
 					</tr>
 				</thead>