Skip to content

Commit

Permalink
Remove vendor info section from Account details section
Browse files Browse the repository at this point in the history
  • Loading branch information
support committed Nov 16, 2023
1 parent 730b2d8 commit 074c70e
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 436 deletions.
5 changes: 0 additions & 5 deletions src/Core/Grand.Domain/Vendors/VendorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ public class VendorSettings : ISettings
/// Get or sets a value indicating whether vendor can edit information about itself (public store)
/// </summary>
public bool AllowVendorsToEditInfo { get; set; }
/// <summary>
/// Get or sets a value indicating whether vendor can upload picture file
/// </summary>
public bool AllowToUploadFile { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the store owner is notified that the vendor information has been changed
/// </summary>
Expand Down
14 changes: 1 addition & 13 deletions src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Vendor.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,7 @@
<span asp-validation-for="TermsOfServiceEnabled"></span>
</div>
</div>
<div class="form-group">
<div class="col-8 col-md-4 col-sm-4 text-right">
<admin-label asp-for="AllowToUploadFile" class="control-label" />
</div>
<div class="col-4 col-md-8 col-sm-8">
<label class="mt-checkbox mt-checkbox-outline control control-checkbox">
<admin-input asp-for="AllowToUploadFile" />
<div class="control__indicator"></div>
</label>
<span asp-validation-for="AllowToUploadFile"></span>
</div>
</div>
<div class="form-group">
<div class="form-group">
<div class="col-8 col-md-4 col-sm-4 text-right">
<admin-label asp-for="VendorReviewsMustBeApproved" class="control-label" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public VendorSettingsModel()

[GrandResourceDisplayName("Admin.Settings.Vendor.TermsOfServiceEnabled")]
public bool TermsOfServiceEnabled { get; set; }
[GrandResourceDisplayName("Admin.Settings.Vendor.AllowToUploadFile")]
public bool AllowToUploadFile { get; set; }
//review vendor
[GrandResourceDisplayName("Admin.Settings.Vendor.VendorReviewsMustBeApproved")]
public bool VendorReviewsMustBeApproved { get; set; }
Expand Down
3 changes: 0 additions & 3 deletions src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11424,9 +11424,6 @@
<Resource Name="Admin.Settings.Vendor.AllowCustomersToContactVendors" Area="Admin">
<Value>Allow customers to contact vendors</Value>
</Resource>
<Resource Name="Admin.Settings.Vendor.AllowToUploadFile" Area="Admin">
<Value>Allow vendor to upload picture file</Value>
</Resource>
<Resource Name="Admin.Settings.Vendor.AllowSearchByVendor" Area="Admin">
<Value>Allow search by vendor in store advanced search</Value>
</Resource>
Expand Down
161 changes: 2 additions & 159 deletions src/Web/Grand.Web/Controllers/VendorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Grand.SharedKernel.Extensions;
using Grand.Web.Commands.Models.Vendors;
using Grand.Web.Common.Controllers;
using Grand.Web.Common.Extensions;
using Grand.Web.Common.Filters;
using Grand.Web.Common.Security.Authorization;
using Grand.Web.Common.Security.Captcha;
Expand Down Expand Up @@ -113,7 +112,6 @@ public virtual async Task<IActionResult> ApplyVendor()
model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage;
model.Email = _workContext.CurrentCustomer.Email;
model.TermsOfServiceEnabled = _vendorSettings.TermsOfServiceEnabled;
model.AllowToUploadFile = _vendorSettings.AllowToUploadFile;
model.TermsOfServicePopup = _commonSettings.PopupForTermsOfServiceLinks;
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
model.Address = await _mediator.Send(new GetVendorAddress {
Expand All @@ -137,28 +135,6 @@ public virtual async Task<IActionResult> ApplyVendorSubmit(ApplyVendorModel mode
if (!_vendorSettings.AllowCustomersToApplyForVendorAccount)
return RedirectToRoute("HomePage");

var contentType = string.Empty;
byte[] vendorPictureBinary = null;

if (_vendorSettings.AllowToUploadFile && uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName))
{
try
{
contentType = uploadedFile.ContentType;
if (string.IsNullOrEmpty(contentType))
ModelState.AddModelError("", "Empty content type");
else
if (!contentType.StartsWith("image"))
ModelState.AddModelError("", "Only image content type is allowed");

vendorPictureBinary = uploadedFile.GetPictureBits();
}
catch (Exception)
{
ModelState.AddModelError("", _translationService.GetResource("Vendors.ApplyAccount.Picture.ErrorMessage"));
}
}

if (ModelState.IsValid)
{
var description = FormatText.ConvertText(model.Description);
Expand All @@ -173,13 +149,7 @@ public virtual async Task<IActionResult> ApplyVendorSubmit(ApplyVendorModel mode
AllowCustomerReviews = _vendorSettings.DefaultAllowCustomerReview
};
model.Address.ToEntity(vendor.Address);
if (vendorPictureBinary != null && !string.IsNullOrEmpty(contentType))
{
var picture = await _pictureService.InsertPicture(vendorPictureBinary, contentType, null, reference: Reference.Vendor, objectId: vendor.Id);
if (picture != null)
vendor.PictureId = picture.Id;
}


await _vendorService.InsertVendor(vendor);

//search engine name (the same as vendor name)
Expand Down Expand Up @@ -209,7 +179,6 @@ await _messageProviderService.SendNewVendorAccountApplyStoreOwnerMessage(_workCo
model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage;
model.TermsOfServiceEnabled = _vendorSettings.TermsOfServiceEnabled;
model.TermsOfServicePopup = _commonSettings.PopupForTermsOfServiceLinks;
model.AllowToUploadFile = _vendorSettings.AllowToUploadFile;
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
model.Address = await _mediator.Send(new GetVendorAddress {
Language = _workContext.WorkingLanguage,
Expand All @@ -222,133 +191,7 @@ await _messageProviderService.SendNewVendorAccountApplyStoreOwnerMessage(_workCo
});
return View(model);
}

[HttpGet]
[CustomerGroupAuthorize(SystemCustomerGroupNames.Registered)]
public virtual async Task<IActionResult> Info()
{
if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo)
return RedirectToRoute("CustomerInfo");

var model = new VendorInfoModel();
var vendor = _workContext.CurrentVendor;
model.Description = vendor.Description;
model.Email = vendor.Email;
model.Name = vendor.Name;
model.UserFields = vendor.UserFields;
model.AllowToUploadFile = _vendorSettings.AllowToUploadFile;
model.PictureUrl = await _pictureService.GetPictureUrl(vendor.PictureId);
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
model.Address = await _mediator.Send(new GetVendorAddress {
Language = _workContext.WorkingLanguage,
Address = vendor.Address,
ExcludeProperties = false,
LoadCountries = () => countries
});

return View(model);
}

[HttpPost]
[AutoValidateAntiforgeryToken]
[CustomerGroupAuthorize(SystemCustomerGroupNames.Registered)]
public virtual async Task<IActionResult> Info(VendorInfoModel model, IFormFile uploadedFile)
{
if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo)
return RedirectToRoute("CustomerInfo");

var contentType = string.Empty;
byte[] vendorPictureBinary = null;

if (_vendorSettings.AllowToUploadFile && uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName))
{
try
{
contentType = uploadedFile.ContentType;
if (string.IsNullOrEmpty(contentType))
ModelState.AddModelError("", "Empty content type");
else
if (!contentType.StartsWith("image"))
ModelState.AddModelError("", "Only image content type is allowed");

vendorPictureBinary = uploadedFile.GetPictureBits();
}
catch (Exception)
{
ModelState.AddModelError("", _translationService.GetResource("Account.VendorInfo.Picture.ErrorMessage"));
}
}

var vendor = _workContext.CurrentVendor;
var prevPicture = await _pictureService.GetPictureById(vendor.PictureId);
if (prevPicture == null)
vendor.PictureId = "";

if (ModelState.IsValid)
{
var description = FormatText.ConvertText(model.Description);

vendor.Name = model.Name;
vendor.Email = model.Email;
vendor.Description = description;

if (vendorPictureBinary != null && !string.IsNullOrEmpty(contentType))
{
var picture = await _pictureService.InsertPicture(vendorPictureBinary, contentType, null, reference: Reference.Vendor, objectId: vendor.Id);
if (picture != null)
vendor.PictureId = picture.Id;

if (prevPicture != null)
await _pictureService.DeletePicture(prevPicture);
}
//update picture seo file name
await UpdatePictureSeoNames(vendor);
model.Address.ToEntity(vendor.Address);

await _vendorService.UpdateVendor(vendor);

//notifications
if (_vendorSettings.NotifyStoreOwnerAboutVendorInformationChange)
await _messageProviderService.SendVendorInformationChangeMessage(vendor, _workContext.CurrentStore, _languageSettings.DefaultAdminLanguageId);

return RedirectToAction("Info");
}
var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);
model.Address = await _mediator.Send(new GetVendorAddress {
Language = _workContext.WorkingLanguage,
Model = model.Address,
Address = vendor.Address,
ExcludeProperties = false,
LoadCountries = () => countries
});

return View(model);
}

[HttpGet]
[CustomerGroupAuthorize(SystemCustomerGroupNames.Registered)]
public virtual async Task<IActionResult> RemovePicture()
{
if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo)
return RedirectToRoute("CustomerInfo");

var vendor = _workContext.CurrentVendor;
var picture = await _pictureService.GetPictureById(vendor.PictureId);

if (picture != null)
await _pictureService.DeletePicture(picture);

vendor.PictureId = "";
await _vendorService.UpdateVendor(vendor);

//notifications
if (_vendorSettings.NotifyStoreOwnerAboutVendorInformationChange)
await _messageProviderService.SendVendorInformationChangeMessage(vendor, _workContext.CurrentStore, _languageSettings.DefaultAdminLanguageId);

return RedirectToAction("Info");
}



