Skip to content

Commit

Permalink
#504: media and vimeo modules updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simonas Mikulenas committed Jul 3, 2013
1 parent b26aa78 commit 8a6de97
Show file tree
Hide file tree
Showing 20 changed files with 204 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
<Compile Include="Models\Extensions\MediaExtensions.cs" />
<Compile Include="Models\Extensions\MediaFileExtensions.cs" />
<Compile Include="Models\Maps\MediaTagMap.cs" />
<Compile Include="Models\Maps\MediaVideoMap.cs" />
<Compile Include="Models\MediaImageAlign.cs" />
<Compile Include="Models\MediaType.cs" />
<Compile Include="Models\Maps\MediaMap.cs" />
Expand All @@ -191,8 +192,10 @@
<Compile Include="Models\MediaFolder.cs" />
<Compile Include="Models\Media.cs" />
<Compile Include="Models\MediaImage.cs" />
<Compile Include="Models\MediaVideo.cs" />
<Compile Include="Models\MigrationsContent\Migration201306201216.cs" />
<Compile Include="Models\MigrationsContent\Migration201306071105.cs" />
<Compile Include="Models\Migrations\Migration201307011545.cs" />
<Compile Include="Models\Migrations\Migration2013062810010.cs" />
<Compile Include="Models\Migrations\Migration201306271601.cs" />
<Compile Include="Models\Migrations\Migration201306271317.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
using BetterCms.Module.MediaManager.Command.MediaManager;
using System;

using BetterCms.Module.MediaManager.Command.MediaManager;
using BetterCms.Module.MediaManager.Models;
using BetterCms.Module.MediaManager.ViewModels.MediaManager;

