//TODO: maybe move this to ApplicationService and make it public
 private void EnsureApplicationPermission(Guid appId)
 {
     if (appId == ServiceLocator.ServiceLocatorMaster.ApplicationService.GetAssessmentId())
     {
         if (!ApplicationSecurity.HasAssessmentEnabled(Context) && !ApplicationSecurity.HasStudyCenterAccess(Context))
         {
             throw new ChalkableSecurityException("Current user has disabled assessment access");
         }
     }
     else if (!ApplicationSecurity.HasStudyCenterAccess(Context))
     {
         throw new StudyCenterDisabledException();
     }
 }
Exemplo n.º 2
0
        public ActionResult AttachSettings(int announcementId, int?announcementType)
        {
            Trace.Assert(Context.PersonId.HasValue);

            var assesmentId          = (!ApplicationSecurity.HasStudyCenterAccess(Context) && !ApplicationSecurity.HasAssessmentEnabled(Context)) ? null : MasterLocator.ApplicationService.GetAssessmentId();
            var type                 = (AnnouncementTypeEnum?)announcementType ?? AnnouncementTypeEnum.Class;
            var canAddStandard       = SchoolLocator.GetAnnouncementService(type).CanAddStandard(announcementId);
            var isAppEnabled         = BaseSecurity.IsDistrictOrTeacher(Context) && Context.SCEnabled;
            var isFileCabinetEnabled = Context.Role == CoreRoles.TEACHER_ROLE; //only teacher can use file cabinet for now

            var apps = MasterLocator.ApplicationService.GetApplications(live: true).ToList();

            apps = apps.Where(app => MasterLocator.ApplicationService.HasExternalAttachMode(app)).ToList();
            return(Json(AttachSettingsViewData.Create(assesmentId, canAddStandard, isAppEnabled, isFileCabinetEnabled, apps)));
        }