Fixes on company CRUD
Change-Id: I7ea8c4f99b4366daf18677654f15f406a479815f Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
730806c6a0
commit
408e8aefe8
@ -132,6 +132,7 @@ abstract class AbstractSerializer implements IModelSerializer
|
||||
const FloatType = 'json_float';
|
||||
const ObfuscatedEmailType = 'json_obfuscated_email';
|
||||
const UrlType = 'json_url';
|
||||
const ColorType = 'json_color';
|
||||
|
||||
const ValidTypes = [
|
||||
self::BoolType,
|
||||
@ -141,6 +142,7 @@ abstract class AbstractSerializer implements IModelSerializer
|
||||
self::FloatType,
|
||||
self::ObfuscatedEmailType,
|
||||
self::UrlType,
|
||||
self::ColorType,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -221,6 +223,11 @@ abstract class AbstractSerializer implements IModelSerializer
|
||||
$value = JsonUtils::toJsonBoolean($value);
|
||||
}
|
||||
break;
|
||||
case 'json_color':
|
||||
{
|
||||
$value = JsonUtils::toJsonColor($value);
|
||||
}
|
||||
break;
|
||||
case 'json_int':
|
||||
{
|
||||
$value = JsonUtils::toJsonInt($value);
|
||||
|
@ -69,6 +69,20 @@ abstract class JsonUtils
|
||||
return boolval($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function toJsonColor($value)
|
||||
{
|
||||
if(empty($value))
|
||||
$value = 'f0f0ee';
|
||||
if (strpos($value,'#') === false) {
|
||||
$value = '#'.$value;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return int|null
|
||||
|
@ -205,4 +205,62 @@ final class OAuth2CompaniesApiController extends OAuth2ProtectedController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
* @param $speaker_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function addCompanyBigLogo(LaravelRequest $request, $company_id)
|
||||
{
|
||||
try {
|
||||
|
||||
$file = $request->file('file');
|
||||
if (is_null($file)) {
|
||||
return $this->error412(array('file param not set!'));
|
||||
}
|
||||
|
||||
$logo = $this->service->addCompanyLogo($company_id, $file);
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($logo)->serialize());
|
||||
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412(array($ex2->getMessage()));
|
||||
} catch (\HTTP401UnauthorizedException $ex3) {
|
||||
Log::warning($ex3);
|
||||
return $this->error401();
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $company_id
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function deleteCompanyBigLogo($company_id){
|
||||
try {
|
||||
|
||||
$this->service->deleteCompanyLogo($company_id);
|
||||
|
||||
return $this->deleted();
|
||||
|
||||
} catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
} catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412(array($ex2->getMessage()));
|
||||
} catch (\HTTP401UnauthorizedException $ex3) {
|
||||
Log::warning($ex3);
|
||||
return $this->error401();
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@
|
||||
use App\Models\ResourceServer\ApiEndpoint;
|
||||
use App\Models\ResourceServer\IApiEndpointRepository;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use libs\utils\RequestUtils;
|
||||
use models\main\IMemberRepository;
|
||||
@ -77,6 +78,9 @@ final class UserAuthEndpoint
|
||||
$required_groups = $endpoint->getAuthzGroups();
|
||||
|
||||
foreach ($required_groups as $required_group) {
|
||||
Log::debug(sprintf("UserAuthEndpoint::handle route %s method %s member %s (%s) required group %s",
|
||||
$route, $method, $current_member->getId(), $current_member->getEmail(), $required_group->getSlug()));
|
||||
|
||||
if($current_member->isOnGroup($required_group->getSlug()))
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ Route::group([
|
||||
Route::get('', 'OAuth2CompaniesApiController@getAllCompanies');
|
||||
Route::post('', [ 'middleware' => 'auth.user', 'uses' => 'OAuth2CompaniesApiController@add']);
|
||||
Route::group(['prefix'=>'{id}'], function(){
|
||||
Route::get('', [ 'middleware' => 'auth.user', 'uses' => 'OAuth2CompaniesApiController@get']);
|
||||
Route::get('', [ 'uses' => 'OAuth2CompaniesApiController@get']);
|
||||
Route::put('', [ 'middleware' => 'auth.user', 'uses' => 'OAuth2CompaniesApiController@update']);
|
||||
Route::delete('', [ 'middleware' => 'auth.user', 'uses' => 'OAuth2CompaniesApiController@delete']);
|
||||
Route::group(['prefix'=>'logo'], function(){
|
||||
|
@ -59,6 +59,7 @@ abstract class AbstractEmailJob implements ShouldQueue
|
||||
public function __construct(array $payload, ?string $template_identifier, string $to_email, ?string $subject = null)
|
||||
{
|
||||
$this->template_identifier = $template_identifier;
|
||||
Log::debug(sprintf("AbstractEmailJob::__construct template_identifier %s", $template_identifier));
|
||||
if(empty($this->template_identifier)){
|
||||
throw new \InvalidArgumentException("missing template_identifier value");
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use models\summit\SummitOrder;
|
||||
use models\summit\SummitRegistrationDiscountCode;
|
||||
/**
|
||||
@ -110,7 +111,7 @@ class RegisteredMemberOrderPaidMail extends AbstractEmailJob
|
||||
$payload['tickets'] = $tickets;
|
||||
|
||||
$template_identifier = $this->getEmailTemplateIdentifierFromEmailEvent($summit);
|
||||
|
||||
Log::debug(sprintf("RegisteredMemberOrderPaidMail::__construct template_identifier %s", $template_identifier));
|
||||
parent::__construct($payload, $template_identifier, $owner_email);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use models\summit\SummitOrder;
|
||||
/**
|
||||
* Class UnregisteredMemberOrderPaidMail
|
||||
@ -36,7 +37,9 @@ class UnregisteredMemberOrderPaidMail extends RegisteredMemberOrderPaidMail
|
||||
*/
|
||||
public function __construct(SummitOrder $order, string $set_password_link)
|
||||
{
|
||||
Log::debug("UnregisteredMemberOrderPaidMail::__construct");
|
||||
parent::__construct($order);
|
||||
Log::debug(sprintf("UnregisteredMemberOrderPaidMail::__construct %s", $this->template_identifier));
|
||||
// need to add the dashboard client id and return url
|
||||
$base_url = Config::get("registration.dashboard_base_url", null);
|
||||
if(empty($base_url))
|
||||
|
@ -38,6 +38,7 @@ final class CompanySerializer extends SilverStripeSerializer
|
||||
'CommitmentAuthor' => 'commitment_author:json_string',
|
||||
'LogoUrl' => 'logo:json_url',
|
||||
'BigLogoUrl' => 'big_logo:json_url',
|
||||
'Color' => 'color:json_string',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -52,15 +53,6 @@ final class CompanySerializer extends SilverStripeSerializer
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$company = $this->object;
|
||||
if(!$company instanceof Company) return $values;
|
||||
|
||||
$color = isset($values['color']) ? $values['color']:'';
|
||||
if(empty($color))
|
||||
$color = 'f0f0ee';
|
||||
if (strpos($color,'#') === false) {
|
||||
$color = '#'.$color;
|
||||
}
|
||||
$values['color'] = $color;
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use App\Security\SummitScopes;
|
||||
use App\Security\OrganizationScopes;
|
||||
use App\Security\MemberScopes;
|
||||
use App\Security\CompanyScopes;
|
||||
/**
|
||||
* Class ApiScopesSeeder
|
||||
*/
|
||||
@ -475,12 +476,12 @@ final class ApiScopesSeeder extends Seeder
|
||||
|
||||
$scopes = [
|
||||
[
|
||||
'name' => sprintf('%s/companies/read', $current_realm),
|
||||
'name' => sprintf(CompanyScopes::Read, $current_realm),
|
||||
'short_description' => 'Get Companies Data',
|
||||
'description' => 'Grants read only access for Companies Data',
|
||||
],
|
||||
[
|
||||
'name' => sprintf('%s/companies/write', $current_realm),
|
||||
'name' => sprintf(CompanyScopes::Write, $current_realm),
|
||||
'short_description' => 'Write Companies Data',
|
||||
'description' => 'Grants write only access for Companies Data',
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user