Skip to content

Commit

Permalink
Merge composer/master into availability
Browse files Browse the repository at this point in the history
Conflicts:
	View/RegistrationAnswers/key_auth.ctp
  • Loading branch information
s-nakajima committed Dec 25, 2023
2 parents c6e1a18 + 9b8c7e1 commit 5f662a4
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 36 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ name: tests
jobs:
setup:
name: setup
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Slack Notification on Start
uses: rtCamp/action-slack-notify@v2.2.0
if: env.SLACK_WEBHOOK != ''
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }}
SLACK_CHANNEL: notify-nc3-tests
Expand All @@ -28,7 +29,7 @@ jobs:
tests:
name: tests
needs: setup
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.1', '7.2', '7.3', '7.4' ]
Expand Down Expand Up @@ -92,54 +93,61 @@ jobs:
docker-compose exec -T nc3app bash /opt/scripts/app-build.sh
- name: phpcs (PHP CodeSniffer)
if: always()
run: |
cd ${NC3_DOCKER_DIR}
docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh
- name: phpmd (PHP Mess Detector)
if: always()
run: |
cd ${NC3_DOCKER_DIR}
docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh
- name: phpcpd (PHP Copy/Paste Detector)
if: always()
run: |
cd ${NC3_DOCKER_DIR}
docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh
- name: gjslint (JavaScript Style Check)
if: always()
run: |
cd ${NC3_DOCKER_DIR}
docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh
- name: phpdoc (PHP Documentor)
if: always()
run: |
cd ${NC3_DOCKER_DIR}
docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh
- name: phpunit (PHP UnitTest)
if: always()
run: |
cd ${NC3_DOCKER_DIR}
docker-compose exec -T nc3app bash /opt/scripts/phpunit.sh
sudo -s chmod a+w -R ${NC3_BUILD_DIR}/build
- name: push coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.php }}
run: |
cd ${NC3_BUILD_DIR}
ls -la ${NC3_BUILD_DIR}
vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
# - name: push coveralls
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# COVERALLS_FLAG_NAME: ${{ matrix.php }}
# run: |
# cd ${NC3_BUILD_DIR}
# ls -la ${NC3_BUILD_DIR}
# vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v

- name: docker-compose remove
if: always()
run: |
cd ${NC3_DOCKER_DIR}
docker-compose rm -f
# テスト失敗時はこちらのステップが実行される
- name: Slack Notification on Failure
uses: rtCamp/action-slack-notify@v2.2.0
if: failure()
if: env.SLACK_WEBHOOK != '' && failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }}
SLACK_CHANNEL: notify-nc3-tests
Expand All @@ -148,13 +156,13 @@ jobs:

teardown:
name: teardown
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
needs: tests
steps:
# テスト成功時はこちらのステップが実行される
- name: Slack Notification on Success
if: success()
uses: rtCamp/action-slack-notify@v2.2.0
if: env.SLACK_WEBHOOK != '' && success()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }}
SLACK_CHANNEL: notify-nc3-tests
Expand Down
1 change: 1 addition & 0 deletions Controller/RegistrationAddController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function add() {

// 過去データ 取り出し
$conditions = Hash::remove($this->Registration->getBaseCondition(), 'block_id');
unset($conditions['Registration.block_id']);
$conditions['Block.room_id'] = Current::read('Room.id');
$pastRegistrations = $this->Registration->find('all',
array(
Expand Down
61 changes: 48 additions & 13 deletions Controller/RegistrationAnswersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* @property RegistrationAnswer $RegistrationAnswer
* @property RegistrationsOwnAnswerComponent $RegistrationOwnAnswer
* @property RegistrationAnswerSummary $RegistrationAnswerSummary
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class RegistrationAnswersController extends RegistrationsAppController {

Expand Down Expand Up @@ -76,6 +78,12 @@ class RegistrationAnswersController extends RegistrationsAppController {
*/
private $__ableToAnswerAction = ['view', 'confirm'];

/**
* target remainingCount Action
*
*/
private $__remainingCountAction = ['view', 'confirm', 'key_auth', 'img_auth'];

/**
* frame setting display type
*/
Expand All @@ -90,7 +98,7 @@ class RegistrationAnswersController extends RegistrationsAppController {
public function beforeFilter() {
// ゲストアクセスOKのアクションを設定
$this->Auth->allow('view', 'confirm', 'thanks', 'no_more_answer', 'key_auth', 'img_auth',
'empty_form');
'empty_form', 'limit');

// 親クラスのbeforeFilterを済ませる
parent::beforeFilter();
Expand Down Expand Up @@ -142,6 +150,16 @@ public function beforeFilter() {
return;
}
}

if (in_array($this->action, $this->__remainingCountAction)) {
//残りの登録可能数を取得
$remainingCount = $this->__remainingCount($this->__registration);
if ($remainingCount == 0) {
$this->setAction('limit');
return;
}
$this->set('remainingCount', $remainingCount);
}
}

/**
Expand All @@ -153,6 +171,15 @@ public function empty_form() {
$this->emptyRender();
}

/**
* 登録数を超過したときに表示
*
* @return void
*/
public function limit() {
$this->set('registration', $this->__registration);
}

/**
* test_mode
*
Expand Down Expand Up @@ -308,12 +335,6 @@ public function view() {
$registration = $this->__registration;
$registrationKey = $this->_getRegistrationKey($this->__registration);

//登録数制限
if ($this->_isLimitNumber($registration)) {
$this->set('registration', $registration);
$this->render('limit');
return;
}
//
$this->_viewGuard();

Expand Down Expand Up @@ -542,23 +563,37 @@ protected function _redirectAnswerPage() {
}

/**
* 登録数制限に達してるかチェック
* 残りの登録可能数を取得
*
* @param array $registration Registrationデータ
* @return bool
* @return int 残りの登録可能数 登録数制限を行わない場合は-1を返す。
*/
protected function _isLimitNumber($registration) {
private function __remainingCount($registration) {
if ($registration['Registration']['is_limit_number']) {
$limit = $registration['Registration']['limit_number'];
// 登録数カウント
$options = [
'conditions' => $this->RegistrationAnswerSummary->getResultCondition($registration)
];
$answerCount = $this->RegistrationAnswerSummary->find('count', $options);
if ($limit <= $answerCount) {
return true;
if ($limit > $answerCount) {
//登録可能
return $limit - $answerCount;
} else {
//登録数制限を超過
if ($this->request->is('post') &&
($this->action === 'view' || $this->action === 'confirm')) {
//回答画面で次へ、もしくは確認画面で決定をクリックしたときはフラッシュメッセージ表示
$this->NetCommons->setFlashNotification(
__d('net_commons', 'Failed to save.'),
['class' => 'danger'],
400
);
}
return 0;
}
}
return false;
//登録数制限を行わない
return -1;
}
}
3 changes: 3 additions & 0 deletions Locale/jpn/LC_MESSAGES/registrations.po
Original file line number Diff line number Diff line change
Expand Up @@ -1047,3 +1047,6 @@ msgstr "登録数"

msgid "Registration Number"
msgstr "受付番号"

msgid "(Remaining: %s)"
msgstr "(残り: %s)"
7 changes: 4 additions & 3 deletions Model/ActionRegistrationAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public function checkPastRegistration($check) {
'Registration.id' => $check['past_registration_id']
));
unset($baseCondition['block_id']);
unset($baseCondition['Registration.block_id']);
$cnt = $this->Registration->find('count', array(
'conditions' => $baseCondition,
'recursive' => -1
Expand Down Expand Up @@ -258,11 +259,11 @@ protected function _getRegistrationCloneById($registrationId) {
return $registration;
}
/**
* _copyWysiwygFiles
*
* _copyWysiwygFiles
*
* 引数で指定された登録フォームの中を分析し、
* ウィジウィグに設定されているファイルは複製を作ります
*
*
* @param array $registration 登録フォームデータ
* @return array $registration 複製を作り終えた登録フォームデータ
*/
Expand Down
4 changes: 2 additions & 2 deletions Model/RegistrationAnswerSummaryCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getAnswerSummaryCsv($registration, $limit, $offset) {
),
'limit' => $limit,
'offset' => $offset,
'order' => array('RegistrationAnswerSummaryCsv.created ASC'),
'order' => array('RegistrationAnswerSummaryCsv.answer_time ASC'),
));
if (empty($summaries)) {
return $retArray;
Expand Down Expand Up @@ -257,7 +257,7 @@ protected function _getRows($registration, $summary, $answers) {
$cols[] = $summary['RegistrationAnswerSummaryCsv']['serial_number'];
$cols[] = $this->_getUserName($registration, $summary);
$cols[] = $this->__NetCommonsTime->dateFormat(
$summary['RegistrationAnswerSummaryCsv']['modified'],
$summary['RegistrationAnswerSummaryCsv']['answer_time'],
'Y-m-d H:i:s'
);
$cols[] = $summary['RegistrationAnswerSummaryCsv']['answer_number'];
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.6
3.3.7
5 changes: 5 additions & 0 deletions View/Elements/Answers/answer_header.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@
<?php echo $this->TitleIcon->titleIcon($registration['Registration']['title_icon']); ?>
<?php echo h($registration['Registration']['title']); ?>
<small><?php echo h($registration['Registration']['sub_title']);?></small>
<?php if (isset($remainingCount) && $remainingCount > 0) : ?>
<div class="registration-answer-header-remaining-count">
<small><?php echo __d('registrations', '(Remaining: %s)', $remainingCount);?></small>
</div>
<?php endif; ?>
</h1>
1 change: 1 addition & 0 deletions View/RegistrationAnswers/img_auth.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
echo $this->NetCommonsHtml->css('/registrations/css/registration.css');
?>
<article>
<?php echo $this->element('Registrations.Answers/answer_header'); ?>
Expand Down
6 changes: 2 additions & 4 deletions View/RegistrationAnswers/key_auth.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
echo $this->NetCommonsHtml->script(array(
'/authorization_keys/js/key_auth_init.js'
));
echo $this->NetCommonsHtml->css('/registrations/css/registration.css');
?>
<article ng-controller="AuthorizationKey" ng-init="initialize('<?php echo h($postUrl); ?>')">
<?php echo $this->element('Registrations.Answers/answer_header'); ?>
Expand All @@ -36,4 +34,4 @@ echo $this->NetCommonsHtml->script(array(
</div>

<?php echo $this->NetCommonsForm->end(); ?>
</article>
</article>
5 changes: 5 additions & 0 deletions webroot/css/registration.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ table.table.registration-table-vcenter tbody td {
#RegistrationAnswerViewForm .radio-inline+.radio-inline {
margin-left: 0px;
}

/*--登録フォーム回答画面のヘッダー---*/
.registration-answer-header-remaining-count {
font-size: 18px;
}

0 comments on commit 5f662a4

Please sign in to comment.