diff --git a/README.md b/README.md index daeabdb645e..28e424cd1d6 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,6 @@ -nopCommerce: free and open-source eCommerce solution -=========== - -[nopCommerce](https://www.nopcommerce.com/?utm_source=github&utm_medium=content&utm_campaign=homepage) is the best open-source eCommerce platform. nopCommerce is free, and it is the most popular ASP.NET Core shopping cart. - -![nopCommerce demo](https://www.nopcommerce.com/images/github/responsive_devices_codeplex.png#v1) - -### Key features ### - -* The product is being developed and supported by the professional team since 2008. -* nopCommerce has been downloaded more than 3,000,000 times. -* The active developer community has more than 250,000 members. -* nopCommerce runs on .NET 6 with an MS SQL 2012 (or higher) backend database. -* nopCommerce is cross-platform, and you can run it on Windows, Linux, or Mac. -* nopCommerce supports Docker out of the box, so you can easily run nopCommerce on a Linux machine. -* nopCommerce supports PostgreSQL and MySQL databases. -* nopCommerce fully supports web farms. You can read more about it [here](https://docs.nopcommerce.com/en/developer/tutorials/web-farms.html?utm_source=github&utm_medium=referral&utm_campaign=documentation&utm_content=text). -* All methods in nopCommerce are async. -* nopCommerce supports multi-factor authentication out of the box. -* Start our [online course for developers](https://nopcommerce.com/training?utm_source=github&utm_medium=referral&utm_campaign=course&utm_content=text) and get the practical and technical skills you need to run and customize nopCommerce websites. - -![Logo](https://www.nopcommerce.com/images/github/logos.png#v2) - -nopCommerce architecture follows well-known software patterns and the best security practices. The source code is fully customizable. Pluggable and clear architecture makes it easy to develop custom functionality and follow any business requirements. - -Using the latest Microsoft technologies, nopCommerce provides high performance, stability, and security. nopCommerce is also fully compatible with Azure and web farms. - -Our clear and detailed [documentation](https://docs.nopcommerce.com/developer/index.html?utm_source=github&utm_medium=referral&utm_campaign=documentation&utm_content=text) and [online course](https://nopcommerce.com/training?utm_source=github&utm_medium=referral&utm_campaign=course&utm_content=text) for developers will help you start with nopCommerce easily. - - -### The advantages of working with nopCommerce ### - -nopCommerce offers powerful [out-of-the-box features](https://www.nopcommerce.com/features?utm_source=github&utm_medium=referral&utm_campaign=features&utm_content=text) for creating an online store of any size and type. - -nopCommerce is integrated with all the popular third-party services. You can find thousands of integrations on nopCommerce [Marketplace](https://www.nopcommerce.com/marketplace?utm_source=github&utm_medium=referral&utm_campaign=marketplace&utm_content=text). - -The [Web API plugin](https://www.nopcommerce.com/web-api?utm_source=github&utm_medium=referral&utm_campaign=WebAPI&utm_content=text) by the nopCommerce team lets you build integrations with third-party services or mobile applications using REST. The Web API plugin is available with source code and covers all methods of nopCommerce: backend and frontend. You can read more about it [here](https://www.nopcommerce.com/web-api?utm_source=github&utm_medium=referral&utm_campaign=WebAPI&utm_content=text). - -Friendly members of the [nopCommerce community](https://www.nopcommerce.com/boards?utm_source=github&utm_medium=referral&utm_campaign=forum&utm_content=text) will always help with advice and share their experiences. nopCommerce core development team provides [professional support](https://www.nopcommerce.com/nopcommerce-premium-support-services?utm_source=github&utm_medium=referral&utm_campaign=premium_support&utm_content=text) within 24 hours. - - -## Store demo ## - -Evaluate the functionality and convenience of nopCommerce as a customer and store owner. - -Front End | Admin area -----|------ -[![ScreenShot](https://www.nopcommerce.com/images/github/public-demo.png#v1)](https://frontend.nopcommerce.com?utm_source=github&utm_medium=referral&utm_campaign=demo_store&utm_content=button) | [![ScreenShot](https://www.nopcommerce.com/images/github/admin-demo.png#v1)](https://admin-demo.nopcommerce.com/admin?utm_source=github&utm_medium=referral&utm_campaign=demo_store&utm_content=button) - - -### nopCommerce resources ### - -nopCommerce official site: [https://www.nopcommerce.com](https://www.nopcommerce.com/?utm_source=github&utm_medium=referral&utm_campaign=homepage&utm_content=links) - -* [Demo store](https://www.nopcommerce.com/demo?utm_source=github&utm_medium=referral&utm_campaign=demo_store&utm_content=links) -* [Download nopCommerce](https://www.nopcommerce.com/download-nopcommerce?utm_source=github&utm_medium=referral&utm_campaign=download_nop&utm_content=links) -* [Online course for developers](https://nopcommerce.com/training?utm_source=github&utm_medium=referral&utm_campaign=course&utm_content=links) -* [Feature list](https://www.nopcommerce.com/features?utm_source=github&utm_medium=referral&utm_campaign=features&utm_content=links) -* [Web API plugin](https://www.nopcommerce.com/web-api?utm_source=github&utm_medium=referral&utm_campaign=WebAPI&utm_content=links) -* [nopCommerce documentation](https://docs.nopcommerce.com?utm_source=github&utm_medium=referral&utm_campaign=documentation&utm_content=links) -* [Community forums](https://www.nopcommerce.com/boards?utm_source=github&utm_medium=referral&utm_campaign=forum&utm_content=links) -* [Premium support services](https://www.nopcommerce.com/nopcommerce-premium-support-services?utm_source=github&utm_medium=referral&utm_campaign=premium_support&utm_content=links) -* [Certified developer program](https://www.nopcommerce.com/certified-developer-program?utm_source=github&utm_medium=referral&utm_campaign=certified_developer&utm_content=links) -* [nopCommerce partners](https://www.nopcommerce.com/partners?utm_source=github&utm_medium=referral&utm_campaign=solution_partners&utm_content=links) - -nopCommerce YouTube: [The Architecture behind the nopCommerce eCommerce Platform](https://www.youtube.com/watch?v=6gLbizzSA9o&list=PLnL_aDfmRHwtJmzeA7SxrpH3-XDY2ue0a) - - -### Earn with nopCommerce ### - -60,000 stores worldwide are powered by nopCommerce, and 10,000 new stores open every year. nopCommerce [solution partners’ directory](https://www.nopcommerce.com/partners?utm_source=github&utm_medium=referral&utm_campaign=solution_partners&utm_content=text_become_partner) gets 80,000+ page views per year from store owners who are looking for a partner to build a store from scratch, migrate from another platform, or improve and customize an existing store. - -Become a solution partner of nopCommerce and get new clients – [learn more](https://www.nopcommerce.com/become-partner?utm_source=github&utm_medium=referral&utm_campaign=become-partner&utm_content=learn_more). - -Create a new graphical theme or develop a new plugin or integration and sell it on the nopCommerce [Marketplace](https://www.nopcommerce.com/marketplace?utm_source=github&utm_medium=referral&utm_campaign=marketplace&utm_content=text_sell_on_marketplace). - - -### Contribute ### - -As a free and open-source project, we are very grateful to everyone who helps us to develop nopCommerce. Please find more details about the options and bonuses for contributors at [contribute page](https://www.nopcommerce.com/contribute?utm_source=github&utm_medium=referral&utm_campaign=contribute&utm_content=text). +Here I Add new product permissions for ADD or Edit. +add if condition in view to show the published field if the user has the permission PublishPermission +set the field published to false when editing the product if current user doesnt have the permission PublishPermission +set the field published always to false on create or Edit +add permission PublishPermission in the following permission provider (admin area). +set the field published always to false when importing products diff --git a/src/Libraries/Nop.Services/Security/StandardPermissionProvider.cs b/src/Libraries/Nop.Services/Security/StandardPermissionProvider.cs index 4906e072f26..805658a6f84 100644 --- a/src/Libraries/Nop.Services/Security/StandardPermissionProvider.cs +++ b/src/Libraries/Nop.Services/Security/StandardPermissionProvider.cs @@ -58,7 +58,7 @@ public partial class StandardPermissionProvider : IPermissionProvider public static readonly PermissionRecord HtmlEditorManagePictures = new() { Name = "Admin area. HTML Editor. Manage pictures", SystemName = "HtmlEditor.ManagePictures", Category = "Configuration" }; public static readonly PermissionRecord ManageScheduleTasks = new() { Name = "Admin area. Manage Schedule Tasks", SystemName = "ManageScheduleTasks", Category = "Configuration" }; public static readonly PermissionRecord ManageAppSettings = new() { Name = "Admin area. Manage App Settings", SystemName = "ManageAppSettings", Category = "Configuration" }; - + public static readonly PermissionRecord ManagePublish = new() { Name = "Admin area. Manage Publish ", SystemName = "ManagePublish", Category = "Catalog" }; //public store permissions public static readonly PermissionRecord DisplayPrices = new() { Name = "Public store. Display Prices", SystemName = "DisplayPrices", Category = "PublicStore" }; public static readonly PermissionRecord EnableShoppingCart = new() { Name = "Public store. Enable shopping cart", SystemName = "EnableShoppingCart", Category = "PublicStore" }; @@ -132,7 +132,9 @@ public virtual IEnumerable GetPermissions() PublicStoreAllowNavigation, AccessClosedStore, AccessProfiling, - EnableMultiFactorAuthentication + EnableMultiFactorAuthentication, + ManagePublish + }; } @@ -202,7 +204,9 @@ public virtual IEnumerable GetPermissions() PublicStoreAllowNavigation, AccessClosedStore, AccessProfiling, - EnableMultiFactorAuthentication + EnableMultiFactorAuthentication, + ManagePublish + } ), ( diff --git a/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs b/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs index 76065accd52..51ce96fafa7 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs +++ b/src/Presentation/Nop.Web/Areas/Admin/Controllers/ProductController.cs @@ -799,7 +799,7 @@ public virtual async Task Create(bool showtour = false) //prepare model var model = await _productModelFactory.PrepareProductModelAsync(new ProductModel(), null); - + model.CanPublish = await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePublish); //show configuration tour if (showtour) { @@ -819,6 +819,7 @@ public virtual async Task Create(ProductModel model, bool continu { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); + var canPublish = await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePublish); //validate maximum number of products per vendor var currentVendor = await _workContext.GetCurrentVendorAsync(); @@ -841,6 +842,7 @@ public virtual async Task Create(ProductModel model, bool continu model.ShowOnHomepage = false; //product + model.Published = canPublish ? model.Published : false; var product = model.ToEntity(); product.CreatedOnUtc = DateTime.UtcNow; product.UpdatedOnUtc = DateTime.UtcNow; @@ -892,7 +894,7 @@ await _customerActivityService.InsertActivityAsync("AddNewProduct", //prepare model model = await _productModelFactory.PrepareProductModelAsync(model, null, true); - + model.CanPublish = canPublish; //if we got this far, something failed, redisplay form return View(model); } @@ -901,6 +903,7 @@ public virtual async Task Edit(int id) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); + var canPublish = await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePublish); //try to get a product with the specified id var product = await _productService.GetProductByIdAsync(id); @@ -914,7 +917,7 @@ public virtual async Task Edit(int id) //prepare model var model = await _productModelFactory.PrepareProductModelAsync(null, product); - + model.CanPublish = canPublish; return View(model); } @@ -923,6 +926,7 @@ public virtual async Task Edit(ProductModel model, bool continueE { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); + var canPublish = await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePublish); //try to get a product with the specified id var product = await _productService.GetProductByIdAsync(model.Id); @@ -963,6 +967,7 @@ public virtual async Task Edit(ProductModel model, bool continueE var previousProductType = product.ProductType; //product + model.Published = canPublish ? model.Published : false; product = model.ToEntity(product); product.UpdatedOnUtc = DateTime.UtcNow; diff --git a/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductModelFactory.cs b/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductModelFactory.cs index 4672f36f931..2fc748e604c 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductModelFactory.cs +++ b/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductModelFactory.cs @@ -880,7 +880,7 @@ public virtual async Task PrepareProductModelAsync(ProductModel mo model.UnlimitedDownloads = true; model.IsShipEnabled = true; model.AllowCustomerReviews = true; - model.Published = true; + model.Published = false; model.VisibleIndividually = true; } diff --git a/src/Presentation/Nop.Web/Areas/Admin/Models/Catalog/ProductModel.cs b/src/Presentation/Nop.Web/Areas/Admin/Models/Catalog/ProductModel.cs index 4497c340f23..ae48f400372 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Models/Catalog/ProductModel.cs +++ b/src/Presentation/Nop.Web/Areas/Admin/Models/Catalog/ProductModel.cs @@ -394,6 +394,7 @@ public ProductModel() public IList Locales { get; set; } + public bool CanPublish { get; set; } //ACL (customer roles) [NopResourceDisplayName("Admin.Catalog.Products.Fields.AclCustomerRoles")] public IList SelectedCustomerRoleIds { get; set; } diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/Product/_CreateOrUpdate.Info.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/Product/_CreateOrUpdate.Info.cshtml index 36d451704f1..44a7931cf06 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Views/Product/_CreateOrUpdate.Info.cshtml +++ b/src/Presentation/Nop.Web/Areas/Admin/Views/Product/_CreateOrUpdate.Info.cshtml @@ -306,7 +306,7 @@ -
+