<commit_before>package com.worth.ifs.competition.security;

import com.worth.ifs.competition.resource.CompetitionResource;
import com.worth.ifs.security.BasePermissionRules;
import com.worth.ifs.security.PermissionRule;
import com.worth.ifs.security.PermissionRules;
import com.worth.ifs.user.resource.UserResource;
import com.worth.ifs.user.resource.UserRoleType;
import org.springframework.stereotype.Component;

/**
 * Provides the permissions around CRUD for Competitions
 */
@Component
@PermissionRules
public class CompetitionPermissionRules extends BasePermissionRules {

    @PermissionRule(value = "READ", description = "Anyone can view open Competitions, only comp admin can see others")
    public boolean anyoneCanViewOpenCompetitions(CompetitionResource competition, UserResource user) {
        if (CompetitionResource.Status.OPEN.equals(competition.getCompetitionStatus())) {
            return true;
        } else {<commit_msg>INFUND-3907 Adjusting permission to only restrict competitions in setup.<commit_after>package com.worth.ifs.competition.security;

import com.worth.ifs.competition.resource.CompetitionResource;
import com.worth.ifs.security.BasePermissionRules;
import com.worth.ifs.security.PermissionRule;
import com.worth.ifs.security.PermissionRules;
import com.worth.ifs.user.resource.UserResource;
import com.worth.ifs.user.resource.UserRoleType;
import org.springframework.stereotype.Component;

/**
 * Provides the permissions around CRUD for Competitions
 */
@Component
@PermissionRules
public class CompetitionPermissionRules extends BasePermissionRules {

    @PermissionRule(value = "READ", description = "Anyone can view finished competitions. Only comp admin can see competitions in setup")
    public boolean anyoneCanViewOpenCompetitions(CompetitionResource competition, UserResource user) {
        if (!CompetitionResource.Status.COMPETITION_SETUP.equals(competition.getCompetitionStatus())) {
            return true;
        } else {
{'fraction_non_alphanumeric': 0.08535353535353535, 'fraction_numerical': 0.00202020202020202, 'mean_word_length': 5.516447368421052, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3528668', 'n_tokens_mistral': 520, 'n_tokens_neox': 498, 'n_words': 120}