namespace BetterCms.Module.MediaManager.Command.Videos.GetVideos
{
public class GetVideosCommand : GetMediaItemsCommandBase<MediaFile>
/// <summary>
/// Command to get all the videos.
/// </summary>
public class GetVideosCommand : GetMediaItemsCommandBase<MediaVideo>
{
/// <summary>
/// Gets the type of the current media items.
Expand All @@ -15,5 +21,26 @@ protected override MediaType MediaType
{
get { return MediaType.Video; }
}

/// <summary>
/// To the view model.
/// </summary>
/// <param name="media">The media.</param>
/// <returns>Video view model.</returns>
/// <exception cref="System.InvalidOperationException">Cannot convert media to video view model. Wrong entity passed.</exception>
protected override MediaViewModel ToViewModel(Media media)
{
var video = media as MediaVideo;
if (video != null)
{
var model = new MediaVideoViewModel();

FillMediaFileViewModel(model, video);

return model;
}

throw new InvalidOperationException("Cannot convert media to video view model. Wrong entity passed.");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
<value>Are you sure you want to send the media {0} to archive?</value>
</data>
<data name="ArchiveVideo_ConfirmationMessage" xml:space="preserve">
<value>Are you sure you want to send the video {0} to archive?archive?</value>
<value>Are you sure you want to send the video {0} to archive?</value>
</data>
<data name="MediaManager_ButtonArchive" xml:space="preserve">
<value>Archive</value>
Expand Down
19 changes: 19 additions & 0 deletions Modules/BetterCms.Module.MediaManager/Models/Maps/MediaVideoMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

using BetterCms.Core.Models;

namespace BetterCms.Module.MediaManager.Models.Maps
{
[Serializable]
public class MediaVideoMap : EntitySubClassMapBase<MediaVideo>
{
public MediaVideoMap()
: base(MediaManagerModuleDescriptor.ModuleName)
{
Table("MediaVideos");

Map(x => x.ProviderName).Nullable();
Map(x => x.VideoId).Nullable();
}
}
}
51 changes: 51 additions & 0 deletions Modules/BetterCms.Module.MediaManager/Models/MediaVideo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;

namespace BetterCms.Module.MediaManager.Models
{
/// <summary>
/// Media video data entity.
/// </summary>
[Serializable]
public class MediaVideo : MediaFile
{
/// <summary>
/// Gets or sets the name of the provider.
/// </summary>
/// <value>
/// The name of the provider.
/// </value>
public virtual string ProviderName { get; set; }

/// <summary>
/// Gets or sets the video id according to provider.
/// </summary>
/// <value>
/// The video id.
/// </value>
public virtual string VideoId { get; set; }

/// <summary>
/// Clones this instance.
/// </summary>
/// <returns></returns>
public virtual MediaVideo Clone()
{
return CopyDataTo(new MediaVideo());
}

/// <summary>
/// Copies the data to.
/// </summary>
/// <param name="media">The media.</param>
/// <returns></returns>
public virtual MediaVideo CopyDataTo(MediaVideo media)
{
var copy = (MediaVideo)base.CopyDataTo(media);

copy.ProviderName = ProviderName;
copy.VideoId = VideoId;

return copy;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;

using BetterCms.Core.DataAccess.DataContext.Migrations;
using BetterCms.Core.Models;

using FluentMigrator;

namespace BetterCms.Module.MediaManager.Models.Migrations
{
/// <summary>
/// Migration for IsInSitemap.
/// </summary>
[Migration(201307011545)]
public class Migration201307011545 : DefaultMigration
{
/// <summary>
/// Initializes a new instance of the <see cref="Migration201307011545"/> class.
/// </summary>
public Migration201307011545()
: base(MediaManagerModuleDescriptor.ModuleName)
{
}

/// <summary>
/// Migrate up.
/// </summary>
public override void Up()
{
Create
.Table("MediaVideos").InSchema(SchemaName)
.WithColumn("Id").AsGuid().PrimaryKey().NotNullable()
.WithColumn("ProviderName").AsString(MaxLength.Name).Nullable()
.WithColumn("VideoId").AsString(MaxLength.Name).Nullable();
}

/// <summary>
/// Migrate down.
/// </summary>
public override void Down()
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public virtual void RemoveFile(Guid fileId, int version)

public virtual MediaFile UploadFile(MediaType type, Guid rootFolderId, string fileName, long fileLength, Stream fileStream)
{
string folderName = CreateRandomFolderName();
MediaFile file = new MediaFile();
var folderName = CreateRandomFolderName();
var file = type == MediaType.Video ? new MediaVideo() : new MediaFile();
if (!rootFolderId.HasDefaultValue())
{
file.Folder = repository.AsProxy<MediaFolder>(rootFolderId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace BetterCms.Module.MediaManager.Services
using BetterCms.Module.MediaManager.Models;
using BetterCms.Module.MediaManager.ViewModels.MediaManager;

namespace BetterCms.Module.MediaManager.Services
{
public interface IMediaVideoService
{
{
}
}
12 changes: 5 additions & 7 deletions Modules/BetterCms.Module.Vimeo/BetterCms.Module.Vimeo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@
<Compile Include="..\..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Command\Videos\GetVideos\GetVideosCommand.cs" />
<Compile Include="Content\Resources\Globalization.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Globalization.resx</DependentUpon>
</Compile>
<Compile Include="Controllers\VideoController.cs" />
<Compile Include="ViewModels\Video\VideoViewModel.cs" />
<Compile Include="VimeoModuleDescriptor.cs" />
<Compile Include="Models\Maps\VideoMap.cs" />
<Compile Include="Models\Video.cs" />
<Compile Include="Models\Migrations\InitialSetup.cs" />
<Compile Include="Models\Migrations\MigrationVersionMetaData.cs" />
<Compile Include="Models\Video.cs" />
<Compile Include="Services\VimeoVideoService.cs" />
<Compile Include="ViewModels\Video\VideoViewModel.cs" />
<Compile Include="VimeoModuleDescriptor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Registration\VideoJsModuleIncludeDescriptor.cs" />
</ItemGroup>
Expand Down Expand Up @@ -172,9 +172,7 @@
<EmbeddedResource Include="Scripts\bcms.vimeo.js" />
<Content Include="web.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Views\Web.config" />
</ItemGroup>
Expand Down

This file was deleted.

39 changes: 19 additions & 20 deletions Modules/BetterCms.Module.Vimeo/Controllers/VideoController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Web.Mvc;

using BetterCms.Core.Security;
using BetterCms.Module.MediaManager.Command.Videos.GetVideos;
using BetterCms.Module.MediaManager.ViewModels.MediaManager;
using BetterCms.Module.Root;
using BetterCms.Module.Root.Models;
using BetterCms.Module.Root.Mvc;
using BetterCms.Module.Vimeo.Command.Videos;
using BetterCms.Module.Vimeo.Command.Videos.GetVideos;

using Microsoft.Web.Mvc;

Expand All @@ -16,23 +15,23 @@ namespace BetterCms.Module.Vimeo.Controllers
[ActionLinkArea(VimeoModuleDescriptor.VimeoServiceAreaName)]
public class VideoController : CmsControllerBase
{
[BcmsAuthorize(RootModuleConstants.UserRoles.EditContent, RootModuleConstants.UserRoles.DeleteContent)]
public ActionResult Index(MediaManagerViewModel options)
{
var success = true;
if (options == null)
{
options = new MediaManagerViewModel();
}
options.SetDefaultPaging();

var model = GetCommand<GetVideosCommand>().ExecuteCommand(options);
if (model == null)
{
success = false;
}

return Json(new WireJson { Success = success, Data = model });
}
// [BcmsAuthorize(RootModuleConstants.UserRoles.EditContent, RootModuleConstants.UserRoles.DeleteContent)]
// public ActionResult Index(MediaManagerViewModel options)
// {
// var success = true;
// if (options == null)
// {
// options = new MediaManagerViewModel();
// }
// options.SetDefaultPaging();
//
// var model = GetCommand<GetVideosCommand>().ExecuteCommand(options);
// if (model == null)
// {
// success = false;
// }
//
// return Json(new WireJson { Success = success, Data = model });
// }
}
}
2 changes: 0 additions & 2 deletions Modules/BetterCms.Module.Vimeo/Models/Maps/VideoMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public VideoMap()
{
Table("Videos");

Map(x => x.VideoId).Not.Nullable();
Map(x => x.Html).Nullable();
Map(x => x.ThumbnailUrl).Nullable();
Map(x => x.AuthorName).Nullable();
Map(x => x.AuthorUrl).Nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BetterCms.Module.Vimeo.Models.Migrations
/// <summary>
/// Module initial database structure creation.
/// </summary>
[Migration(201307011543)]
[Migration(201307011550)]
public class InitialSetup : DefaultMigration
{
/// <summary>
Expand All @@ -29,8 +29,6 @@ public override void Up()
Create
.Table("Videos").InSchema(SchemaName)
.WithColumn("Id").AsGuid().PrimaryKey().NotNullable()
.WithColumn("VideoId").AsInt32().NotNullable()
.WithColumn("Html").AsString(MaxLength.Text).Nullable()
.WithColumn("ThumbnailUrl").AsString(MaxLength.Url).Nullable()
.WithColumn("AuthorName").AsString(MaxLength.Name).Nullable()
.WithColumn("AuthorUrl").AsString(MaxLength.Url).Nullable();
Expand Down
Loading

0 comments on commit 8a6de97

Please sign in to comment.