Skip to content

Commit

Permalink
Merge pull request #559 from gurch101/add-customer-detail-modal
Browse files Browse the repository at this point in the history
Add customer detail modal to admin order creator (SHUUP-2725)
  • Loading branch information
tulimaki committed Jun 27, 2016
2 parents 22c2df3 + ffcd2f9 commit d4d7edd
Show file tree
Hide file tree
Showing 14 changed files with 343 additions and 49 deletions.
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Localization
Admin
~~~~~

- Add customer detail view to order creator
- Define module-level permissions for all admin modules
- Enable adding of permission groups from `Users` admin
- Add admin module for managing Django permission groups
Expand Down
59 changes: 52 additions & 7 deletions shoop/admin/locale/en/LC_MESSAGES/djangojs.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-13 20:20+0000\n"
"POT-Creation-Date: 2016-06-20 19:23+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: en <LL@li.org>\n"
Expand Down Expand Up @@ -132,6 +132,51 @@ msgstr ""
msgid "Shipping address"
msgstr ""

msgid "Full Name"
msgstr ""

msgid "Phone"
msgstr ""

msgid "Email"
msgstr ""

msgid "Groups"
msgstr ""

msgid "Companies"
msgstr ""

msgid "Merchant Notes"
msgstr ""

msgid "Year"
msgstr ""

msgid "Total Sales"
msgstr ""

msgid "Shipment Status"
msgstr ""

msgid "Payment Status"
msgstr ""

msgid "Order Status"
msgstr ""

msgid "Customer Information"
msgstr ""

msgid "Order Summary"
msgstr ""

msgid "Recent Orders"
msgstr ""

msgid "Close"
msgstr ""

msgid "A new customer will be created based on billing address."
msgstr ""

Expand All @@ -144,6 +189,9 @@ msgstr ""
msgid "New Customer"
msgstr ""

msgid "View Details"
msgstr ""

msgid "Save customer details while creating order"
msgstr ""

Expand Down Expand Up @@ -263,12 +311,6 @@ msgstr ""
msgid "Tax number"
msgstr ""

msgid "Phone"
msgstr ""

msgid "Email"
msgstr ""

msgid "Street"
msgstr ""

Expand All @@ -287,6 +329,9 @@ msgstr ""
msgid "Country"
msgstr ""

msgid "No records found."
msgstr ""

msgid "Identifier"
msgstr ""

Expand Down
11 changes: 2 additions & 9 deletions shoop/admin/modules/contacts/views/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
from django.conf import settings
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http.response import HttpResponseRedirect
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView

from shoop.admin.toolbar import PostActionButton, Toolbar, URLActionButton
from shoop.core.models import CompanyContact, Contact, Order, PersonContact
from shoop.core.models import CompanyContact, Contact, PersonContact
from shoop.utils.excs import Problem


Expand Down Expand Up @@ -103,18 +102,12 @@ def get_context_data(self, **kwargs):
context = super(ContactDetailView, self).get_context_data(**kwargs)
context["companies"] = []
if isinstance(self.object, PersonContact):
order_q = Q(orderer=self.object) | Q(customer=self.object)
context["companies"] = sorted(
self.object.company_memberships.all(), key=(lambda x: force_text(x))
)
else:
order_q = Q(customer=self.object)
user = getattr(self.object, "user", None)
if user:
order_q |= Q(creator=user)
context["contact_groups"] = sorted(
self.object.groups.all(), key=(lambda x: force_text(x)))
context["orders"] = Order.objects.filter(order_q).order_by("-id")
context["orders"] = self.object.customer_orders.order_by("-id")
context["toolbar"] = ContactDetailToolbar(contact=self.object, request=self.request)
context["title"] = "%s: %s" % (
self.object._meta.verbose_name.title(),
Expand Down
16 changes: 16 additions & 0 deletions shoop/admin/modules/orders/static_src/create/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const setAddressSavingOption = createAction("setAddressSavingOption");
export const setShipToBillingAddress = createAction("setShipToBillingAddress");
export const setIsCompany = createAction("setIsCompany");
export const setCustomer = createAction("setCustomer");
export const showCustomerModal = createAction("showCustomerModal");
// Methods actions
export const setShippingMethodChoices = createAction("setShippingMethodChoices");
export const setShippingMethod = createAction("setShippingMethod");
Expand Down Expand Up @@ -85,6 +86,20 @@ export const retrieveCustomerData = function({id}) {
};
};

export const retrieveCustomerDetails = function({id}) {
return (dispatch) => {
return get("customer_details", {
id
}).then((data) => {
if (data.error) {
alert(data.error);
return;
}
dispatch(receiveCustomerDetails({ id, data }));
});
};
};

export const retrieveOrderSourceData = function () {
return (dispatch, getState) => {
const state = getState();
Expand Down Expand Up @@ -114,6 +129,7 @@ export const updateLines = () => {

export const receiveProductData = createAction("receiveProductData");
export const receiveCustomerData = createAction("receiveCustomerData");
export const receiveCustomerDetails = createAction("receiveCustomerDetails");
export const receiveOrderSourceData = createAction("receiveOrderSourceData");
export const endFinalizingOrder = createAction("endFinalizingOrder");

Expand Down
4 changes: 2 additions & 2 deletions shoop/admin/modules/orders/static_src/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import {
setPaymentMethod,
setLines,
setOrderId,
updateTotals,
clearOrderSourceData
updateTotals
} from "./actions";

var controller = null;
Expand All @@ -43,6 +42,7 @@ export function init(config = {}) {
const customerData = config.customerData;

const persistor = persistStore(store);
persistor.purge(["customerDetails"]);
const resetOrder = window.localStorage.getItem("resetSavedOrder") || "false";
var savedOrder = {id: null};
if (resetOrder === "true") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* This file is part of Shoop.
*
* Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.
*
* This source code is licensed under the AGPLv3 license found in the
* LICENSE file in the root directory of this source tree.
*/
import {handleActions} from "redux-actions";
import _ from "lodash";

export default handleActions({
retrieveCustomerDetails: _.identity,
receiveCustomerDetails: (state, {payload}) => {
return _.assign(state, {
customerInfo: payload.data.customer_info,
orderSummary: payload.data.order_summary,
recentOrders: payload.data.recent_orders
});
},
showCustomerModal: ((state, {payload}) => _.assign(state, {showCustomerModal: payload}))
}, {});
13 changes: 12 additions & 1 deletion shoop/admin/modules/orders/static_src/create/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ import productData from "./productData";
import shop from "./shop";
import customer from "./customer";
import customerData from "./customerData";
import customerDetails from "./customerDetails";
import methods from "./methods";
import order from "./order";
import comment from "./comment";

const childReducer = combineReducers({lines, productData, shop, customer, customerData, methods, order, comment});
const childReducer = combineReducers({
lines,
productData,
shop,
customer,
customerData,
customerDetails,
methods,
order,
comment
});

export default function(state, action) {
if(action.type === "_replaceState") { // For debugging purposes.
Expand Down
Loading

0 comments on commit d4d7edd

Please sign in to comment.