[HttpPost]
[AutoValidateAntiforgeryToken]
[DenySystemAccount]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ public async Task<CustomerNavigationModel> Handle(GetNavigation request, Cancell
HideCourses = _customerSettings.HideCoursesTab,
HideSubAccounts = _customerSettings.HideSubAccountsTab || !string.IsNullOrEmpty(request.Customer.OwnerId)
};
if (_vendorSettings.AllowVendorsToEditInfo && request.Vendor != null)
{
model.ShowVendorInfo = true;
}
model.SelectedTab = (AccountNavigationEnum)request.SelectedTabId;

return await Task.FromResult(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class CustomerNavigationModel : BaseModel
public bool HideAuctions { get; set; }
public bool HideNotes { get; set; }
public bool HideDocuments { get; set; }
public bool ShowVendorInfo { get; set; }
public bool HideReviews { get; set; }
public bool HideCourses { get; set; }
public bool HideSubAccounts { get; set; }
Expand Down
1 change: 0 additions & 1 deletion src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public ApplyVendorModel()
public bool TermsOfServiceEnabled { get; set; }
public bool TermsOfServicePopup { get; set; }
public bool DisableFormInput { get; set; }
public bool AllowToUploadFile { get; set; }
public string Result { get; set; }
}
}
27 changes: 0 additions & 27 deletions src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs

This file was deleted.

Loading

0 comments on commit 074c70e

Please sign in to comment.